OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 sk_sp<SkData> data(SkData::MakeWithCString("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 doc->close(); |
54 sk_sp<SkData> out = outStream.detachAsData(); | 54 sk_sp<SkData> out = outStream.detachAsData(); |
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 sk_sp<SkData> data(SkData::MakeWithCString("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 doc->close(); |
72 sk_sp<SkData> out = outStream.detachAsData(); | 72 sk_sp<SkData> out = outStream.detachAsData(); |
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 } |
OLD | NEW |