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

Side by Side Diff: tests/AnnotationTest.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkAnnotation.h" 7 #include "SkAnnotation.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDocument.h" 10 #include "SkDocument.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 DEF_TEST(Annotation_NoDraw, reporter) { 26 DEF_TEST(Annotation_NoDraw, reporter) {
27 SkBitmap bm; 27 SkBitmap bm;
28 bm.allocN32Pixels(10, 10); 28 bm.allocN32Pixels(10, 10);
29 bm.eraseColor(SK_ColorTRANSPARENT); 29 bm.eraseColor(SK_ColorTRANSPARENT);
30 30
31 SkCanvas canvas(bm); 31 SkCanvas canvas(bm);
32 SkRect r = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10)); 32 SkRect r = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10));
33 33
34 SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com")); 34 sk_sp<SkData> data(SkData::MakeWithCString("http://www.gooogle.com"));
35 35
36 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0)); 36 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0));
37 SkAnnotateRectWithURL(&canvas, r, data.get()); 37 SkAnnotateRectWithURL(&canvas, r, data.get());
38 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0)); 38 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0));
39 } 39 }
40 40
41 DEF_TEST(Annotation_PdfLink, reporter) { 41 DEF_TEST(Annotation_PdfLink, reporter) {
42 REQUIRE_PDF_DOCUMENT(Annotation_PdfLink, reporter); 42 REQUIRE_PDF_DOCUMENT(Annotation_PdfLink, reporter);
43 SkDynamicMemoryWStream outStream; 43 SkDynamicMemoryWStream outStream;
44 sk_sp<SkDocument> doc(SkDocument::MakePDF(&outStream)); 44 sk_sp<SkDocument> doc(SkDocument::MakePDF(&outStream));
45 SkCanvas* canvas = doc->beginPage(612.0f, 792.0f); 45 SkCanvas* canvas = doc->beginPage(612.0f, 792.0f);
46 REPORTER_ASSERT(reporter, canvas); 46 REPORTER_ASSERT(reporter, canvas);
47 47
48 SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72), 48 SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72),
49 SkIntToScalar(288), SkIntToScalar(72)); 49 SkIntToScalar(288), SkIntToScalar(72));
50 SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com")); 50 sk_sp<SkData> data(SkData::MakeWithCString("http://www.gooogle.com"));
51 SkAnnotateRectWithURL(canvas, r, data.get()); 51 SkAnnotateRectWithURL(canvas, r, data.get());
52 52
53 REPORTER_ASSERT(reporter, doc->close()); 53 REPORTER_ASSERT(reporter, doc->close());
54 SkAutoDataUnref out(outStream.copyToData()); 54 sk_sp<SkData> out(outStream.copyToData());
55 const char* rawOutput = (const char*)out->data(); 55 const char* rawOutput = (const char*)out->data();
56 56
57 REPORTER_ASSERT(reporter, ContainsString(rawOutput, out->size(), "/Annots ") ); 57 REPORTER_ASSERT(reporter, ContainsString(rawOutput, out->size(), "/Annots ") );
58 } 58 }
59 59
60 DEF_TEST(Annotation_NamedDestination, reporter) { 60 DEF_TEST(Annotation_NamedDestination, reporter) {
61 REQUIRE_PDF_DOCUMENT(Annotation_NamedDestination, reporter); 61 REQUIRE_PDF_DOCUMENT(Annotation_NamedDestination, reporter);
62 SkDynamicMemoryWStream outStream; 62 SkDynamicMemoryWStream outStream;
63 sk_sp<SkDocument> doc(SkDocument::MakePDF(&outStream)); 63 sk_sp<SkDocument> doc(SkDocument::MakePDF(&outStream));
64 SkCanvas* canvas = doc->beginPage(612.0f, 792.0f); 64 SkCanvas* canvas = doc->beginPage(612.0f, 792.0f);
65 REPORTER_ASSERT(reporter, canvas); 65 REPORTER_ASSERT(reporter, canvas);
66 66
67 SkPoint p = SkPoint::Make(SkIntToScalar(72), SkIntToScalar(72)); 67 SkPoint p = SkPoint::Make(SkIntToScalar(72), SkIntToScalar(72));
68 SkAutoDataUnref data(SkData::NewWithCString("example")); 68 sk_sp<SkData> data(SkData::MakeWithCString("example"));
69 SkAnnotateNamedDestination(canvas, p, data.get()); 69 SkAnnotateNamedDestination(canvas, p, data.get());
70 70
71 REPORTER_ASSERT(reporter, doc->close()); 71 REPORTER_ASSERT(reporter, doc->close());
72 SkAutoDataUnref out(outStream.copyToData()); 72 sk_sp<SkData> out(outStream.copyToData());
73 const char* rawOutput = (const char*)out->data(); 73 const char* rawOutput = (const char*)out->data();
74 74
75 REPORTER_ASSERT(reporter, 75 REPORTER_ASSERT(reporter,
76 ContainsString(rawOutput, out->size(), "/example ")); 76 ContainsString(rawOutput, out->size(), "/example "));
77 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698