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

Unified Diff: tests/FlattenDrawableTest.cpp

Issue 1922853003: Do not globally register drawables in test code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/FlattenDrawableTest.cpp
diff --git a/tests/FlattenDrawableTest.cpp b/tests/FlattenDrawableTest.cpp
index dd06b410b23e168fbef305ce5af9433a4ba3ccb3..8285cb7beaebe1bdc41d20383cf01bb8f03aac11 100644
--- a/tests/FlattenDrawableTest.cpp
+++ b/tests/FlattenDrawableTest.cpp
@@ -79,6 +79,8 @@ public:
const SkPaint& paint() const { return fPaint; }
+ const char* getTypeName() const override { return "PaintDrawable"; }
+
protected:
SkRect onGetBounds() override { return SkRect::MakeEmpty(); }
void onDraw(SkCanvas*) override {}
@@ -124,6 +126,8 @@ public:
IntDrawable* intDrawable() const { return fIntDrawable; }
PaintDrawable* paintDrawable() const { return fPaintDrawable; }
+ const char* getTypeName() const override { return "CompoundDrawable"; }
+
protected:
SkRect onGetBounds() override { return SkRect::MakeEmpty(); }
void onDraw(SkCanvas*) override {}
@@ -181,6 +185,8 @@ public:
IntDrawable* intDrawable() const { return fIntDrawable; }
SkDrawable* drawable() const { return fDrawable; }
+ const char* getTypeName() const override { return "RootDrawable"; }
+
protected:
SkRect onGetBounds() override { return SkRect::MakeEmpty(); }
void onDraw(SkCanvas*) override {}
@@ -191,21 +197,14 @@ private:
SkAutoTUnref<SkDrawable> fDrawable;
};
-static void register_test_drawables() {
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(IntDrawable)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(PaintDrawable)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(CompoundDrawable)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(RootDrawable)
-}
-
-static void register_test_drawables_once() {
- static SkOnce once;
- once(register_test_drawables);
+static void register_test_drawables(SkReadBuffer& buffer) {
+ buffer.setCustomFactory(SkString("IntDrawable"), IntDrawable::CreateProc);
+ buffer.setCustomFactory(SkString("PaintDrawable"), PaintDrawable::CreateProc);
+ buffer.setCustomFactory(SkString("CompoundDrawable"), CompoundDrawable::CreateProc);
+ buffer.setCustomFactory(SkString("RootDrawable"), RootDrawable::CreateProc);
}
DEF_TEST(FlattenDrawable, r) {
- register_test_drawables_once();
-
// Create and serialize the test drawable
SkAutoTUnref<SkDrawable> drawable(new IntDrawable(1, 2, 3, 4));
SkPaint paint;
@@ -218,6 +217,7 @@ DEF_TEST(FlattenDrawable, r) {
sk_sp<SkData> data = SkData::MakeUninitialized(writeBuffer.bytesWritten());
writeBuffer.writeToMemory(data->writable_data());
SkReadBuffer readBuffer(data->data(), data->size());
+ register_test_drawables(readBuffer);
// Deserialize and verify the drawable
SkAutoTUnref<SkDrawable> out((SkDrawable*)
@@ -255,8 +255,6 @@ static sk_sp<SkFlattenable> custom_create_proc(SkReadBuffer& buffer) {
}
DEF_TEST(FlattenCustomDrawable, r) {
mtklein 2016/04/26 15:17:24 Does this make this test moot?
msarett 2016/04/26 15:18:54 Yes... I'll delete this.
- // No need to register the drawables since we will be using a custom proc.
-
// Create and serialize the test drawable
SkAutoTUnref<SkDrawable> drawable(new IntDrawable(1, 2, 3, 4));
SkWriteBuffer writeBuffer;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698