Index: tests/ValueTest.cpp |
diff --git a/tests/ValueTest.cpp b/tests/ValueTest.cpp |
index 0569a94bb4e1d59d679c40f03b9b213aeac0bba8..129ae42d86473de11305fed6fa53f1d3957d29b6 100644 |
--- a/tests/ValueTest.cpp |
+++ b/tests/ValueTest.cpp |
@@ -5,7 +5,9 @@ |
* found in the LICENSE file. |
*/ |
+#include "Resources.h" |
#include "SkData.h" |
+#include "SkImage.h" |
#include "SkMatrix.h" |
#include "SkToFromValue.h" |
#include "Test.h" |
@@ -109,3 +111,21 @@ DEF_TEST(Value_Matrix, r) { |
REPORTER_ASSERT(r, SkFromValue(val, &dst)); |
REPORTER_ASSERT(r, dst == m); |
} |
+ |
+DEF_TEST(Value_Image, r) { |
+ SkAutoTUnref<SkImage> img1(GetResourceAsImage("mandrill_512.png")); |
+ if (!img1) { |
+ return; |
+ } |
+ auto val = SkToValue((const SkImage*)img1); |
+ SkAutoTUnref<SkImage> img2; |
+ REPORTER_ASSERT(r, SkFromValue(val, &img2)); |
+ if (!img2) { |
+ return; |
+ } |
+ SkAutoTUnref<SkData> data1(img1->refEncoded()); |
+ SkAutoTUnref<SkData> data2(img2->refEncoded()); |
+ REPORTER_ASSERT(r, data1); |
+ REPORTER_ASSERT(r, data2); |
+ REPORTER_ASSERT(r, data1.get() == data2.get()); |
+} |