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

Unified Diff: tests/RecordOptsTest.cpp

Issue 767333002: Defer saves() until they're needed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update tests Created 6 years 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 | « tests/RecordDrawTest.cpp ('k') | tests/RecordPatternTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordOptsTest.cpp
diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp
index c5c4471d6715937383b9d8b122acc843d0e44e3e..cdc0350e535ddfc81450a44a50f78a11ebd5afc4 100644
--- a/tests/RecordOptsTest.cpp
+++ b/tests/RecordOptsTest.cpp
@@ -16,26 +16,19 @@
static const int W = 1920, H = 1080;
-DEF_TEST(RecordOpts_NoopDrawSaveRestore, r) {
+DEF_TEST(RecordOpts_NoopDraw, r) {
SkRecord record;
SkRecorder recorder(&record, W, H);
- // The save and restore are pointless if there's only draw commands in the middle.
- recorder.save();
- recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint());
- recorder.drawRect(SkRect::MakeWH(300, 300), SkPaint());
- recorder.drawRect(SkRect::MakeWH(100, 100), SkPaint());
- recorder.restore();
+ recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint());
+ recorder.drawRect(SkRect::MakeWH(300, 300), SkPaint());
+ recorder.drawRect(SkRect::MakeWH(100, 100), SkPaint());
- record.replace<SkRecords::NoOp>(2); // NoOps should be allowed.
+ record.replace<SkRecords::NoOp>(1); // NoOps should be allowed.
SkRecordNoopSaveRestores(&record);
- assert_type<SkRecords::NoOp>(r, record, 0);
- assert_type<SkRecords::DrawRect>(r, record, 1);
- assert_type<SkRecords::NoOp>(r, record, 2);
- assert_type<SkRecords::DrawRect>(r, record, 3);
- assert_type<SkRecords::NoOp>(r, record, 4);
+ REPORTER_ASSERT(r, 2 == count_instances_of_type<SkRecords::DrawRect>(record));
}
DEF_TEST(RecordOpts_SingleNoopSaveRestore, r) {
@@ -70,7 +63,7 @@ DEF_TEST(RecordOpts_NoopSaveRestores, r) {
recorder.restore();
SkRecordNoopSaveRestores(&record);
- for (unsigned index = 0; index < 8; index++) {
+ for (unsigned index = 0; index < record.count(); index++) {
assert_type<SkRecords::NoOp>(r, record, index);
}
}
@@ -86,10 +79,22 @@ DEF_TEST(RecordOpts_SaveSaveLayerRestoreRestore, r) {
recorder.restore();
SkRecordNoopSaveRestores(&record);
- assert_type<SkRecords::Save> (r, record, 0);
- assert_type<SkRecords::SaveLayer>(r, record, 1);
- assert_type<SkRecords::Restore> (r, record, 2);
- assert_type<SkRecords::Restore> (r, record, 3);
+ switch (record.count()) {
+ case 4:
+ assert_type<SkRecords::Save> (r, record, 0);
+ assert_type<SkRecords::SaveLayer>(r, record, 1);
+ assert_type<SkRecords::Restore> (r, record, 2);
+ assert_type<SkRecords::Restore> (r, record, 3);
+ break;
+ case 2:
+ assert_type<SkRecords::SaveLayer>(r, record, 0);
+ assert_type<SkRecords::Restore> (r, record, 1);
+ break;
+ case 0:
+ break;
+ default:
+ REPORTER_ASSERT(r, false);
+ }
}
static void assert_savelayer_restore(skiatest::Reporter* r,
« no previous file with comments | « tests/RecordDrawTest.cpp ('k') | tests/RecordPatternTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698