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

Unified Diff: tests/ColorSpaceTest.cpp

Issue 2085653003: Enable flattening and unflattening of SkColorSpace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit tests Created 4 years, 6 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/SkMatrix44.cpp ('k') | tests/ImageIsOpaqueTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ColorSpaceTest.cpp
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp
index 4b39ab02c66e0e996e06cb129e08c66e7805b7d7..853bdceb4f88dbd6ef397d0b57031fa0a665814a 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -165,3 +165,41 @@ DEF_TEST(ColorSpace_Named, r) {
SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType);
REPORTER_ASSERT(r, info.gammaCloseToSRGB());
}
+
+static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNamed) {
+ sk_sp<SkData> data = space->serialize();
+ sk_sp<SkColorSpace> newSpace = SkColorSpace::Deserialize(data->data(), data->size());
+
+ if (isNamed) {
+ REPORTER_ASSERT(r, space == newSpace.get());
+ } else {
+ REPORTER_ASSERT(r, space->gammaNamed() == newSpace->gammaNamed());
+
+ REPORTER_ASSERT(r, space->xyz().getFloat(0, 0) == newSpace->xyz().getFloat(0, 0));
+ REPORTER_ASSERT(r, space->xyz().getFloat(0, 1) == newSpace->xyz().getFloat(0, 1));
+ REPORTER_ASSERT(r, space->xyz().getFloat(0, 2) == newSpace->xyz().getFloat(0, 2));
+ REPORTER_ASSERT(r, space->xyz().getFloat(0, 3) == newSpace->xyz().getFloat(0, 3));
+ REPORTER_ASSERT(r, space->xyz().getFloat(1, 0) == newSpace->xyz().getFloat(1, 0));
+ REPORTER_ASSERT(r, space->xyz().getFloat(1, 1) == newSpace->xyz().getFloat(1, 1));
+ REPORTER_ASSERT(r, space->xyz().getFloat(1, 2) == newSpace->xyz().getFloat(1, 2));
+ REPORTER_ASSERT(r, space->xyz().getFloat(1, 3) == newSpace->xyz().getFloat(1, 3));
+ REPORTER_ASSERT(r, space->xyz().getFloat(2, 0) == newSpace->xyz().getFloat(2, 0));
+ REPORTER_ASSERT(r, space->xyz().getFloat(2, 1) == newSpace->xyz().getFloat(2, 1));
+ REPORTER_ASSERT(r, space->xyz().getFloat(2, 2) == newSpace->xyz().getFloat(2, 2));
+ REPORTER_ASSERT(r, space->xyz().getFloat(2, 3) == newSpace->xyz().getFloat(2, 3));
+ REPORTER_ASSERT(r, space->xyz().getFloat(3, 0) == newSpace->xyz().getFloat(3, 0));
+ REPORTER_ASSERT(r, space->xyz().getFloat(3, 1) == newSpace->xyz().getFloat(3, 1));
+ REPORTER_ASSERT(r, space->xyz().getFloat(3, 2) == newSpace->xyz().getFloat(3, 2));
+ REPORTER_ASSERT(r, space->xyz().getFloat(3, 3) == newSpace->xyz().getFloat(3, 3));
+ }
+}
+
+DEF_TEST(ColorSpace_Serialize, r) {
+ test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), true);
+ test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get(), true);
+
+ sk_sp<SkData> monitorData = SkData::MakeFromFileName(
+ GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str());
+ test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false);
+}
+
« no previous file with comments | « src/core/SkMatrix44.cpp ('k') | tests/ImageIsOpaqueTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698