From 2ff1fcede1e9525285c5de1f35fb2dcb0fab32bd Mon Sep 17 00:00:00 2001 From: reed Date: Thu, 11 Dec 2014 07:07:37 -0800 Subject: Defer saves() until they're needed patch from issue 759443006 at patchset 40001 (http://crrev.com/759443006#ps40001) BUG=skia: Review URL: https://codereview.chromium.org/767333002 --- tests/RecordPatternTest.cpp | 92 ++++++++++----------------------------------- 1 file changed, 20 insertions(+), 72 deletions(-) (limited to 'tests/RecordPatternTest.cpp') diff --git a/tests/RecordPatternTest.cpp b/tests/RecordPatternTest.cpp index 5f4d006683..1f5ce2c046 100644 --- a/tests/RecordPatternTest.cpp +++ b/tests/RecordPatternTest.cpp @@ -75,56 +75,19 @@ DEF_TEST(RecordPattern_Star, r) { SkRecord record; SkRecorder recorder(&record, 1920, 1200); - - recorder.save(); - recorder.restore(); - REPORTER_ASSERT(r, pattern.match(&record, 0)); + int index = 0; recorder.save(); recorder.clipRect(SkRect::MakeWH(300, 200)); recorder.restore(); - REPORTER_ASSERT(r, pattern.match(&record, 2)); + REPORTER_ASSERT(r, pattern.match(&record, index)); + index += 3; recorder.save(); recorder.clipRect(SkRect::MakeWH(300, 200)); recorder.clipRect(SkRect::MakeWH(100, 100)); recorder.restore(); - REPORTER_ASSERT(r, pattern.match(&record, 5)); -} - -DEF_TEST(RecordPattern_IsDraw, r) { - Pattern3, IsDraw, Is > pattern; - - SkRecord record; - SkRecorder recorder(&record, 1920, 1200); - - recorder.save(); - recorder.clipRect(SkRect::MakeWH(300, 200)); - recorder.restore(); - - REPORTER_ASSERT(r, !pattern.match(&record, 0)); - - SkPaint paint; - - recorder.save(); - paint.setColor(0xEEAA8822); - recorder.drawRect(SkRect::MakeWH(300, 200), paint); - recorder.restore(); - - recorder.save(); - paint.setColor(0xFACEFACE); - recorder.drawPaint(paint); - recorder.restore(); - - REPORTER_ASSERT(r, pattern.match(&record, 3)); - REPORTER_ASSERT(r, pattern.first() != NULL); - REPORTER_ASSERT(r, pattern.second()->getColor() == 0xEEAA8822); - REPORTER_ASSERT(r, pattern.third() != NULL); - - REPORTER_ASSERT(r, pattern.match(&record, 6)); - REPORTER_ASSERT(r, pattern.first() != NULL); - REPORTER_ASSERT(r, pattern.second()->getColor() == 0xFACEFACE); - REPORTER_ASSERT(r, pattern.third() != NULL); + REPORTER_ASSERT(r, pattern.match(&record, index)); } DEF_TEST(RecordPattern_Complex, r) { @@ -136,54 +99,39 @@ DEF_TEST(RecordPattern_Complex, r) { SkRecord record; SkRecorder recorder(&record, 1920, 1200); + unsigned start, begin, end; - recorder.save(); - recorder.restore(); - REPORTER_ASSERT(r, pattern.match(&record, 0) == 2); - - recorder.save(); - recorder.save(); - recorder.restore(); - recorder.restore(); - REPORTER_ASSERT(r, !pattern.match(&record, 2)); - REPORTER_ASSERT(r, pattern.match(&record, 3) == 5); - + start = record.count(); recorder.save(); recorder.clipRect(SkRect::MakeWH(300, 200)); recorder.restore(); - REPORTER_ASSERT(r, pattern.match(&record, 6) == 9); + REPORTER_ASSERT(r, pattern.match(&record, 0) == record.count()); + end = start; + REPORTER_ASSERT(r, pattern.search(&record, &begin, &end)); + REPORTER_ASSERT(r, begin == start); + REPORTER_ASSERT(r, end == record.count()); + start = record.count(); recorder.save(); recorder.clipRect(SkRect::MakeWH(300, 200)); recorder.drawRect(SkRect::MakeWH(100, 3000), SkPaint()); recorder.restore(); - REPORTER_ASSERT(r, !pattern.match(&record, 9)); + REPORTER_ASSERT(r, !pattern.match(&record, start)); + end = start; + REPORTER_ASSERT(r, !pattern.search(&record, &begin, &end)); + start = record.count(); recorder.save(); recorder.pushCull(SkRect::MakeWH(300, 200)); recorder.clipRect(SkRect::MakeWH(300, 200)); recorder.clipRect(SkRect::MakeWH(100, 400)); recorder.popCull(); recorder.restore(); - REPORTER_ASSERT(r, pattern.match(&record, 13) == 19); - - // Same as above, but using pattern.search to step through matches. - unsigned begin, end = 0; - REPORTER_ASSERT(r, pattern.search(&record, &begin, &end)); - REPORTER_ASSERT(r, begin == 0); - REPORTER_ASSERT(r, end == 2); - - REPORTER_ASSERT(r, pattern.search(&record, &begin, &end)); - REPORTER_ASSERT(r, begin == 3); - REPORTER_ASSERT(r, end == 5); - - REPORTER_ASSERT(r, pattern.search(&record, &begin, &end)); - REPORTER_ASSERT(r, begin == 6); - REPORTER_ASSERT(r, end == 9); - + REPORTER_ASSERT(r, pattern.match(&record, start) == record.count()); + end = start; REPORTER_ASSERT(r, pattern.search(&record, &begin, &end)); - REPORTER_ASSERT(r, begin == 13); - REPORTER_ASSERT(r, end == 19); + REPORTER_ASSERT(r, begin == start); + REPORTER_ASSERT(r, end == record.count()); REPORTER_ASSERT(r, !pattern.search(&record, &begin, &end)); } -- cgit v1.2.3