OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 #include "SkPathEffect.h" | 10 #include "SkPathEffect.h" |
11 #include "SkDashPathEffect.h" | 11 #include "SkDashPathEffect.h" |
12 #include "SkCornerPathEffect.h" | 12 #include "SkCornerPathEffect.h" |
13 | 13 |
14 DEF_TEST(AsADashTest_noneDash, reporter) { | 14 DEF_TEST(AsADashTest_noneDash, reporter) { |
15 SkAutoTUnref<SkCornerPathEffect> pe(SkCornerPathEffect::Create(1.0)); | 15 SkAutoTUnref<SkPathEffect> pe(SkCornerPathEffect::Create(1.0)); |
16 SkPathEffect::DashInfo info; | 16 SkPathEffect::DashInfo info; |
17 | 17 |
18 SkPathEffect::DashType dashType = pe->asADash(&info); | 18 SkPathEffect::DashType dashType = pe->asADash(&info); |
19 REPORTER_ASSERT(reporter, SkPathEffect::kNone_DashType == dashType); | 19 REPORTER_ASSERT(reporter, SkPathEffect::kNone_DashType == dashType); |
20 } | 20 } |
21 | 21 |
22 DEF_TEST(AsADashTest_nullInfo, reporter) { | 22 DEF_TEST(AsADashTest_nullInfo, reporter) { |
23 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; | 23 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; |
24 const SkScalar phase = 2.0; | 24 const SkScalar phase = 2.0; |
25 SkAutoTUnref<SkDashPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, p
hase)); | 25 SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase
)); |
26 | 26 |
27 SkPathEffect::DashType dashType = pe->asADash(nullptr); | 27 SkPathEffect::DashType dashType = pe->asADash(nullptr); |
28 REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); | 28 REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); |
29 } | 29 } |
30 | 30 |
31 DEF_TEST(AsADashTest_usingDash, reporter) { | 31 DEF_TEST(AsADashTest_usingDash, reporter) { |
32 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; | 32 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; |
33 SkScalar totalIntSum = 10.0; | 33 SkScalar totalIntSum = 10.0; |
34 const SkScalar phase = 2.0; | 34 const SkScalar phase = 2.0; |
35 | 35 |
36 SkAutoTUnref<SkDashPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, p
hase)); | 36 SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase
)); |
37 | 37 |
38 SkPathEffect::DashInfo info; | 38 SkPathEffect::DashInfo info; |
39 | 39 |
40 SkPathEffect::DashType dashType = pe->asADash(&info); | 40 SkPathEffect::DashType dashType = pe->asADash(&info); |
41 REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); | 41 REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); |
42 REPORTER_ASSERT(reporter, 4 == info.fCount); | 42 REPORTER_ASSERT(reporter, 4 == info.fCount); |
43 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase); | 43 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase); |
44 | 44 |
45 // Since it is a kDash_DashType, allocate space for the intervals and recall
asADash | 45 // Since it is a kDash_DashType, allocate space for the intervals and recall
asADash |
46 SkAutoTArray<SkScalar> intervals(info.fCount); | 46 SkAutoTArray<SkScalar> intervals(info.fCount); |
47 info.fIntervals = intervals.get(); | 47 info.fIntervals = intervals.get(); |
48 pe->asADash(&info); | 48 pe->asADash(&info); |
49 REPORTER_ASSERT(reporter, inIntervals[0] == info.fIntervals[0]); | 49 REPORTER_ASSERT(reporter, inIntervals[0] == info.fIntervals[0]); |
50 REPORTER_ASSERT(reporter, inIntervals[1] == info.fIntervals[1]); | 50 REPORTER_ASSERT(reporter, inIntervals[1] == info.fIntervals[1]); |
51 REPORTER_ASSERT(reporter, inIntervals[2] == info.fIntervals[2]); | 51 REPORTER_ASSERT(reporter, inIntervals[2] == info.fIntervals[2]); |
52 REPORTER_ASSERT(reporter, inIntervals[3] == info.fIntervals[3]); | 52 REPORTER_ASSERT(reporter, inIntervals[3] == info.fIntervals[3]); |
53 | 53 |
54 // Make sure nothing else has changed on us | 54 // Make sure nothing else has changed on us |
55 REPORTER_ASSERT(reporter, 4 == info.fCount); | 55 REPORTER_ASSERT(reporter, 4 == info.fCount); |
56 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase); | 56 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase); |
57 } | 57 } |
OLD | NEW |