OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
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 | 7 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 const char* expectedData, size_t expectedSize, | 62 const char* expectedData, size_t expectedSize, |
63 bool indirect) { | 63 bool indirect) { |
64 SkPDFSubstituteMap substituteMap; | 64 SkPDFSubstituteMap substituteMap; |
65 SkPDFObjNumMap catalog; | 65 SkPDFObjNumMap catalog; |
66 size_t directSize = get_output_size(obj, catalog, substituteMap, false); | 66 size_t directSize = get_output_size(obj, catalog, substituteMap, false); |
67 REPORTER_ASSERT(reporter, directSize == expectedSize); | 67 REPORTER_ASSERT(reporter, directSize == expectedSize); |
68 | 68 |
69 SkDynamicMemoryWStream buffer; | 69 SkDynamicMemoryWStream buffer; |
70 emit_object(obj, &buffer, catalog, substituteMap, false); | 70 emit_object(obj, &buffer, catalog, substituteMap, false); |
71 REPORTER_ASSERT(reporter, directSize == buffer.getOffset()); | 71 REPORTER_ASSERT(reporter, directSize == buffer.getOffset()); |
72 REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedData, | 72 if (!stream_equals(buffer, 0, expectedData, directSize)) { |
73 directSize)); | 73 SkAutoTDelete<SkStreamAsset> asset(buffer.detachAsStream()); |
| 74 SkString s(asset->getLength()); |
| 75 asset->read(s.writable_str(), s.size()); |
| 76 ERRORF(reporter, "!stream_equals() '%s' '%s'", expectedData, s.c_str()); |
| 77 } |
74 | 78 |
75 if (indirect) { | 79 if (indirect) { |
76 // Indirect output. | 80 // Indirect output. |
77 static char header[] = "1 0 obj\n"; | 81 static char header[] = "1 0 obj\n"; |
78 static size_t headerLen = strlen(header); | 82 static size_t headerLen = strlen(header); |
79 static char footer[] = "\nendobj\n"; | 83 static char footer[] = "\nendobj\n"; |
80 static size_t footerLen = strlen(footer); | 84 static size_t footerLen = strlen(footer); |
81 | 85 |
82 catalog.addObject(obj); | 86 catalog.addObject(obj); |
83 | 87 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 array->append(int42.get()); | 269 array->append(int42.get()); |
266 SimpleCheckObjectOutput(reporter, array.get(), "[42]"); | 270 SimpleCheckObjectOutput(reporter, array.get(), "[42]"); |
267 array->append(realHalf.get()); | 271 array->append(realHalf.get()); |
268 SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5]"); | 272 SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5]"); |
269 SkAutoTUnref<SkPDFInt> int0(new SkPDFInt(0)); | 273 SkAutoTUnref<SkPDFInt> int0(new SkPDFInt(0)); |
270 array->append(int0.get()); | 274 array->append(int0.get()); |
271 SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5 0]"); | 275 SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5 0]"); |
272 | 276 |
273 SkAutoTUnref<SkPDFDict> dict(new SkPDFDict); | 277 SkAutoTUnref<SkPDFDict> dict(new SkPDFDict); |
274 SimpleCheckObjectOutput(reporter, dict.get(), "<<>>"); | 278 SimpleCheckObjectOutput(reporter, dict.get(), "<<>>"); |
275 SkAutoTUnref<SkPDFName> n1(new SkPDFName("n1")); | 279 dict->insert("n1", int42.get()); |
276 dict->insert(n1.get(), int42.get()); | |
277 SimpleCheckObjectOutput(reporter, dict.get(), "<</n1 42>>"); | 280 SimpleCheckObjectOutput(reporter, dict.get(), "<</n1 42>>"); |
278 SkAutoTUnref<SkPDFName> n2(new SkPDFName("n2")); | 281 SkString n3("n3"); |
279 SkAutoTUnref<SkPDFName> n3(new SkPDFName("n3")); | 282 dict->insert("n2", realHalf.get()); |
280 dict->insert(n2.get(), realHalf.get()); | 283 dict->insertObject(n3, array.detach()); |
281 dict->insert(n3.get(), array.get()); | |
282 SimpleCheckObjectOutput(reporter, dict.get(), | 284 SimpleCheckObjectOutput(reporter, dict.get(), |
283 "<</n1 42\n/n2 0.5\n/n3 [42 0.5 0]>>"); | 285 "<</n1 42\n/n2 0.5\n/n3 [42 0.5 0]>>"); |
284 | 286 |
285 TestPDFStream(reporter); | 287 TestPDFStream(reporter); |
286 | 288 |
287 TestCatalog(reporter); | 289 TestCatalog(reporter); |
288 | 290 |
289 TestObjectRef(reporter); | 291 TestObjectRef(reporter); |
290 | 292 |
291 TestSubstitute(reporter); | 293 TestSubstitute(reporter); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // Filter just created; should be unvisited. | 343 // Filter just created; should be unvisited. |
342 REPORTER_ASSERT(reporter, !filter->visited()); | 344 REPORTER_ASSERT(reporter, !filter->visited()); |
343 SkPaint paint; | 345 SkPaint paint; |
344 paint.setImageFilter(filter.get()); | 346 paint.setImageFilter(filter.get()); |
345 canvas->drawRect(SkRect::MakeWH(100, 100), paint); | 347 canvas->drawRect(SkRect::MakeWH(100, 100), paint); |
346 doc->close(); | 348 doc->close(); |
347 | 349 |
348 // Filter was used in rendering; should be visited. | 350 // Filter was used in rendering; should be visited. |
349 REPORTER_ASSERT(reporter, filter->visited()); | 351 REPORTER_ASSERT(reporter, filter->visited()); |
350 } | 352 } |
OLD | NEW |