OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "Test.h" | |
9 | |
10 #include "SkPathEffect.h" | |
11 #include "SkDashPathEffect.h" | |
12 #include "SkCornerPathEffect.h" | |
13 | |
14 DEF_TEST(AsADashTest_noneDash, reporter) { | |
15 SkAutoTUnref<SkCornerPathEffect> pe(SkCornerPathEffect::Create(1.0)); | |
16 SkPathEffect::DashInfo info; | |
17 | |
18 SkPathEffect::DashType dashType = pe->asADash(&info); | |
19 REPORTER_ASSERT(reporter, SkPathEffect::kNone_DashType == dashType); | |
20 } | |
21 | |
22 DEF_TEST(AsADashTest_nullInfo, reporter) { | |
23 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; | |
24 const SkScalar phase = 2.0; | |
25 SkAutoTUnref<SkDashPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, p hase, true)); | |
26 | |
27 SkPathEffect::DashType dashType = pe->asADash(NULL); | |
28 REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); | |
29 } | |
30 | |
31 DEF_TEST(AsADashTest_usingDash, reporter) { | |
32 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; | |
33 SkScalar totalIntSum = 10.0; | |
34 const SkScalar phase = 2.0; | |
35 | |
36 SkAutoTUnref<SkDashPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, p hase, true)); | |
37 | |
38 SkPathEffect::DashInfo info; | |
reed1
2014/03/28 14:52:53
since we "read" fIntervals, and only that field, p
| |
39 info.fCount = 0; | |
40 info.fIntervals = NULL; | |
41 | |
42 SkPathEffect::DashType dashType = pe->asADash(&info); | |
43 REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); | |
44 REPORTER_ASSERT(reporter, 4 == info.fCount); | |
45 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase); | |
46 REPORTER_ASSERT(reporter, true == info.fScaleToFit); | |
47 | |
48 // Since it is a kDash_DashType, allocate space for the intervals and recall asADash | |
49 SkAutoTArray<SkScalar> intervals(info.fCount); | |
50 info.fIntervals = intervals.get(); | |
51 pe->asADash(&info); | |
52 REPORTER_ASSERT(reporter, inIntervals[0] == info.fIntervals[0]); | |
53 REPORTER_ASSERT(reporter, inIntervals[1] == info.fIntervals[1]); | |
54 REPORTER_ASSERT(reporter, inIntervals[2] == info.fIntervals[2]); | |
55 REPORTER_ASSERT(reporter, inIntervals[3] == info.fIntervals[3]); | |
56 | |
57 // Make sure nothing else has changed on us | |
58 REPORTER_ASSERT(reporter, 4 == info.fCount); | |
59 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase); | |
60 REPORTER_ASSERT(reporter, true == info.fScaleToFit); | |
61 } | |
OLD | NEW |