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

Unified Diff: tests/WArrayTest.cpp

Issue 1953153004: SkAdvancedTypefaceMetrics: abstract out linked list (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-05-06 (Friday) 17:00:24 EDT 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkTypeface_win_dw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/WArrayTest.cpp
diff --git a/tests/WArrayTest.cpp b/tests/WArrayTest.cpp
index 40128fa2b4dd47c1e62c1a5dc5f0d8ce606928bf..55f2a10b01be5f340142b75377f573a11aec3997 100644
--- a/tests/WArrayTest.cpp
+++ b/tests/WArrayTest.cpp
@@ -10,8 +10,6 @@
// Include the implementation so we can make an appropriate template instance.
#include "SkAdvancedTypefaceMetrics.h"
-using namespace skia_advanced_typeface_metrics_utils;
-
// Negative values and zeros in a range plus trailing zeros.
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
static const int16_t data1[] = {-1, 0, -3, 4, 5, 6, 7, 0, 0, 0, 8, 0, 0, 0, 0};
@@ -98,34 +96,35 @@ static const char* expected14 = "0[1] 5[2]";
static const uint32_t subset14[] = {0, 5};
static const char* expectedSubset14 = "0[1] 5[2]";
-static SkString stringify_advance_data(SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>* data) {
+static SkString stringify_advance_data(const SkSinglyLinkedList<
+ SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>>& list) {
SkString result;
bool leadingSpace = false;
- while (data != nullptr) {
- if (leadingSpace) {
- result.append(" ");
- } else {
- leadingSpace = true;
- }
- switch(data->fType) {
- case SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>::kRun:
- result.appendf("%d %d %d", data->fStartId, data->fEndId, data->fAdvance[0]);
- break;
- case SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>::kRange:
- result.appendf("%d[", data->fStartId);
- for (int i = 0; i < data->fAdvance.count(); ++i) {
- if (i > 0) {
- result.append(" ");
- }
- result.appendf("%d", data->fAdvance[i]);
- }
- result.append("]");
- break;
- case SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>::kDefault:
- result.appendf("<Default=%d>", data->fAdvance[0]);
- break;
- }
- data = data->fNext.get();
+ for (const SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>& data : list) {
+ if (leadingSpace) {
+ result.append(" ");
+ } else {
+ leadingSpace = true;
+ }
+ switch (data.fType) {
+ case SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>::kRun:
+ result.appendf("%d %d %d", data.fStartId, data.fEndId,
+ data.fAdvance[0]);
+ break;
+ case SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>::kRange:
+ result.appendf("%d[", data.fStartId);
+ for (int i = 0; i < data.fAdvance.count(); ++i) {
+ if (i > 0) {
+ result.append(" ");
+ }
+ result.appendf("%d", data.fAdvance[i]);
+ }
+ result.append("]");
+ break;
+ case SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>::kDefault:
+ result.appendf("<Default=%d>", data.fAdvance[0]);
+ break;
+ }
}
return result;
}
@@ -161,10 +160,11 @@ class TestWData {
}
void runTest(skiatest::Reporter* reporter) {
- SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result;
- result.reset(getAdvanceData((void*)this, fAdvancesLen, fSubset, fSubsetLen, getAdvance));
+ SkAdvancedTypefaceMetrics metrics;
+ metrics.setGlyphWidths((void*)this, fAdvancesLen, fSubset, fSubsetLen,
+ getAdvance);
- SkString stringResult = stringify_advance_data(result);
+ SkString stringResult = stringify_advance_data(metrics.fGlyphWidths);
if (!stringResult.equals(fExpected)) {
ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringResult.c_str());
}
« 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