| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPathOpsBounds.h" | 8 #include "SkPathOpsBounds.h" |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 #include "TestClassDef.h" |
| 10 | 11 |
| 11 static const SkRect sectTests[][2] = { | 12 static const SkRect sectTests[][2] = { |
| 12 {{2, 0, 4, 1}, {4, 0, 6, 1}}, | 13 {{2, 0, 4, 1}, {4, 0, 6, 1}}, |
| 13 {{2, 0, 4, 1}, {3, 0, 5, 1}}, | 14 {{2, 0, 4, 1}, {3, 0, 5, 1}}, |
| 14 {{2, 0, 4, 1}, {3, 0, 5, 0}}, | 15 {{2, 0, 4, 1}, {3, 0, 5, 0}}, |
| 15 {{2, 0, 4, 1}, {3, 1, 5, 2}}, | 16 {{2, 0, 4, 1}, {3, 1, 5, 2}}, |
| 16 {{2, 1, 4, 2}, {1, 0, 5, 3}}, | 17 {{2, 1, 4, 2}, {1, 0, 5, 3}}, |
| 17 {{2, 1, 5, 3}, {3, 1, 4, 2}}, | 18 {{2, 1, 5, 3}, {3, 1, 4, 2}}, |
| 18 {{2, 0, 4, 1}, {3, 0, 3, 0}}, // intersecting an empty bounds is OK | 19 {{2, 0, 4, 1}, {3, 0, 3, 0}}, // intersecting an empty bounds is OK |
| 19 {{2, 0, 4, 1}, {4, 1, 5, 2}}, // touching just on a corner is OK | 20 {{2, 0, 4, 1}, {4, 1, 5, 2}}, // touching just on a corner is OK |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 static const size_t emptyTestsCount = SK_ARRAY_COUNT(reallyEmpty); | 40 static const size_t emptyTestsCount = SK_ARRAY_COUNT(reallyEmpty); |
| 40 | 41 |
| 41 static const SkRect notReallyEmpty[] = { | 42 static const SkRect notReallyEmpty[] = { |
| 42 {0, 0, 1, 0}, | 43 {0, 0, 1, 0}, |
| 43 {0, 0, 0, 1}, | 44 {0, 0, 0, 1}, |
| 44 {0, 0, 1, 1}, | 45 {0, 0, 1, 1}, |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 static const size_t notEmptyTestsCount = SK_ARRAY_COUNT(notReallyEmpty); | 48 static const size_t notEmptyTestsCount = SK_ARRAY_COUNT(notReallyEmpty); |
| 48 | 49 |
| 49 static void PathOpsBoundsTest(skiatest::Reporter* reporter) { | 50 DEF_TEST(PathOpsBounds, reporter) { |
| 50 for (size_t index = 0; index < sectTestsCount; ++index) { | 51 for (size_t index = 0; index < sectTestsCount; ++index) { |
| 51 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(sec
tTests[index][0]); | 52 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(sec
tTests[index][0]); |
| 52 SkASSERT(ValidBounds(bounds1)); | 53 SkASSERT(ValidBounds(bounds1)); |
| 53 const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(sec
tTests[index][1]); | 54 const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(sec
tTests[index][1]); |
| 54 SkASSERT(ValidBounds(bounds2)); | 55 SkASSERT(ValidBounds(bounds2)); |
| 55 bool touches = SkPathOpsBounds::Intersects(bounds1, bounds2); | 56 bool touches = SkPathOpsBounds::Intersects(bounds1, bounds2); |
| 56 REPORTER_ASSERT(reporter, touches); | 57 REPORTER_ASSERT(reporter, touches); |
| 57 } | 58 } |
| 58 for (size_t index = 0; index < noSectTestsCount; ++index) { | 59 for (size_t index = 0; index < noSectTestsCount; ++index) { |
| 59 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(noS
ectTests[index][0]); | 60 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(noS
ectTests[index][0]); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 expected.set(0, 0, 3, 4); | 102 expected.set(0, 0, 3, 4); |
| 102 REPORTER_ASSERT(reporter, bounds == expected); | 103 REPORTER_ASSERT(reporter, bounds == expected); |
| 103 (bounds.*SetCurveBounds[2])(curvePts); | 104 (bounds.*SetCurveBounds[2])(curvePts); |
| 104 REPORTER_ASSERT(reporter, bounds == expected); | 105 REPORTER_ASSERT(reporter, bounds == expected); |
| 105 bounds.setCubicBounds(curvePts); | 106 bounds.setCubicBounds(curvePts); |
| 106 expected.set(0, 0, 5, 6); | 107 expected.set(0, 0, 5, 6); |
| 107 REPORTER_ASSERT(reporter, bounds == expected); | 108 REPORTER_ASSERT(reporter, bounds == expected); |
| 108 (bounds.*SetCurveBounds[3])(curvePts); | 109 (bounds.*SetCurveBounds[3])(curvePts); |
| 109 REPORTER_ASSERT(reporter, bounds == expected); | 110 REPORTER_ASSERT(reporter, bounds == expected); |
| 110 } | 111 } |
| 111 | |
| 112 #include "TestClassDef.h" | |
| 113 DEFINE_TESTCLASS_SHORT(PathOpsBoundsTest) | |
| OLD | NEW |