aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrShapeTest.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-04-27 13:30:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-27 13:30:25 -0700
commit4eeccc9de7d2381df85d68e0331a40cddf5989b1 (patch)
tree52d5a37c7f202fce9e27f3d6936d895624e0de11 /tests/GrShapeTest.cpp
parent409ed73237c1fc42ea49ae89efdc4cddc7b6f600 (diff)
Add tests for volatile paths to GrShapeTest
Diffstat (limited to 'tests/GrShapeTest.cpp')
-rw-r--r--tests/GrShapeTest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index 14316c1f8d..de08457dba 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -449,6 +449,36 @@ void test_unknown_path_effect(skiatest::Reporter* reporter, const GEO& geo) {
geoPEStrokeCase.testExpectations(reporter, expectations);
}
+/**
+ * isNonPath indicates whether the initial shape made from the path is expected to be recognized
+ * as a simpler shape type (e.g. rrect)
+ */
+void test_volatile_path(skiatest::Reporter* reporter, const SkPath& path,
+ bool isNonPath) {
+ SkPath vPath(path);
+ vPath.setIsVolatile(true);
+
+ SkPaint dashAndStroke;
+ dashAndStroke.setPathEffect(make_dash());
+ dashAndStroke.setStrokeWidth(2.f);
+ dashAndStroke.setStyle(SkPaint::kStroke_Style);
+ TestCase volatileCase(vPath, dashAndStroke);
+ // We expect a shape made from a volatile path to have a key iff the shape is recognized
+ // as a specialized geometry.
+ if (isNonPath) {
+ REPORTER_ASSERT(reporter, SkToBool(volatileCase.baseKey().count()));
+ // In this case all the keys should be identical to the non-volatile case.
+ TestCase nonVolatileCase(path, dashAndStroke);
+ volatileCase.compare(reporter, nonVolatileCase, TestCase::kAllSame_ComparisonExpecation);
+ } else {
+ // None of the keys should be valid.
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.baseKey().count()));
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectKey().count()));
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedFullStyleKey().count()));
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectThenStrokeKey().count()));
+ }
+}
+
template <typename GEO>
void test_path_effect_makes_empty_shape(skiatest::Reporter* reporter, const GEO& geo) {
/**
@@ -594,6 +624,8 @@ DEF_TEST(GrShape, reporter) {
test_null_dash(reporter, path);
test_path_effect_makes_rrect(reporter, path);
}
+ // This test uses a stroking paint, hence use of fIsRRectForStroke
+ test_volatile_path(reporter, path, testPath.fIsRRectForStroke);
test_dash_fill(reporter, path);
// Test modifying various stroke params.
test_stroke_param<SkPath, SkScalar>(
@@ -637,6 +669,9 @@ DEF_TEST(GrShape, reporter) {
}
}
+ // Test a volatile empty path.
+ test_volatile_path(reporter, SkPath(), true);
+
test_empty_shape(reporter);
}