Flutter Engine
The Flutter Engine
Functions
AsADashTest.cpp File Reference
#include "include/core/SkPathEffect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/effects/SkCornerPathEffect.h"
#include "include/effects/SkDashPathEffect.h"
#include "include/private/base/SkTemplates.h"
#include "tests/Test.h"

Go to the source code of this file.

Functions

 DEF_TEST (AsADashTest_noneDash, reporter)
 
 DEF_TEST (AsADashTest_nullInfo, reporter)
 
 DEF_TEST (AsADashTest_usingDash, reporter)
 

Function Documentation

◆ DEF_TEST() [1/3]

DEF_TEST ( AsADashTest_noneDash  ,
reporter   
)

Definition at line 18 of file AsADashTest.cpp.

18 {
21
22 SkPathEffect::DashType dashType = pe->asADash(&info);
24}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
static sk_sp< SkPathEffect > Make(SkScalar radius)
@ kNone_DashType
ignores the info parameter
Definition: SkPathEffect.h:61

◆ DEF_TEST() [2/3]

DEF_TEST ( AsADashTest_nullInfo  ,
reporter   
)

Definition at line 26 of file AsADashTest.cpp.

26 {
27 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 };
28 const SkScalar phase = 2.0;
29 sk_sp<SkPathEffect> pe(SkDashPathEffect::Make(inIntervals, 4, phase));
30
31 SkPathEffect::DashType dashType = pe->asADash(nullptr);
33}
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
@ kDash_DashType
fills in all of the info parameter
Definition: SkPathEffect.h:62
float SkScalar
Definition: extension.cpp:12

◆ DEF_TEST() [3/3]

DEF_TEST ( AsADashTest_usingDash  ,
reporter   
)

Definition at line 35 of file AsADashTest.cpp.

35 {
36 SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 };
37 SkScalar totalIntSum = 10.0;
38 const SkScalar phase = 2.0;
39
40 sk_sp<SkPathEffect> pe(SkDashPathEffect::Make(inIntervals, 4, phase));
41
43
44 SkPathEffect::DashType dashType = pe->asADash(&info);
46 REPORTER_ASSERT(reporter, 4 == info.fCount);
47 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase);
48
49 // Since it is a kDash_DashType, allocate space for the intervals and recall asADash
50 AutoTArray<SkScalar> intervals(info.fCount);
51 info.fIntervals = intervals.get();
52 pe->asADash(&info);
53 REPORTER_ASSERT(reporter, inIntervals[0] == info.fIntervals[0]);
54 REPORTER_ASSERT(reporter, inIntervals[1] == info.fIntervals[1]);
55 REPORTER_ASSERT(reporter, inIntervals[2] == info.fIntervals[2]);
56 REPORTER_ASSERT(reporter, inIntervals[3] == info.fIntervals[3]);
57
58 // Make sure nothing else has changed on us
59 REPORTER_ASSERT(reporter, 4 == info.fCount);
60 REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase);
61}
#define SkScalarMod(x, y)
Definition: SkScalar.h:41