diff options
author | halcanary <halcanary@google.com> | 2015-03-01 06:55:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-01 06:55:20 -0800 |
commit | 3d32d50364d1b63777fbf05c3593a35601bde9e2 (patch) | |
tree | c1624a6fba189f14c9813727e463dccb84cd22c5 /tests/PDFPrimitivesTest.cpp | |
parent | 9f2f3493f6185bb7d0c24c8ab451d5d012234edc (diff) |
PDF: Switch some unit tests to higher level API.
Also, clean up some headers.
Review URL: https://codereview.chromium.org/968683002
Diffstat (limited to 'tests/PDFPrimitivesTest.cpp')
-rw-r--r-- | tests/PDFPrimitivesTest.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index 97ad25e09a..7861ef0fe1 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -8,6 +8,7 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkData.h" +#include "SkDocument.h" #include "SkFlate.h" #include "SkImageEncoder.h" #include "SkMatrix.h" @@ -215,21 +216,16 @@ static void TestSubstitute(skiatest::Reporter* reporter) { // 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() { - SkISize pageSize = SkISize::Make(100, 100); - SkPDFCanon canon; - SkAutoTUnref<SkPDFDevice> dev(SkPDFDevice::Create(pageSize, 72.0f, &canon)); - SkCanvas c(dev); + SkDynamicMemoryWStream outStream; + SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream)); + SkCanvas* canvas = doc->beginPage(100.0f, 100.0f); SkPaint paint; paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); uint16_t glyphID = 65000; - c.drawText(&glyphID, 2, 0, 0, paint); + canvas->drawText(&glyphID, 2, 0, 0, paint); - SkPDFDocument doc; - doc.appendPage(dev); - - SkDynamicMemoryWStream stream; - doc.emitPDF(&stream); + doc->close(); } DEF_TEST(PDFPrimitives, reporter) { @@ -354,18 +350,18 @@ void DummyImageFilter::toString(SkString* str) const { // Check that PDF rendering of image filters successfully falls back to // CPU rasterization. DEF_TEST(PDFImageFilter, reporter) { - SkISize pageSize = SkISize::Make(100, 100); - SkPDFCanon canon; - SkAutoTUnref<SkPDFDevice> pdfDevice( - SkPDFDevice::Create(pageSize, 72.0f, &canon)); - SkCanvas canvas(pdfDevice.get()); + SkDynamicMemoryWStream stream; + SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream)); + SkCanvas* canvas = doc->beginPage(100.0f, 100.0f); + SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter()); // Filter just created; should be unvisited. REPORTER_ASSERT(reporter, !filter->visited()); SkPaint paint; paint.setImageFilter(filter.get()); - canvas.drawRect(SkRect::MakeWH(100, 100), paint); + canvas->drawRect(SkRect::MakeWH(100, 100), paint); + doc->close(); // Filter was used in rendering; should be visited. REPORTER_ASSERT(reporter, filter->visited()); |