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 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkMath.h" | 10 #include "SkMath.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 quadraticPointCount_EC(path, SkIntToScalar(1)); | 130 quadraticPointCount_EC(path, SkIntToScalar(1)); |
131 estimatedCount = | 131 estimatedCount = |
132 quadraticPointCount_CE(path); | 132 quadraticPointCount_CE(path); |
133 } | 133 } |
134 // Allow estimated to be high by a factor of two, but no less than | 134 // Allow estimated to be high by a factor of two, but no less than |
135 // the computed value. | 135 // the computed value. |
136 bool isAccurate = (estimatedCount >= computedCount) && | 136 bool isAccurate = (estimatedCount >= computedCount) && |
137 (estimatedCount <= 2 * computedCount); | 137 (estimatedCount <= 2 * computedCount); |
138 | 138 |
139 if (!isAccurate) { | 139 if (!isAccurate) { |
140 SkString errorDescription; | 140 ERRORF(reporter, "Curve from %.2f %.2f through %.2f %.2f to " |
141 errorDescription.printf( | 141 "%.2f %.2f computes %d, estimates %d\n", |
142 "Curve from %.2f %.2f through %.2f %.2f to %.2f %.2f " | 142 path[0].fX, path[0].fY, path[1].fX, path[1].fY, |
143 "computes %d, estimates %d\n", | 143 path[2].fX, path[2].fY, computedCount, estimatedCount); |
144 path[0].fX, path[0].fY, path[1].fX, path[1].fY, | |
145 path[2].fX, path[2].fY, computedCount, estimatedCount); | |
146 numErrors++; | 144 numErrors++; |
147 reporter->reportFailed(errorDescription); | |
148 } | 145 } |
149 } | 146 } |
150 | 147 |
151 return (numErrors == 0); | 148 return (numErrors == 0); |
152 } | 149 } |
153 | 150 |
154 | 151 |
155 | 152 |
156 static void TestQuadPointCount(skiatest::Reporter* reporter) { | 153 static void TestQuadPointCount(skiatest::Reporter* reporter) { |
157 one_d_pe(gXY, SK_ARRAY_COUNT(gXY), reporter); | 154 one_d_pe(gXY, SK_ARRAY_COUNT(gXY), reporter); |
158 one_d_pe(gSawtooth, SK_ARRAY_COUNT(gSawtooth), reporter); | 155 one_d_pe(gSawtooth, SK_ARRAY_COUNT(gSawtooth), reporter); |
159 one_d_pe(gOvalish, SK_ARRAY_COUNT(gOvalish), reporter); | 156 one_d_pe(gOvalish, SK_ARRAY_COUNT(gOvalish), reporter); |
160 one_d_pe(gSharpSawtooth, SK_ARRAY_COUNT(gSharpSawtooth), reporter); | 157 one_d_pe(gSharpSawtooth, SK_ARRAY_COUNT(gSharpSawtooth), reporter); |
161 one_d_pe(gRibbon, SK_ARRAY_COUNT(gRibbon), reporter); | 158 one_d_pe(gRibbon, SK_ARRAY_COUNT(gRibbon), reporter); |
162 } | 159 } |
163 | 160 |
164 DEF_TEST(PathCoverage, reporter) { | 161 DEF_TEST(PathCoverage, reporter) { |
165 TestQuadPointCount(reporter); | 162 TestQuadPointCount(reporter); |
166 | 163 |
167 } | 164 } |
OLD | NEW |