OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "ui/gfx/color_space.h" | 7 #include "ui/gfx/color_space.h" |
8 #include "ui/gfx/icc_profile.h" | 8 #include "ui/gfx/icc_profile.h" |
9 #include "ui/gfx/test/icc_profiles.h" | 9 #include "ui/gfx/test/icc_profiles.h" |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 ICCProfile accurate_color_space; | 87 ICCProfile accurate_color_space; |
88 EXPECT_TRUE(accurate.GetColorSpace().GetICCProfile(&accurate_color_space)); | 88 EXPECT_TRUE(accurate.GetColorSpace().GetICCProfile(&accurate_color_space)); |
89 EXPECT_EQ(accurate_color_space, accurate); | 89 EXPECT_EQ(accurate_color_space, accurate); |
90 | 90 |
91 ICCProfile accurate_parametric_color_space; | 91 ICCProfile accurate_parametric_color_space; |
92 EXPECT_TRUE(accurate.GetParametricColorSpace().GetICCProfile( | 92 EXPECT_TRUE(accurate.GetParametricColorSpace().GetICCProfile( |
93 &accurate_parametric_color_space)); | 93 &accurate_parametric_color_space)); |
94 EXPECT_EQ(accurate_parametric_color_space, accurate); | 94 EXPECT_EQ(accurate_parametric_color_space, accurate); |
95 | 95 |
96 // This ICC profile has only an A2B representation. For now, this means that | 96 // This ICC profile has only an A2B representation. We cannot create an |
97 // the parametric representation will be sRGB. We will eventually want to get | 97 // SkColorSpaceXform to A2B only ICC profiles, so this should be marked |
98 // some sense of the gamut. | 98 // as invalid. |
99 ICCProfile a2b = ICCProfileForTestingA2BOnly(); | 99 ICCProfile a2b = ICCProfileForTestingA2BOnly(); |
100 EXPECT_TRUE(a2b.GetColorSpace().IsValid()); | 100 EXPECT_FALSE(a2b.GetColorSpace().IsValid()); |
101 EXPECT_NE(a2b.GetColorSpace(), a2b.GetParametricColorSpace()); | |
102 EXPECT_EQ(ColorSpace::CreateSRGB(), a2b.GetParametricColorSpace()); | |
103 } | 101 } |
104 | 102 |
105 TEST(ICCProfile, GarbageData) { | 103 TEST(ICCProfile, GarbageData) { |
106 std::vector<char> bad_data(10 * 1024); | 104 std::vector<char> bad_data(10 * 1024); |
107 const char* bad_data_string = "deadbeef"; | 105 const char* bad_data_string = "deadbeef"; |
108 for (size_t i = 0; i < bad_data.size(); ++i) | 106 for (size_t i = 0; i < bad_data.size(); ++i) |
109 bad_data[i] = bad_data_string[i % 8]; | 107 bad_data[i] = bad_data_string[i % 8]; |
110 ICCProfile garbage_profile = | 108 ICCProfile garbage_profile = |
111 ICCProfile::FromData(bad_data.data(), bad_data.size()); | 109 ICCProfile::FromData(bad_data.data(), bad_data.size()); |
112 EXPECT_FALSE(garbage_profile.IsValid()); | 110 EXPECT_FALSE(garbage_profile.IsValid()); |
113 EXPECT_FALSE(garbage_profile.GetColorSpace().IsValid()); | 111 EXPECT_FALSE(garbage_profile.GetColorSpace().IsValid()); |
114 EXPECT_FALSE(garbage_profile.GetParametricColorSpace().IsValid()); | 112 EXPECT_FALSE(garbage_profile.GetParametricColorSpace().IsValid()); |
115 | 113 |
116 ICCProfile default_ctor_profile; | 114 ICCProfile default_ctor_profile; |
117 EXPECT_FALSE(default_ctor_profile.IsValid()); | 115 EXPECT_FALSE(default_ctor_profile.IsValid()); |
118 EXPECT_FALSE(default_ctor_profile.GetColorSpace().IsValid()); | 116 EXPECT_FALSE(default_ctor_profile.GetColorSpace().IsValid()); |
119 EXPECT_FALSE(default_ctor_profile.GetParametricColorSpace().IsValid()); | 117 EXPECT_FALSE(default_ctor_profile.GetParametricColorSpace().IsValid()); |
120 } | 118 } |
121 | 119 |
122 } // namespace gfx | 120 } // namespace gfx |
OLD | NEW |