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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 SkDynamicMemoryWStream compressedByteStream; | 105 SkDynamicMemoryWStream compressedByteStream; |
106 SkDeflateWStream deflateWStream(&compressedByteStream); | 106 SkDeflateWStream deflateWStream(&compressedByteStream); |
107 deflateWStream.write(streamBytes2, strlen(streamBytes2)); | 107 deflateWStream.write(streamBytes2, strlen(streamBytes2)); |
108 deflateWStream.finalize(); | 108 deflateWStream.finalize(); |
109 | 109 |
110 SkDynamicMemoryWStream expected; | 110 SkDynamicMemoryWStream expected; |
111 expected.writeText("<</Filter /FlateDecode\n/Length 116>> stream\n"); | 111 expected.writeText("<</Filter /FlateDecode\n/Length 116>> stream\n"); |
112 compressedByteStream.writeToStream(&expected); | 112 compressedByteStream.writeToStream(&expected); |
113 compressedByteStream.reset(); | 113 compressedByteStream.reset(); |
114 expected.writeText("\nendstream"); | 114 expected.writeText("\nendstream"); |
115 SkAutoDataUnref expectedResultData2(expected.copyToData()); | 115 sk_sp<SkData> expectedResultData2(expected.copyToData()); |
116 SkString result = emit_to_string(*stream); | 116 SkString result = emit_to_string(*stream); |
117 assert_eql(reporter, | 117 assert_eql(reporter, |
118 result, | 118 result, |
119 (const char*)expectedResultData2->data(), | 119 (const char*)expectedResultData2->data(), |
120 expectedResultData2->size()); | 120 expectedResultData2->size()); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 static void TestObjectNumberMap(skiatest::Reporter* reporter) { | 124 static void TestObjectNumberMap(skiatest::Reporter* reporter) { |
125 SkPDFObjNumMap objNumMap; | 125 SkPDFObjNumMap objNumMap; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 char buffer[5]; | 499 char buffer[5]; |
500 for (int i = 0; i < 256; ++i) { | 500 for (int i = 0; i < 256; ++i) { |
501 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); | 501 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); |
502 REPORTER_ASSERT(reporter, len == strlen(buffer)); | 502 REPORTER_ASSERT(reporter, len == strlen(buffer)); |
503 float f; | 503 float f; |
504 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); | 504 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); |
505 int roundTrip = (int)(0.5 + f * 255); | 505 int roundTrip = (int)(0.5 + f * 255); |
506 REPORTER_ASSERT(reporter, roundTrip == i); | 506 REPORTER_ASSERT(reporter, roundTrip == i); |
507 } | 507 } |
508 } | 508 } |
OLD | NEW |