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

Unified Diff: tests/ColorFilterTest.cpp

Issue 972153010: add impl limit for number of leaf-nodes in composecolorfilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify using base-1 Created 5 years, 10 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
« include/core/SkColorFilter.h ('K') | « src/core/SkColorFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ColorFilterTest.cpp
diff --git a/tests/ColorFilterTest.cpp b/tests/ColorFilterTest.cpp
index f3f6a0a8e890f73d2752b6ef4b869276bf746e64..b2e37183b5e7b223cf1d545ee8138a5311e68b64 100644
--- a/tests/ColorFilterTest.cpp
+++ b/tests/ColorFilterTest.cpp
@@ -30,6 +30,26 @@ static SkColorFilter* reincarnate_colorfilter(SkFlattenable* obj) {
///////////////////////////////////////////////////////////////////////////////
+static SkColorFilter* make_filter() {
+ // pick a filter that cannot compose with itself via newComposed()
+ return SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kColorBurn_Mode);
+}
+
+static void test_composecolorfilter_limit(skiatest::Reporter* reporter) {
+ // Test that CreateComposeFilter() has some finite limit (i.e. that the factory can return null)
Stephen White 2015/03/05 15:19:11 Maybe we should add some more tests that reasonabl
robertphillips 2015/03/05 15:20:43 kWayTooMany ?
+ const int way_too_many = 100;
+ SkAutoTUnref<SkColorFilter> parent(make_filter());
+ for (int i = 2; i < way_too_many; ++i) {
+ SkAutoTUnref<SkColorFilter> filter(make_filter());
+ parent.reset(SkColorFilter::CreateComposeFilter(parent, filter));
+ if (NULL == parent) {
+ REPORTER_ASSERT(reporter, i > 2); // we need to have succeeded at least once!
+ return;
+ }
+ }
+ REPORTER_ASSERT(reporter, false); // we never saw a NULL :(
+}
+
#define ILLEGAL_MODE ((SkXfermode::Mode)-1)
DEF_TEST(ColorFilter, reporter) {
@@ -89,6 +109,8 @@ DEF_TEST(ColorFilter, reporter) {
REPORTER_ASSERT(reporter, m2 == expectedMode);
}
}
+
+ test_composecolorfilter_limit(reporter);
}
///////////////////////////////////////////////////////////////////////////////
« include/core/SkColorFilter.h ('K') | « src/core/SkColorFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698