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

Unified Diff: tests/ValueTest.cpp

Issue 1585813004: SkValue: SkXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-01-15 (Friday) 14:43:14 EST Created 4 years, 11 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
« src/core/SkValue.cpp ('K') | « src/effects/SkPixelXorXfermode.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ValueTest.cpp
diff --git a/tests/ValueTest.cpp b/tests/ValueTest.cpp
index 220ef2f9aeceb43d318a2c2f3c250a837c9c25d4..931c26d49f4cb2fba3dbf1ecfea7b55d9e2a51dc 100644
--- a/tests/ValueTest.cpp
+++ b/tests/ValueTest.cpp
@@ -5,5 +5,43 @@
* found in the LICENSE file.
*/
-#include "Test.h"
#include "SkValue.h"
+#include "Test.h"
+
+static const SkValue::Type example_type = SkValue::Type(0x80000001);
+
+enum { kExampleS32, kExampleF32, kExampleU32, kExampleObject};
+
+#define EXAMPLES(FN) \
mtklein 2016/01/15 20:42:20 Let's expand this out?
+ FN(kExampleS32, S32, s32, -123) \
+ FN(kExampleF32, F32, f32, 0.5f) \
+ FN(kExampleU32, U32, u32, 1234) \
+
+static SkValue make_example(skiatest::Reporter* r, int level = 4) {
+ auto value = SkValue::Object(example_type);
+ value.set(kExampleU32, SkValue::FromU32(1000));
+
+ #define FN(KEY, FNAME, MNAME, VALUE) \
+ value.set(KEY, SkValue::From##FNAME(VALUE));
+ EXAMPLES(FN)
+ #undef FN
+ if (level > 0) {
+ value.set(kExampleObject, make_example(r, 0));
+ value.set(kExampleObject, make_example(r, level - 1)); // replace
+ }
+ return value;
+}
+
+DEF_TEST(Value, r) {
+ SkValue val = make_example(r);
+ REPORTER_ASSERT(r, example_type == val.type());
+ val.set(4321, SkValue());
+ SkValue valCopy = val;
+ REPORTER_ASSERT(r, example_type == valCopy.type());
+ #define FN(KEY, FNAME, MNAME, VALUE) { \
+ const SkValue* v = val.get(KEY); \
+ REPORTER_ASSERT(r, v && VALUE == v->MNAME()); \
+ }
+ EXAMPLES(FN)
+ #undef FN
+}
« src/core/SkValue.cpp ('K') | « src/effects/SkPixelXorXfermode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698