5e1ddb1086
Reason for revert: chrome changes have landed Original issue's description: > Revert of change all factories to return their base-class (patchset #1 id:1 of https://codereview.chromium.org/1535353002/ ) > > Reason for revert: > need to update some chrome/blink call-sites > > Original issue's description: > > change all factories to return their base-class > > > > will watch DEPS roll to see if there are chrome sites needing updates > > > > BUG=skia: > > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1535353002 > > > > TBR= > > > > Committed: https://skia.googlesource.com/skia/+/d63f60a36327e9580861205ebb35cade8c49bd34 > > TBR= > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/2d6ba6690f8951e152d8e793191b14afd52f5506 TBR= NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1533373002
58 lines
2.0 KiB
C++
58 lines
2.0 KiB
C++
/*
|
|
* Copyright 2014 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "Test.h"
|
|
|
|
#include "SkPathEffect.h"
|
|
#include "SkDashPathEffect.h"
|
|
#include "SkCornerPathEffect.h"
|
|
|
|
DEF_TEST(AsADashTest_noneDash, reporter) {
|
|
SkAutoTUnref<SkPathEffect> pe(SkCornerPathEffect::Create(1.0));
|
|
SkPathEffect::DashInfo info;
|
|
|
|
SkPathEffect::DashType dashType = pe->asADash(&info);
|
|
REPORTER_ASSERT(reporter, SkPathEffect::kNone_DashType == dashType);
|
|
}
|
|
|
|
DEF_TEST(AsADashTest_nullInfo, reporter) {
|
|
SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 };
|
|
const SkScalar phase = 2.0;
|
|
SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
|
|
|
|
SkPathEffect::DashType dashType = pe->asADash(nullptr);
|
|
REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType);
|
|
}
|
|
|
|
DEF_TEST(AsADashTest_usingDash, reporter) {
|
|
SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 };
|
|
SkScalar totalIntSum = 10.0;
|
|
const SkScalar phase = 2.0;
|
|
|
|
SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
|
|
|
|
SkPathEffect::DashInfo info;
|
|
|
|
SkPathEffect::DashType dashType = pe->asADash(&info);
|
|
REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType);
|
|
REPORTER_ASSERT(reporter, 4 == info.fCount);
|
|
REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase);
|
|
|
|
// Since it is a kDash_DashType, allocate space for the intervals and recall asADash
|
|
SkAutoTArray<SkScalar> intervals(info.fCount);
|
|
info.fIntervals = intervals.get();
|
|
pe->asADash(&info);
|
|
REPORTER_ASSERT(reporter, inIntervals[0] == info.fIntervals[0]);
|
|
REPORTER_ASSERT(reporter, inIntervals[1] == info.fIntervals[1]);
|
|
REPORTER_ASSERT(reporter, inIntervals[2] == info.fIntervals[2]);
|
|
REPORTER_ASSERT(reporter, inIntervals[3] == info.fIntervals[3]);
|
|
|
|
// Make sure nothing else has changed on us
|
|
REPORTER_ASSERT(reporter, 4 == info.fCount);
|
|
REPORTER_ASSERT(reporter, SkScalarMod(phase, totalIntSum) == info.fPhase);
|
|
}
|