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

Side by Side Diff: tests/AnnotationTest.cpp

Issue 936403002: PDF: why do we have flags no one uses (or can use)? (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkAnnotation.h" 8 #include "SkAnnotation.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 21 matching lines...) Expand all
32 SkCanvas canvas(bm); 32 SkCanvas canvas(bm);
33 SkRect r = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10)); 33 SkRect r = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10));
34 34
35 SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com")); 35 SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com"));
36 36
37 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0)); 37 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0));
38 SkAnnotateRectWithURL(&canvas, r, data.get()); 38 SkAnnotateRectWithURL(&canvas, r, data.get());
39 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0)); 39 REPORTER_ASSERT(reporter, 0 == *bm.getAddr32(0, 0));
40 } 40 }
41 41
42 struct testCase {
43 SkPDFDocument::Flags flags;
44 bool expectAnnotations;
45 };
46
47 DEF_TEST(Annotation_PdfLink, reporter) { 42 DEF_TEST(Annotation_PdfLink, reporter) {
48 SkISize size = SkISize::Make(612, 792); 43 SkISize size = SkISize::Make(612, 792);
49 SkMatrix initialTransform; 44 SkMatrix initialTransform;
50 initialTransform.reset(); 45 initialTransform.reset();
51 SkPDFDevice device(size, size, initialTransform); 46 SkPDFDevice device(size, size, initialTransform);
52 SkCanvas canvas(&device); 47 SkCanvas canvas(&device);
53 48
54 SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72), 49 SkRect r = SkRect::MakeXYWH(SkIntToScalar(72), SkIntToScalar(72),
55 SkIntToScalar(288), SkIntToScalar(72)); 50 SkIntToScalar(288), SkIntToScalar(72));
56 SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com")); 51 SkAutoDataUnref data(SkData::NewWithCString("http://www.gooogle.com"));
57 SkAnnotateRectWithURL(&canvas, r, data.get()); 52 SkAnnotateRectWithURL(&canvas, r, data.get());
58 53
59 testCase tests[] = {{(SkPDFDocument::Flags)0, true}, 54 SkPDFDocument doc;
60 {SkPDFDocument::kNoLinks_Flags, false}}; 55 doc.appendPage(&device);
61 for (size_t testNum = 0; testNum < SK_ARRAY_COUNT(tests); testNum++) { 56 SkDynamicMemoryWStream outStream;
62 SkPDFDocument doc(tests[testNum].flags); 57 doc.emitPDF(&outStream);
63 doc.appendPage(&device); 58 SkAutoDataUnref out(outStream.copyToData());
64 SkDynamicMemoryWStream outStream; 59 const char* rawOutput = (const char*)out->data();
65 doc.emitPDF(&outStream);
66 SkAutoDataUnref out(outStream.copyToData());
67 const char* rawOutput = (const char*)out->data();
68 60
69 REPORTER_ASSERT(reporter, 61 REPORTER_ASSERT(reporter, ContainsString(rawOutput, out->size(), "/Annots ") );
70 ContainsString(rawOutput, out->size(), "/Annots ")
71 == tests[testNum].expectAnnotations);
72 }
73 } 62 }
74 63
75 DEF_TEST(Annotation_NamedDestination, reporter) { 64 DEF_TEST(Annotation_NamedDestination, reporter) {
76 SkISize size = SkISize::Make(612, 792); 65 SkISize size = SkISize::Make(612, 792);
77 SkMatrix initialTransform; 66 SkMatrix initialTransform;
78 initialTransform.reset(); 67 initialTransform.reset();
79 SkPDFDevice device(size, size, initialTransform); 68 SkPDFDevice device(size, size, initialTransform);
80 SkCanvas canvas(&device); 69 SkCanvas canvas(&device);
81 70
82 SkPoint p = SkPoint::Make(SkIntToScalar(72), SkIntToScalar(72)); 71 SkPoint p = SkPoint::Make(SkIntToScalar(72), SkIntToScalar(72));
83 SkAutoDataUnref data(SkData::NewWithCString("example")); 72 SkAutoDataUnref data(SkData::NewWithCString("example"));
84 SkAnnotateNamedDestination(&canvas, p, data.get()); 73 SkAnnotateNamedDestination(&canvas, p, data.get());
85 74
86 SkPDFDocument doc; 75 SkPDFDocument doc;
87 doc.appendPage(&device); 76 doc.appendPage(&device);
88 SkDynamicMemoryWStream outStream; 77 SkDynamicMemoryWStream outStream;
89 doc.emitPDF(&outStream); 78 doc.emitPDF(&outStream);
90 SkAutoDataUnref out(outStream.copyToData()); 79 SkAutoDataUnref out(outStream.copyToData());
91 const char* rawOutput = (const char*)out->data(); 80 const char* rawOutput = (const char*)out->data();
92 81
93 REPORTER_ASSERT(reporter, 82 REPORTER_ASSERT(reporter,
94 ContainsString(rawOutput, out->size(), "/example ")); 83 ContainsString(rawOutput, out->size(), "/example "));
95 } 84 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698