caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 1 | #include "EdgeWalker_Test.h" |
| 2 | #include "Intersection_Tests.h" |
| 3 | |
| 4 | static void testSimplifyQuad1() { |
| 5 | SkPath path, out; |
| 6 | path.moveTo(0, 0); |
| 7 | path.lineTo(1, 0); |
| 8 | path.lineTo(3, 2); |
| 9 | path.lineTo(3, 3); |
| 10 | path.close(); |
| 11 | path.moveTo(1, 0); |
| 12 | path.lineTo(1, 3); |
| 13 | path.lineTo(1, 3); |
| 14 | path.lineTo(1, 3); |
| 15 | path.close(); |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 16 | testSimplify(path, true, out); |
| 17 | } |
| 18 | |
| 19 | static void testSimplifyQuad2() { |
| 20 | SkPath path, out; |
| 21 | path.moveTo(0, 0); |
| 22 | path.lineTo(0, 0); |
| 23 | path.lineTo(0, 0); |
| 24 | path.lineTo(0, 2); |
| 25 | path.close(); |
| 26 | path.moveTo(0, 1); |
| 27 | path.lineTo(0, 1); |
| 28 | path.lineTo(1, 1); |
| 29 | path.lineTo(0, 2); |
| 30 | path.close(); |
| 31 | testSimplify(path, true, out); |
| 32 | } |
| 33 | |
| 34 | static void testSimplifyQuad3() { |
| 35 | SkPath path, out; |
| 36 | path.moveTo(0, 0); |
| 37 | path.lineTo(0, 0); |
| 38 | path.lineTo(1, 0); |
| 39 | path.lineTo(1, 2); |
| 40 | path.close(); |
| 41 | path.moveTo(0, 1); |
| 42 | path.lineTo(1, 1); |
| 43 | path.lineTo(2, 1); |
| 44 | path.lineTo(0, 2); |
| 45 | path.close(); |
| 46 | testSimplify(path, true, out); |
| 47 | } |
| 48 | |
| 49 | static void testSimplifyQuad4() { |
| 50 | SkPath path, out; |
| 51 | path.moveTo(0, 0); |
| 52 | path.lineTo(0, 0); |
| 53 | path.lineTo(1, 0); |
| 54 | path.lineTo(2, 2); |
| 55 | path.close(); |
| 56 | path.moveTo(0, 0); |
| 57 | path.lineTo(2, 1); |
| 58 | path.lineTo(3, 1); |
| 59 | path.lineTo(3, 3); |
| 60 | path.close(); |
| 61 | testSimplify(path, true, out); |
| 62 | } |
| 63 | |
| 64 | static void testSimplifyQuad5() { |
| 65 | SkPath path, out; |
| 66 | path.moveTo(0, 0); |
| 67 | path.lineTo(0, 0); |
| 68 | path.lineTo(1, 0); |
| 69 | path.lineTo(3, 2); |
| 70 | path.close(); |
| 71 | path.moveTo(0, 1); |
| 72 | path.lineTo(1, 1); |
| 73 | path.lineTo(2, 1); |
| 74 | path.lineTo(0, 2); |
| 75 | path.close(); |
| 76 | testSimplify(path, true, out); |
| 77 | } |
| 78 | |
| 79 | static void testSimplifyQuad6() { |
| 80 | SkPath path, out; |
| 81 | path.moveTo(0, 0); |
| 82 | path.lineTo(1, 0); |
| 83 | path.lineTo(1, 1); |
| 84 | path.lineTo(3, 3); |
| 85 | path.close(); |
| 86 | path.moveTo(1, 1); |
| 87 | path.lineTo(1, 1); |
| 88 | path.lineTo(1, 1); |
| 89 | path.lineTo(2, 2); |
| 90 | path.close(); |
| 91 | testSimplify(path, true, out); |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 92 | } |
| 93 | |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 94 | static void (*simplifyTests[])() = { |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 95 | testSimplifyQuad6, |
| 96 | testSimplifyQuad5, |
| 97 | testSimplifyQuad4, |
| 98 | testSimplifyQuad3, |
| 99 | testSimplifyQuad2, |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 100 | testSimplifyQuad1, |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]); |
| 104 | |
| 105 | static void (*firstTest)() = 0; |
| 106 | |
| 107 | void SimplifyQuadralateralPaths_Test() { |
| 108 | size_t index = 0; |
| 109 | if (firstTest) { |
| 110 | while (index < simplifyTestsCount && simplifyTests[index] != firstTest) { |
| 111 | ++index; |
| 112 | } |
| 113 | } |
| 114 | for ( ; index < simplifyTestsCount; ++index) { |
| 115 | (*simplifyTests[index])(); |
| 116 | } |
| 117 | } |