Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: tests/AsADashTest.cpp

Issue 212103010: Add asADash entry point into SkPathEffect to allow extracting Dash info from PathEffects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nits Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkDashPathEffect.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/AsADashTest.cpp
diff --git a/tests/AsADashTest.cpp b/tests/AsADashTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47f19717a4f6d4134d1154cd9ef2c0e060060d53
--- /dev/null
+++ b/tests/AsADashTest.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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<SkCornerPathEffect> 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<SkDashPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
+
+ SkPathEffect::DashType dashType = pe->asADash(NULL);
+ 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<SkDashPathEffect> 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);
+}
« no previous file with comments | « src/effects/SkDashPathEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698