| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 public: | 134 public: |
| 135 TestWData(skiatest::Reporter* reporter, | 135 TestWData(skiatest::Reporter* reporter, |
| 136 const int16_t advances[], int advanceLen, | 136 const int16_t advances[], int advanceLen, |
| 137 const uint32_t subset[], int subsetLen, | 137 const uint32_t subset[], int subsetLen, |
| 138 const char* expected) | 138 const char* expected) |
| 139 : fAdvances(advances) | 139 : fAdvances(advances) |
| 140 , fAdvancesLen(advanceLen) | 140 , fAdvancesLen(advanceLen) |
| 141 , fSubset(subset) | 141 , fSubset(subset) |
| 142 , fSubsetLen(subsetLen) | 142 , fSubsetLen(subsetLen) |
| 143 , fExpected(expected) { | 143 , fExpected(expected) { |
| 144 REPORTER_ASSERT(reporter, RunTest()); | 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) { | 154 static bool getAdvance(void* tc, int gId, int16_t* advance) { |
| 155 TestWData* testCase = (TestWData*)tc; | 155 TestWData* testCase = (TestWData*)tc; |
| 156 if (gId >= 0 && gId < testCase->fAdvancesLen) { | 156 if (gId >= 0 && gId < testCase->fAdvancesLen) { |
| 157 *advance = testCase->fAdvances[gId]; | 157 *advance = testCase->fAdvances[gId]; |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 return false; | 160 return false; |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool RunTest() { | 163 void runTest(skiatest::Reporter* reporter) { |
| 164 SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result
; | 164 SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result
; |
| 165 result.reset(getAdvanceData((void*)this, fAdvancesLen, fSubset, fSubsetL
en, getAdvance)); | 165 result.reset(getAdvanceData((void*)this, fAdvancesLen, fSubset, fSubsetL
en, getAdvance)); |
| 166 | 166 |
| 167 SkString stringResult = stringify_advance_data(result); | 167 SkString stringResult = stringify_advance_data(result); |
| 168 if (!stringResult.equals(fExpected)) { | 168 if (!stringResult.equals(fExpected)) { |
| 169 SkDebugf("Expected: %s\n Result: %s\n", fExpected, stringResult.c_s
tr()); | 169 ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringRe
sult.c_str()); |
| 170 return false; | |
| 171 } | 170 } |
| 172 return true; | |
| 173 } | 171 } |
| 174 }; | 172 }; |
| 175 | 173 |
| 176 DEF_TEST(WArray, reporter) { | 174 DEF_TEST(WArray, reporter) { |
| 177 TestWData(reporter, data1, SK_ARRAY_COUNT(data1), nullptr, 0, expected1); | 175 TestWData(reporter, data1, SK_ARRAY_COUNT(data1), nullptr, 0, expected1); |
| 178 TestWData(reporter, data2, SK_ARRAY_COUNT(data2), nullptr, 0, expected2); | 176 TestWData(reporter, data2, SK_ARRAY_COUNT(data2), nullptr, 0, expected2); |
| 179 TestWData(reporter, data3, SK_ARRAY_COUNT(data3), nullptr, 0, expected3); | 177 TestWData(reporter, data3, SK_ARRAY_COUNT(data3), nullptr, 0, expected3); |
| 180 TestWData(reporter, data4, SK_ARRAY_COUNT(data4), nullptr, 0, expected4); | 178 TestWData(reporter, data4, SK_ARRAY_COUNT(data4), nullptr, 0, expected4); |
| 181 TestWData(reporter, data5, SK_ARRAY_COUNT(data5), nullptr, 0, expected5); | 179 TestWData(reporter, data5, SK_ARRAY_COUNT(data5), nullptr, 0, expected5); |
| 182 TestWData(reporter, data6, SK_ARRAY_COUNT(data6), nullptr, 0, expected6); | 180 TestWData(reporter, data6, SK_ARRAY_COUNT(data6), nullptr, 0, expected6); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 198 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), nullptr, 0, expected12); | 196 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), nullptr, 0, expected12); |
| 199 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), subset12, | 197 TestWData(reporter, data12, SK_ARRAY_COUNT(data12), subset12, |
| 200 SK_ARRAY_COUNT(subset12), expectedSubset12); | 198 SK_ARRAY_COUNT(subset12), expectedSubset12); |
| 201 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), nullptr, 0, expected13); | 199 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), nullptr, 0, expected13); |
| 202 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), subset13, | 200 TestWData(reporter, data13, SK_ARRAY_COUNT(data13), subset13, |
| 203 SK_ARRAY_COUNT(subset13), expectedSubset13); | 201 SK_ARRAY_COUNT(subset13), expectedSubset13); |
| 204 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), nullptr, 0, expected14); | 202 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), nullptr, 0, expected14); |
| 205 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), subset14, | 203 TestWData(reporter, data14, SK_ARRAY_COUNT(data14), subset14, |
| 206 SK_ARRAY_COUNT(subset14), expectedSubset14); | 204 SK_ARRAY_COUNT(subset14), expectedSubset14); |
| 207 } | 205 } |
| OLD | NEW |