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

Unified Diff: tests/SkLiteDLTest.cpp

Issue 2213333002: SkLite* (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: annoying... Created 4 years, 4 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 | « src/core/SkLiteRecorder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SkLiteDLTest.cpp
diff --git a/tests/SkLiteDLTest.cpp b/tests/SkLiteDLTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb6ba987088434528085aa762111bd19c66208be
--- /dev/null
+++ b/tests/SkLiteDLTest.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+#include "SkLiteDL.h"
+#include "SkLiteRecorder.h"
+
+#if 0 // This test doesn't make sense when run in a threaded environment. It tests global state.
+DEF_TEST(SkLiteDL_freelisting, r) {
+ // TODO: byte and count limit tests
+ sk_sp<SkLiteDL> sp1 = SkLiteDL::New({1,1,10,10}),
+ sp2 = SkLiteDL::New({2,2,20,20});
+
+ SkLiteDL* p1 = sp1.get();
+ SkLiteDL* p2 = sp2.get();
+ REPORTER_ASSERT(r, p1 != p2);
+ REPORTER_ASSERT(r, p1->getBounds().left() == 1);
+ REPORTER_ASSERT(r, p2->getBounds().left() == 2);
+
+ sp2.reset();
+
+ sk_sp<SkLiteDL> sp3 = SkLiteDL::New({3,3,30,30});
+ SkLiteDL* p3 = sp3.get();
+ REPORTER_ASSERT(r, p1 != p3);
+ REPORTER_ASSERT(r, p2 == p3);
+ REPORTER_ASSERT(r, p1->getBounds().left() == 1);
+ REPORTER_ASSERT(r, p3->getBounds().left() == 3);
+
+ sp3.reset();
+ sp1.reset();
+
+ sk_sp<SkLiteDL> sp4 = SkLiteDL::New({4,4,40,40});
+ SkLiteDL* p4 = sp4.get();
+ REPORTER_ASSERT(r, p4 == p1); // Checks that we operate in stack order. Nice, not essential.
+ REPORTER_ASSERT(r, p4->getBounds().left() == 4);
+}
+#endif
+
+DEF_TEST(SkLiteDL_basics, r) {
+ sk_sp<SkLiteDL> p { SkLiteDL::New({2,2,3,3}) };
+
+ p->save();
+ p->clipRect(SkRect{2,3,4,5}, SkRegion::kIntersect_Op, true);
+ p->drawRect(SkRect{0,0,9,9}, SkPaint{});
+ p->restore();
+}
+
+DEF_TEST(SkLiteRecorder, r) {
+ sk_sp<SkLiteDL> p { SkLiteDL::New({2,2,3,3}) };
+
+ SkLiteRecorder rec;
+ SkCanvas* c = &rec;
+
+ rec.reset(p.get());
+
+ c->save();
+ c->clipRect(SkRect{2,3,4,5}, SkRegion::kIntersect_Op, true);
+ c->drawRect(SkRect{0,0,9,9}, SkPaint{});
+ c->restore();
+}
« no previous file with comments | « src/core/SkLiteRecorder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698