OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
9 #include "SkPathMeasure.h" | 10 #include "SkPathMeasure.h" |
10 | 11 |
11 static void test_small_segment3() { | 12 static void test_small_segment3() { |
12 #ifdef SK_SCALAR_IS_FLOAT | 13 #ifdef SK_SCALAR_IS_FLOAT |
13 SkPath path; | 14 SkPath path; |
14 const SkPoint pts[] = { | 15 const SkPoint pts[] = { |
15 { 0, 0 }, | 16 { 0, 0 }, |
16 { 100000000000.0f, 100000000000.0f }, { 0, 0 }, { 10, 10 }, | 17 { 100000000000.0f, 100000000000.0f }, { 0, 0 }, { 10, 10 }, |
17 { 10, 10 }, { 0, 0 }, { 10, 10 } | 18 { 10, 10 }, { 0, 0 }, { 10, 10 } |
18 }; | 19 }; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 SkASSERT(d > 0); // TRUE | 73 SkASSERT(d > 0); // TRUE |
73 SkASSERT(seg->fDistance > prevSeg->fDistance); // FALSE | 74 SkASSERT(seg->fDistance > prevSeg->fDistance); // FALSE |
74 | 75 |
75 This 2nd assert failes because (distance += d) didn't affect distance | 76 This 2nd assert failes because (distance += d) didn't affect distance |
76 because distance >>> d. | 77 because distance >>> d. |
77 */ | 78 */ |
78 meas.getLength(); | 79 meas.getLength(); |
79 #endif | 80 #endif |
80 } | 81 } |
81 | 82 |
82 static void TestPathMeasure(skiatest::Reporter* reporter) { | 83 DEF_TEST(PathMeasure, reporter) { |
83 SkPath path; | 84 SkPath path; |
84 | 85 |
85 path.moveTo(0, 0); | 86 path.moveTo(0, 0); |
86 path.lineTo(SK_Scalar1, 0); | 87 path.lineTo(SK_Scalar1, 0); |
87 path.lineTo(SK_Scalar1, SK_Scalar1); | 88 path.lineTo(SK_Scalar1, SK_Scalar1); |
88 path.lineTo(0, SK_Scalar1); | 89 path.lineTo(0, SK_Scalar1); |
89 | 90 |
90 SkPathMeasure meas(path, true); | 91 SkPathMeasure meas(path, true); |
91 SkScalar length = meas.getLength(); | 92 SkScalar length = meas.getLength(); |
92 SkASSERT(length == SK_Scalar1*4); | 93 SkASSERT(length == SK_Scalar1*4); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 SkScalarNearlyEqual(position.fY, | 201 SkScalarNearlyEqual(position.fY, |
201 2.0f, | 202 2.0f, |
202 0.0001f)); | 203 0.0001f)); |
203 REPORTER_ASSERT(reporter, tangent.fX == -SK_Scalar1); | 204 REPORTER_ASSERT(reporter, tangent.fX == -SK_Scalar1); |
204 REPORTER_ASSERT(reporter, tangent.fY == 0); | 205 REPORTER_ASSERT(reporter, tangent.fY == 0); |
205 | 206 |
206 test_small_segment(); | 207 test_small_segment(); |
207 test_small_segment2(); | 208 test_small_segment2(); |
208 test_small_segment3(); | 209 test_small_segment3(); |
209 } | 210 } |
210 | |
211 #include "TestClassDef.h" | |
212 DEFINE_TESTCLASS("PathMeasure", PathMeasureTestClass, TestPathMeasure) | |
OLD | NEW |