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

Unified Diff: tests/RecordTest.cpp

Issue 1461663003: Add SkRecord::defrag(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify Created 5 years, 1 month 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 | « src/core/SkRecordOpts.cpp ('k') | tests/RecordTestUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordTest.cpp
diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp
index 9e02c882dbc5e74e2d994bf1c01e2560cd986501..e613b425fdc7f607d580c053bc7b028819d5c8fb 100644
--- a/tests/RecordTest.cpp
+++ b/tests/RecordTest.cpp
@@ -5,13 +5,14 @@
* found in the LICENSE file.
*/
-#include "Test.h"
-
+#include "RecordTestUtils.h"
#include "SkBitmap.h"
#include "SkImageInfo.h"
-#include "SkShader.h"
#include "SkRecord.h"
#include "SkRecords.h"
+#include "SkShader.h"
+#include "Test.h"
+
// Sums the area of any DrawRect command it sees.
class AreaSummer {
@@ -76,6 +77,25 @@ DEF_TEST(Record, r) {
REPORTER_ASSERT(r, summer.area() == 500);
}
+DEF_TEST(Record_defrag, r) {
+ SkRecord record;
+ APPEND(record, SkRecords::Save);
+ APPEND(record, SkRecords::ClipRect);
+ APPEND(record, SkRecords::NoOp);
+ APPEND(record, SkRecords::DrawRect);
+ APPEND(record, SkRecords::NoOp);
+ APPEND(record, SkRecords::NoOp);
+ APPEND(record, SkRecords::Restore);
+ REPORTER_ASSERT(r, record.count() == 7);
+
+ record.defrag();
+ REPORTER_ASSERT(r, record.count() == 4);
+ assert_type<SkRecords::Save >(r, record, 0);
+ assert_type<SkRecords::ClipRect>(r, record, 1);
+ assert_type<SkRecords::DrawRect>(r, record, 2);
+ assert_type<SkRecords::Restore >(r, record, 3);
+}
+
#undef APPEND
template <typename T>
« no previous file with comments | « src/core/SkRecordOpts.cpp ('k') | tests/RecordTestUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698