OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
11 #include "SkData.h" | 10 #include "SkData.h" |
12 #include "SkPDFTypes.h" | 11 #include "SkPDFTypes.h" |
13 #include "SkPDFFont.h" | 12 #include "SkPDFFont.h" |
14 #include "SkStream.h" | 13 #include "SkStream.h" |
15 | 14 |
16 static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, | 15 static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, |
17 const char* buffer, size_t len) { | 16 const char* buffer, size_t len) { |
18 SkAutoDataUnref data(stream.copyToData()); | 17 SkAutoDataUnref data(stream.copyToData()); |
19 if (offset + len > data->size()) { | 18 if (offset + len > data->size()) { |
20 return false; | 19 return false; |
21 } | 20 } |
22 if (len != strlen(buffer)) { | 21 if (len != strlen(buffer)) { |
23 return false; | 22 return false; |
24 } | 23 } |
25 return memcmp(data->bytes() + offset, buffer, len) == 0; | 24 return memcmp(data->bytes() + offset, buffer, len) == 0; |
26 } | 25 } |
27 | 26 |
28 void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, | 27 void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, |
29 const SkPDFGlyphSet* subset, | 28 const SkPDFGlyphSet* subset, |
30 SkDynamicMemoryWStream* cmap, | 29 SkDynamicMemoryWStream* cmap, |
31 bool multiByteGlyphs, | 30 bool multiByteGlyphs, |
32 uint16_t firstGlypthID, | 31 uint16_t firstGlypthID, |
33 uint16_t lastGlypthID); | 32 uint16_t lastGlypthID); |
34 | 33 |
35 static void TestToUnicode(skiatest::Reporter* reporter) { | 34 DEF_TEST(ToUnicode, reporter) { |
36 SkTDArray<SkUnichar> glyphToUnicode; | 35 SkTDArray<SkUnichar> glyphToUnicode; |
37 SkTDArray<uint16_t> glyphsInSubset; | 36 SkTDArray<uint16_t> glyphsInSubset; |
38 SkPDFGlyphSet subset; | 37 SkPDFGlyphSet subset; |
39 | 38 |
40 glyphToUnicode.push(0); // 0 | 39 glyphToUnicode.push(0); // 0 |
41 glyphToUnicode.push(0); // 1 | 40 glyphToUnicode.push(0); // 1 |
42 glyphToUnicode.push(0); // 2 | 41 glyphToUnicode.push(0); // 2 |
43 glyphsInSubset.push(3); | 42 glyphsInSubset.push(3); |
44 glyphToUnicode.push(0x20); // 3 | 43 glyphToUnicode.push(0x20); // 3 |
45 glyphsInSubset.push(4); | 44 glyphsInSubset.push(4); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 <004F> <006C>\n\ | 172 <004F> <006C>\n\ |
174 <0051> <006E>\n\ | 173 <0051> <006E>\n\ |
175 endbfchar\n\ | 174 endbfchar\n\ |
176 1 beginbfrange\n\ | 175 1 beginbfrange\n\ |
177 <0056> <0057> <0073>\n\ | 176 <0056> <0057> <0073>\n\ |
178 endbfrange\n"; | 177 endbfrange\n"; |
179 | 178 |
180 REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2, | 179 REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2, |
181 buffer2.getOffset())); | 180 buffer2.getOffset())); |
182 } | 181 } |
183 | |
184 #include "TestClassDef.h" | |
185 DEFINE_TESTCLASS("ToUnicode", ToUnicodeTestClass, TestToUnicode) | |
OLD | NEW |