Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: tests/PDFPrimitivesTest.cpp

Issue 968683002: PDF: Switch some unit tests to higher level API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/CanvasTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PDFPrimitivesTest.cpp
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 97ad25e09a167f48276f9cabd3a633d2bb787c04..7861ef0fe145dc7e7359ce5d4361150283fa8aec 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());
« no previous file with comments | « tests/CanvasTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698