aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PDFPrimitivesTest.cpp
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-25 19:27:23 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-25 19:27:23 +0000
commit4e1cc6ac450903510b96c1b12f6ee6f420044a66 (patch)
tree8a5160b6762816863800d0ae6ecf32dcba707719 /tests/PDFPrimitivesTest.cpp
parent6d5d08f14f1907d516ee28656dfd9ca063e0f7fc (diff)
[PDF] Handle invalid glyph IDs on drawText methods.
Review URL: https://codereview.appspot.com/7179053 git-svn-id: http://skia.googlecode.com/svn/trunk@7401 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PDFPrimitivesTest.cpp')
-rw-r--r--tests/PDFPrimitivesTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 42fc133b3c..6e7d61676d 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -8,9 +8,11 @@
#include "Test.h"
+#include "SkCanvas.h"
#include "SkData.h"
#include "SkFlate.h"
#include "SkPDFCatalog.h"
+#include "SkPDFDevice.h"
#include "SkPDFStream.h"
#include "SkPDFTypes.h"
#include "SkScalar.h"
@@ -217,6 +219,28 @@ static void TestSubstitute(skiatest::Reporter* reporter) {
buffer.getOffset()));
}
+// This test used to assert without the fix submitted for
+// http://code.google.com/p/skia/issues/detail?id=1083.
+// SKP files might have invalid glyph ids. This test ensures they are ignored,
+// and there is no assert on input data in Debug mode.
+static void test_issue1083(skiatest::Reporter* reporter) {
+ SkISize pageSize = SkISize::Make(100, 100);
+ SkPDFDevice* dev = new SkPDFDevice(pageSize, pageSize, SkMatrix::I());
+
+ SkCanvas c(dev);
+ SkPaint paint;
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+
+ uint16_t glyphID = 65000;
+ c.drawText(&glyphID, 2, 0, 0, paint);
+
+ SkPDFDocument doc;
+ doc.appendPage(dev);
+
+ SkDynamicMemoryWStream stream;
+ doc.emitPDF(&stream);
+}
+
static void TestPDFPrimitives(skiatest::Reporter* reporter) {
SkAutoTUnref<SkPDFInt> int42(new SkPDFInt(42));
SimpleCheckObjectOutput(reporter, int42.get(), "42");
@@ -298,6 +322,8 @@ static void TestPDFPrimitives(skiatest::Reporter* reporter) {
TestObjectRef(reporter);
TestSubstitute(reporter);
+
+ test_issue1083(reporter);
}
#include "TestClassDef.h"