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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 template <typename T> | 76 template <typename T> |
77 static void assert_emit_eq(skiatest::Reporter* reporter, | 77 static void assert_emit_eq(skiatest::Reporter* reporter, |
78 T& object, | 78 T& object, |
79 const char* string) { | 79 const char* string) { |
80 SkString result = emit_to_string(object); | 80 SkString result = emit_to_string(object); |
81 assert_eq(reporter, result, string); | 81 assert_eq(reporter, result, string); |
82 } | 82 } |
83 | 83 |
84 static void TestPDFStream(skiatest::Reporter* reporter) { | 84 static void TestPDFStream(skiatest::Reporter* reporter) { |
85 char streamBytes[] = "Test\nFoo\tBar"; | 85 char streamBytes[] = "Test\nFoo\tBar"; |
86 SkAutoTDelete<SkMemoryStream> streamData(new SkMemoryStream( | 86 std::unique_ptr<SkStreamAsset> streamData(new SkMemoryStream( |
87 streamBytes, strlen(streamBytes), true)); | 87 streamBytes, strlen(streamBytes), true)); |
88 sk_sp<SkPDFStream> stream(new SkPDFStream(streamData.get())); | 88 auto stream = sk_make_sp<SkPDFStream>(std::move(streamData)); |
89 assert_emit_eq(reporter, | 89 assert_emit_eq(reporter, |
90 *stream, | 90 *stream, |
91 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); | 91 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); |
92 stream->insertInt("Attribute", 42); | 92 stream->insertInt("Attribute", 42); |
93 assert_emit_eq(reporter, | 93 assert_emit_eq(reporter, |
94 *stream, | 94 *stream, |
95 "<</Length 12\n/Attribute 42>> stream\n" | 95 "<</Length 12\n/Attribute 42>> stream\n" |
96 "Test\nFoo\tBar\nendstream"); | 96 "Test\nFoo\tBar\nendstream"); |
97 | 97 |
98 { | 98 { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 char buffer[5]; | 501 char buffer[5]; |
502 for (int i = 0; i < 256; ++i) { | 502 for (int i = 0; i < 256; ++i) { |
503 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); | 503 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); |
504 REPORTER_ASSERT(reporter, len == strlen(buffer)); | 504 REPORTER_ASSERT(reporter, len == strlen(buffer)); |
505 float f; | 505 float f; |
506 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); | 506 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); |
507 int roundTrip = (int)(0.5 + f * 255); | 507 int roundTrip = (int)(0.5 + f * 255); |
508 REPORTER_ASSERT(reporter, roundTrip == i); | 508 REPORTER_ASSERT(reporter, roundTrip == i); |
509 } | 509 } |
510 } | 510 } |
OLD | NEW |