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 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 // Include the implementation so we can make an appropriate template instance. | 10 // Include the implementation so we can make an appropriate template instance. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 this->runTest(reporter); | 143 this->runTest(reporter); |
144 } | 144 } |
145 | 145 |
146 private: | 146 private: |
147 const int16_t* fAdvances; | 147 const int16_t* fAdvances; |
148 const int fAdvancesLen; | 148 const int fAdvancesLen; |
149 const uint32_t* fSubset; | 149 const uint32_t* fSubset; |
150 const int fSubsetLen; | 150 const int fSubsetLen; |
151 const char* fExpected; | 151 const char* fExpected; |
152 | 152 |
153 static bool getAdvance(void* tc, int gId, int16_t* advance) { | |
154 TestWData* testCase = (TestWData*)tc; | |
155 if (gId >= 0 && gId < testCase->fAdvancesLen) { | |
156 *advance = testCase->fAdvances[gId]; | |
157 return true; | |
158 } | |
159 return false; | |
160 } | |
161 | |
162 void runTest(skiatest::Reporter* reporter) { | 153 void runTest(skiatest::Reporter* reporter) { |
163 SkAdvancedTypefaceMetrics metrics; | 154 SkAdvancedTypefaceMetrics metrics; |
164 metrics.setGlyphWidths((void*)this, fAdvancesLen, fSubset, fSubsetLen, | 155 metrics.setGlyphWidths( |
165 getAdvance); | 156 fAdvancesLen, fSubset, fSubsetLen, |
| 157 std::function<bool(int, int16_t*)>([this](int gId, int16_t* adva
nce) { |
| 158 if (gId >= 0 && gId < fAdvancesLen) { |
| 159 *advance = fAdvances[gId]; |
| 160 return true; |
| 161 } |
| 162 return false; |
| 163 })); |
166 | 164 |
167 SkString stringResult = stringify_advance_data(metrics.fGlyphWidths); | 165 SkString stringResult = stringify_advance_data(metrics.fGlyphWidths); |
168 if (!stringResult.equals(fExpected)) { | 166 if (!stringResult.equals(fExpected)) { |
169 ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringRe
sult.c_str()); | 167 ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringRe
sult.c_str()); |
170 } | 168 } |
171 } | 169 } |
172 }; | 170 }; |
173 | 171 |
174 DEF_TEST(WArray, reporter) { | 172 DEF_TEST(WArray, reporter) { |
175 TestWData(reporter, data1, SK_ARRAY_COUNT(data1), nullptr, 0, expected1); | 173 TestWData(reporter, data1, SK_ARRAY_COUNT(data1), nullptr, 0, expected1); |
(...skipping 20 matching lines...) Expand all Loading... |
196 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), nullptr, 0, expected12); | 194 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), nullptr, 0, expected12); |
197 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), subset12, | 195 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), subset12, |
198 SK_ARRAY_COUNT(subset12), expectedSubset12); | 196 SK_ARRAY_COUNT(subset12), expectedSubset12); |
199 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), nullptr, 0, expected13); | 197 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), nullptr, 0, expected13); |
200 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), subset13, | 198 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), subset13, |
201 SK_ARRAY_COUNT(subset13), expectedSubset13); | 199 SK_ARRAY_COUNT(subset13), expectedSubset13); |
202 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), nullptr, 0, expected14); | 200 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), nullptr, 0, expected14); |
203 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), subset14, | 201 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), subset14, |
204 SK_ARRAY_COUNT(subset14), expectedSubset14); | 202 SK_ARRAY_COUNT(subset14), expectedSubset14); |
205 } | 203 } |
OLD | NEW |