OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" |
10 #include "Test.h" | 10 #include "Test.h" |
| 11 #include "TestClassDef.h" |
11 | 12 |
12 // FIXME: add tests for intersecting, non-intersecting, degenerate, coincident | 13 // FIXME: add tests for intersecting, non-intersecting, degenerate, coincident |
13 static const SkDLine tests[][2] = { | 14 static const SkDLine tests[][2] = { |
14 {{{{30,20}, {30,50}}}, {{{24,30}, {36,30}}}}, | 15 {{{{30,20}, {30,50}}}, {{{24,30}, {36,30}}}}, |
15 {{{{323,193}, {-317,193}}}, {{{0,994}, {0,0}}}}, | 16 {{{{323,193}, {-317,193}}}, {{{0,994}, {0,0}}}}, |
16 {{{{90,230}, {160,60}}}, {{{60,120}, {260,120}}}}, | 17 {{{{90,230}, {160,60}}}, {{{60,120}, {260,120}}}}, |
17 {{{{90,230}, {160,60}}}, {{{181.176468,120}, {135.294128,120}}}}, | 18 {{{{90,230}, {160,60}}}, {{{181.176468,120}, {135.294128,120}}}}, |
18 {{{{181.1764678955078125f, 120}, {186.3661956787109375f, 134.7042236328125f}
}}, | 19 {{{{181.1764678955078125f, 120}, {186.3661956787109375f, 134.7042236328125f}
}}, |
19 {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 1
33.7258148193359375f}}}}, | 20 {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 1
33.7258148193359375f}}}}, |
20 #if 0 // FIXME: these fail because one line is too short and appears quasi-coin
cident | 21 #if 0 // FIXME: these fail because one line is too short and appears quasi-coin
cident |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 double bottom = SkTMax(line2[0].fY, line2[1].fY); | 172 double bottom = SkTMax(line2[0].fY, line2[1].fY); |
172 SkIntersections ts; | 173 SkIntersections ts; |
173 ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top); | 174 ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top); |
174 REPORTER_ASSERT(reporter, pts == 2); | 175 REPORTER_ASSERT(reporter, pts == 2); |
175 REPORTER_ASSERT(reporter, pts == ts.used()); | 176 REPORTER_ASSERT(reporter, pts == ts.used()); |
176 check_results(reporter, line1, line2, ts); | 177 check_results(reporter, line1, line2, ts); |
177 } | 178 } |
178 reporter->bumpTestCount(); | 179 reporter->bumpTestCount(); |
179 } | 180 } |
180 | 181 |
181 static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) { | 182 DEF_TEST(PathOpsLineIntersection, reporter) { |
182 size_t index; | 183 size_t index; |
183 for (index = 0; index < coincidentTests_count; ++index) { | 184 for (index = 0; index < coincidentTests_count; ++index) { |
184 const SkDLine& line1 = coincidentTests[index][0]; | 185 const SkDLine& line1 = coincidentTests[index][0]; |
185 const SkDLine& line2 = coincidentTests[index][1]; | 186 const SkDLine& line2 = coincidentTests[index][1]; |
186 testOneCoincident(reporter, line1, line2); | 187 testOneCoincident(reporter, line1, line2); |
187 } | 188 } |
188 for (index = 0; index < tests_count; ++index) { | 189 for (index = 0; index < tests_count; ++index) { |
189 const SkDLine& line1 = tests[index][0]; | 190 const SkDLine& line1 = tests[index][0]; |
190 const SkDLine& line2 = tests[index][1]; | 191 const SkDLine& line2 = tests[index][1]; |
191 testOne(reporter, line1, line2); | 192 testOne(reporter, line1, line2); |
192 } | 193 } |
193 for (index = 0; index < noIntersect_count; ++index) { | 194 for (index = 0; index < noIntersect_count; ++index) { |
194 const SkDLine& line1 = noIntersect[index][0]; | 195 const SkDLine& line1 = noIntersect[index][0]; |
195 const SkDLine& line2 = noIntersect[index][1]; | 196 const SkDLine& line2 = noIntersect[index][1]; |
196 SkIntersections ts; | 197 SkIntersections ts; |
197 int pts = ts.intersect(line1, line2); | 198 int pts = ts.intersect(line1, line2); |
198 REPORTER_ASSERT(reporter, !pts); | 199 REPORTER_ASSERT(reporter, !pts); |
199 REPORTER_ASSERT(reporter, pts == ts.used()); | 200 REPORTER_ASSERT(reporter, pts == ts.used()); |
200 reporter->bumpTestCount(); | 201 reporter->bumpTestCount(); |
201 } | 202 } |
202 } | 203 } |
203 | 204 |
204 static void PathOpsLineIntersectionOneOffTest(skiatest::Reporter* reporter) { | 205 DEF_TEST(PathOpsLineIntersectionOneOff, reporter) { |
205 int index = 0; | 206 int index = 0; |
206 SkASSERT(index < (int) tests_count); | 207 SkASSERT(index < (int) tests_count); |
207 testOne(reporter, tests[index][0], tests[index][1]); | 208 testOne(reporter, tests[index][0], tests[index][1]); |
208 testOne(reporter, tests[1][0], tests[1][1]); | 209 testOne(reporter, tests[1][0], tests[1][1]); |
209 } | 210 } |
210 | 211 |
211 static void PathOpsLineIntersectionOneCoincidentTest(skiatest::Reporter* reporte
r) { | 212 DEF_TEST(PathOpsLineIntersectionOneCoincident, reporter) { |
212 int index = 0; | 213 int index = 0; |
213 SkASSERT(index < (int) coincidentTests_count); | 214 SkASSERT(index < (int) coincidentTests_count); |
214 const SkDLine& line1 = coincidentTests[index][0]; | 215 const SkDLine& line1 = coincidentTests[index][0]; |
215 const SkDLine& line2 = coincidentTests[index][1]; | 216 const SkDLine& line2 = coincidentTests[index][1]; |
216 testOneCoincident(reporter, line1, line2); | 217 testOneCoincident(reporter, line1, line2); |
217 } | 218 } |
218 | |
219 #include "TestClassDef.h" | |
220 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTest) | |
221 | |
222 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneOffTest) | |
223 | |
224 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneCoincidentTest) | |
OLD | NEW |