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

Unified Diff: tests/AnnotationTest.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 | « src/pdf/SkPDFCatalog.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/AnnotationTest.cpp
diff --git a/tests/AnnotationTest.cpp b/tests/AnnotationTest.cpp
index fc762b1493d65eb648884efdaf296ba48009c990..7a1ca97a5543471bdef74c97541c250fb3ec7c45 100644
--- a/tests/AnnotationTest.cpp
+++ b/tests/AnnotationTest.cpp
@@ -8,9 +8,8 @@
#include "SkAnnotation.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkPDFCanon.h"
-#include "SkPDFDevice.h"
-#include "SkPDFDocument.h"
+#include "SkDocument.h"
+#include "SkStream.h"
#include "Test.h"
/** Returns true if data (may contain null characters) contains needle (null
@@ -41,20 +40,17 @@ DEF_TEST(Annotation_NoDraw, reporter) {
}
DEF_TEST(Annotation_PdfLink, reporter) {
- SkISize size = SkISize::Make(612, 792);
- SkPDFCanon canon;
- SkAutoTUnref<SkPDFDevice> device(SkPDFDevice::Create(size, 72.0f, &canon));
- SkCanvas canvas(device.get());
+ SkDynamicMemoryWStream outStream;
+ SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream));
+ SkCanvas* canvas = doc->beginPage(612.0f, 792.0f);
+ REPORTER_ASSERT(reporter, canvas);
SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72),
SkIntToScalar(288), SkIntToScalar(72));
SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com"));
- SkAnnotateRectWithURL(&canvas, r, data.get());
+ SkAnnotateRectWithURL(canvas, r, data.get());
- SkPDFDocument doc;
- doc.appendPage(device.get());
- SkDynamicMemoryWStream outStream;
- doc.emitPDF(&outStream);
+ REPORTER_ASSERT(reporter, doc->close());
SkAutoDataUnref out(outStream.copyToData());
const char* rawOutput = (const char*)out->data();
@@ -62,19 +58,16 @@ DEF_TEST(Annotation_PdfLink, reporter) {
}
DEF_TEST(Annotation_NamedDestination, reporter) {
- SkISize size = SkISize::Make(612, 792);
- SkPDFCanon canon;
- SkAutoTUnref<SkPDFDevice> device(SkPDFDevice::Create(size, 72.0f, &canon));
- SkCanvas canvas(device.get());
+ SkDynamicMemoryWStream outStream;
+ SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream));
+ SkCanvas* canvas = doc->beginPage(612.0f, 792.0f);
+ REPORTER_ASSERT(reporter, canvas);
SkPoint p = SkPoint::Make(SkIntToScalar(72), SkIntToScalar(72));
SkAutoDataUnref data(SkData::NewWithCString("example"));
- SkAnnotateNamedDestination(&canvas, p, data.get());
+ SkAnnotateNamedDestination(canvas, p, data.get());
- SkPDFDocument doc;
- doc.appendPage(device.get());
- SkDynamicMemoryWStream outStream;
- doc.emitPDF(&outStream);
+ REPORTER_ASSERT(reporter, doc->close());
SkAutoDataUnref out(outStream.copyToData());
const char* rawOutput = (const char*)out->data();
« no previous file with comments | « src/pdf/SkPDFCatalog.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698