| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 this->runTest(reporter); | 144 this->runTest(reporter); |
| 145 } | 145 } |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 const int16_t* fAdvances; | 148 const int16_t* fAdvances; |
| 149 const int fAdvancesLen; | 149 const int fAdvancesLen; |
| 150 const uint32_t* fSubset; | 150 const uint32_t* fSubset; |
| 151 const int fSubsetLen; | 151 const int fSubsetLen; |
| 152 const char* fExpected; | 152 const char* fExpected; |
| 153 | 153 |
| 154 static bool getAdvance(void* tc, int gId, int16_t* advance) { | |
| 155 TestWData* testCase = (TestWData*)tc; | |
| 156 if (gId >= 0 && gId < testCase->fAdvancesLen) { | |
| 157 *advance = testCase->fAdvances[gId]; | |
| 158 return true; | |
| 159 } | |
| 160 return false; | |
| 161 } | |
| 162 | |
| 163 void runTest(skiatest::Reporter* reporter) { | 154 void runTest(skiatest::Reporter* reporter) { |
| 164 SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result
; | 155 SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result
; |
| 165 result.reset(getAdvanceData((void*)this, fAdvancesLen, fSubset, fSubsetL
en, getAdvance)); | 156 std::function<bool(int gId, int16_t* data)> getWidthAdvanceFn = |
| 157 [this](int gId, int16_t* advance) { |
| 158 if (gId >= 0 && gId < fAdvancesLen) { |
| 159 *advance = fAdvances[gId]; |
| 160 return true; |
| 161 } |
| 162 return false; |
| 163 }; |
| 164 result.reset(getAdvanceData(fAdvancesLen, fSubset, fSubsetLen, getWidthA
dvanceFn)); |
| 166 | 165 |
| 167 SkString stringResult = stringify_advance_data(result); | 166 SkString stringResult = stringify_advance_data(result); |
| 168 if (!stringResult.equals(fExpected)) { | 167 if (!stringResult.equals(fExpected)) { |
| 169 ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringRe
sult.c_str()); | 168 ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringRe
sult.c_str()); |
| 170 } | 169 } |
| 171 } | 170 } |
| 172 }; | 171 }; |
| 173 | 172 |
| 174 DEF_TEST(WArray, reporter) { | 173 DEF_TEST(WArray, reporter) { |
| 175 TestWData(reporter, data1, SK_ARRAY_COUNT(data1), nullptr, 0, expected1); | 174 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); | 195 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), nullptr, 0, expected12); |
| 197 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), subset12, | 196 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), subset12, |
| 198 SK_ARRAY_COUNT(subset12), expectedSubset12); | 197 SK_ARRAY_COUNT(subset12), expectedSubset12); |
| 199 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), nullptr, 0, expected13); | 198 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), nullptr, 0, expected13); |
| 200 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), subset13, | 199 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), subset13, |
| 201 SK_ARRAY_COUNT(subset13), expectedSubset13); | 200 SK_ARRAY_COUNT(subset13), expectedSubset13); |
| 202 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), nullptr, 0, expected14); | 201 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), nullptr, 0, expected14); |
| 203 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), subset14, | 202 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), subset14, |
| 204 SK_ARRAY_COUNT(subset14), expectedSubset14); | 203 SK_ARRAY_COUNT(subset14), expectedSubset14); |
| 205 } | 204 } |
| OLD | NEW |