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 "SkPathOpsTriangle.h" | 8 #include "SkPathOpsTriangle.h" |
9 #include "Test.h" | 9 #include "Test.h" |
| 10 #include "TestClassDef.h" |
10 | 11 |
11 static const SkDTriangle tests[] = { | 12 static const SkDTriangle tests[] = { |
12 {{{2, 0}, {3, 1}, {2, 2}}}, | 13 {{{2, 0}, {3, 1}, {2, 2}}}, |
13 {{{3, 1}, {2, 2}, {1, 1}}}, | 14 {{{3, 1}, {2, 2}, {1, 1}}}, |
14 {{{3, 0}, {2, 1}, {3, 2}}}, | 15 {{{3, 0}, {2, 1}, {3, 2}}}, |
15 }; | 16 }; |
16 | 17 |
17 static const SkDPoint inPoint[] = { | 18 static const SkDPoint inPoint[] = { |
18 {2.5, 1}, | 19 {2.5, 1}, |
19 {2, 1.5}, | 20 {2, 1.5}, |
20 {2.5, 1}, | 21 {2.5, 1}, |
21 }; | 22 }; |
22 | 23 |
23 static const SkDPoint outPoint[] = { | 24 static const SkDPoint outPoint[] = { |
24 {3, 0}, | 25 {3, 0}, |
25 {2.5, 2}, | 26 {2.5, 2}, |
26 {2.5, 2}, | 27 {2.5, 2}, |
27 }; | 28 }; |
28 | 29 |
29 static const size_t tests_count = SK_ARRAY_COUNT(tests); | 30 static const size_t tests_count = SK_ARRAY_COUNT(tests); |
30 | 31 |
31 static void PathOpsTriangleUtilitiesTest(skiatest::Reporter* reporter) { | 32 DEF_TEST(PathOpsTriangleUtilities, reporter) { |
32 for (size_t index = 0; index < tests_count; ++index) { | 33 for (size_t index = 0; index < tests_count; ++index) { |
33 const SkDTriangle& triangle = tests[index]; | 34 const SkDTriangle& triangle = tests[index]; |
34 SkASSERT(ValidTriangle(triangle)); | 35 SkASSERT(ValidTriangle(triangle)); |
35 bool result = triangle.contains(inPoint[index]); | 36 bool result = triangle.contains(inPoint[index]); |
36 if (!result) { | 37 if (!result) { |
37 SkDebugf("%s [%d] expected point in triangle\n", __FUNCTION__, index
); | 38 SkDebugf("%s [%d] expected point in triangle\n", __FUNCTION__, index
); |
38 REPORTER_ASSERT(reporter, 0); | 39 REPORTER_ASSERT(reporter, 0); |
39 } | 40 } |
40 result = triangle.contains(outPoint[index]); | 41 result = triangle.contains(outPoint[index]); |
41 if (result) { | 42 if (result) { |
42 SkDebugf("%s [%d] expected point outside triangle\n", __FUNCTION__,
index); | 43 SkDebugf("%s [%d] expected point outside triangle\n", __FUNCTION__,
index); |
43 REPORTER_ASSERT(reporter, 0); | 44 REPORTER_ASSERT(reporter, 0); |
44 } | 45 } |
45 } | 46 } |
46 } | 47 } |
47 | 48 |
48 static const SkDTriangle oneOff[] = { | 49 static const SkDTriangle oneOff[] = { |
49 {{{271.03291625750461, 5.0402503630087025e-05}, {275.21652430019037, 3.69973
00650817753}, | 50 {{{271.03291625750461, 5.0402503630087025e-05}, {275.21652430019037, 3.69973
00650817753}, |
50 {279.25839233398438, 7.7416000366210938}}}, | 51 {279.25839233398438, 7.7416000366210938}}}, |
51 | 52 |
52 {{{271.03291625750461, 5.0402503617874572e-05}, {275.21652430019037, 3.69973
00650817877}, | 53 {{{271.03291625750461, 5.0402503617874572e-05}, {275.21652430019037, 3.69973
00650817877}, |
53 {279.25839233398438, 7.7416000366210938}}} | 54 {279.25839233398438, 7.7416000366210938}}} |
54 }; | 55 }; |
55 | 56 |
56 static const size_t oneOff_count = SK_ARRAY_COUNT(oneOff); | 57 static const size_t oneOff_count = SK_ARRAY_COUNT(oneOff); |
57 | 58 |
58 static void PathOpsTriangleOneOffTest(skiatest::Reporter* reporter) { | 59 DEF_TEST(PathOpsTriangleOneOff, reporter) { |
59 for (size_t index = 0; index < oneOff_count; ++index) { | 60 for (size_t index = 0; index < oneOff_count; ++index) { |
60 const SkDTriangle& triangle = oneOff[index]; | 61 const SkDTriangle& triangle = oneOff[index]; |
61 SkASSERT(ValidTriangle(triangle)); | 62 SkASSERT(ValidTriangle(triangle)); |
62 for (int inner = 0; inner < 3; ++inner) { | 63 for (int inner = 0; inner < 3; ++inner) { |
63 bool result = triangle.contains(triangle.fPts[inner]); | 64 bool result = triangle.contains(triangle.fPts[inner]); |
64 if (result) { | 65 if (result) { |
65 SkDebugf("%s [%d][%d] point on triangle is not in\n", __FUNCTION
__, index, inner); | 66 SkDebugf("%s [%d][%d] point on triangle is not in\n", __FUNCTION
__, index, inner); |
66 REPORTER_ASSERT(reporter, 0); | 67 REPORTER_ASSERT(reporter, 0); |
67 } | 68 } |
68 } | 69 } |
69 } | 70 } |
70 } | 71 } |
71 | |
72 #include "TestClassDef.h" | |
73 DEFINE_TESTCLASS_SHORT(PathOpsTriangleUtilitiesTest) | |
74 | |
75 DEFINE_TESTCLASS_SHORT(PathOpsTriangleOneOffTest) | |
OLD | NEW |