Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
AsADashTest.cpp
Go to the documentation of this file.
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
14#include "tests/Test.h"
15
16using namespace skia_private;
17
25
26DEF_TEST(AsADashTest_nullInfo, reporter) {
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}
34
35DEF_TEST(AsADashTest_usingDash, reporter) {
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}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
reporter
#define SkScalarMod(x, y)
Definition SkScalar.h:41
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
static sk_sp< SkPathEffect > Make(SkScalar radius)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
@ kNone_DashType
ignores the info parameter
@ kDash_DashType
fills in all of the info parameter
float SkScalar
Definition extension.cpp:12