OLD | NEW |
---|---|
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/color_transform.h" | 8 #include "ui/gfx/color_transform.h" |
9 #include "ui/gfx/icc_profile.h" | 9 #include "ui/gfx/icc_profile.h" |
10 #include "ui/gfx/test/icc_profiles.h" | 10 #include "ui/gfx/test/icc_profiles.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); | 165 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); |
166 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); | 166 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); |
167 | 167 |
168 // Test a blue color | 168 // Test a blue color |
169 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); | 169 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); |
170 t->transform(&tmp, 1); | 170 t->transform(&tmp, 1); |
171 EXPECT_GT(tmp.z(), tmp.x()); | 171 EXPECT_GT(tmp.z(), tmp.x()); |
172 EXPECT_GT(tmp.z(), tmp.y()); | 172 EXPECT_GT(tmp.z(), tmp.y()); |
173 } | 173 } |
174 | 174 |
175 class MatrixTest : public testing::TestWithParam<ColorSpace::MatrixID> {}; | |
176 | |
177 TEST_P(MatrixTest, checkInvertible) { | |
hubbe
2017/02/02 04:51:37
Add color_space_unittest.cc and add this test ther
ccameron
2017/02/02 17:33:52
It's probably more important to ensure that the ma
hubbe
2017/02/02 18:35:25
I'd prefer to add some tests now, especially since
| |
178 EXPECT_EQ(GetTransferMatrix(GetParam()).matrix().get(3, 3), 1.0f); | |
179 // Check that all transfer matrices are invertable. | |
180 EXPECT_TRUE(GetTransferMatrix(GetParam()).IsInvertible()); | |
181 }; | |
182 | |
183 INSTANTIATE_TEST_CASE_P(ColorSpace, | |
184 MatrixTest, | |
185 testing::ValuesIn(all_matrices)); | |
186 | |
187 class TransferTest : public testing::TestWithParam<ColorSpace::TransferID> {}; | 175 class TransferTest : public testing::TestWithParam<ColorSpace::TransferID> {}; |
188 | 176 |
189 TEST_P(TransferTest, basicTest) { | 177 TEST_P(TransferTest, basicTest) { |
190 for (float x = 0.0f; x <= 1.0f; x += 1.0f / 128.0f) { | 178 for (float x = 0.0f; x <= 1.0f; x += 1.0f / 128.0f) { |
191 float linear = ColorTransform::ToLinearForTesting(GetParam(), x); | 179 float linear = ColorTransform::ToLinearForTesting(GetParam(), x); |
192 float x2 = ColorTransform::FromLinearForTesting(GetParam(), linear); | 180 float x2 = ColorTransform::FromLinearForTesting(GetParam(), linear); |
193 EXPECT_NEAR(x, x2, 0.001f); | 181 EXPECT_NEAR(x, x2, 0.001f); |
194 } | 182 } |
195 } | 183 } |
196 | 184 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 | 250 |
263 INSTANTIATE_TEST_CASE_P( | 251 INSTANTIATE_TEST_CASE_P( |
264 C, | 252 C, |
265 ColorSpaceTest, | 253 ColorSpaceTest, |
266 testing::Combine(testing::ValuesIn(all_primaries), | 254 testing::Combine(testing::ValuesIn(all_primaries), |
267 testing::Values(ColorSpace::TransferID::BT709), | 255 testing::Values(ColorSpace::TransferID::BT709), |
268 testing::ValuesIn(all_matrices), | 256 testing::ValuesIn(all_matrices), |
269 testing::ValuesIn(all_ranges), | 257 testing::ValuesIn(all_ranges), |
270 testing::ValuesIn(intents))); | 258 testing::ValuesIn(intents))); |
271 } // namespace | 259 } // namespace |
OLD | NEW |