Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: tests/WArrayTest.cpp

Issue 1955053002: SkAdvancedTypefaceMetrics: getAdvanceData uses std::function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typedef Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkTypeface_win_dw.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/ports/SkTypeface_win_dw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698