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

Unified Diff: tests/DashPathEffectTest.cpp

Issue 189373008: Add reg test for http://crbug.com/348821 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments Created 6 years, 9 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 | « gyp/tests.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DashPathEffectTest.cpp
diff --git a/tests/DashPathEffectTest.cpp b/tests/DashPathEffectTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..32538aad910b058d3523862bf720fb227e988a80
--- /dev/null
+++ b/tests/DashPathEffectTest.cpp
@@ -0,0 +1,22 @@
+#include "Test.h"
+
+#include "SkDashPathEffect.h"
+#include "SkWriteBuffer.h"
+
+#define ASSERT(x) REPORTER_ASSERT(r, x)
+
+// crbug.com/348821 was rooted in SkDashPathEffect refusing to flatten and unflatten itself when
+// fInitialDashLength < 0 (a signal the effect is nonsense). Here we test that it flattens.
+
+DEF_TEST(DashPathEffectTest_crbug_348821, r) {
+ SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug.
+ const int count = 2;
reed1 2014/03/07 14:52:59 I *thought* the bug was triggered by count < 0 ...
mtklein 2014/03/07 15:00:10 Nope. This is the path effect: (gdb) p *this $1
+ SkScalar phase = 1.0f/0.0f; // Used to force the bad fInitialDashLength = -1 path.
reed1 2014/03/07 14:52:59 you may get compiler warnings about this construct
mtklein 2014/03/07 15:00:10 Duh, right. Done.
+ SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, count, phase));
+
+ ASSERT(dash->getFactory() != NULL); // NULL -> refuses to work with flattening framework.
+
+ SkWriteBuffer buffer;
+ buffer.writeFlattenable(dash);
+ ASSERT(buffer.bytesWritten() > 12); // We'd write 12 if broken, >=40 if not.
+}
« no previous file with comments | « gyp/tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698