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

Side by Side Diff: ui/gfx/icc_profile_unittest.cc

Issue 2660393002: Use gfx::ColorSpace instead of SkColorSpace in Blink (Closed)
Patch Set: Rebase (again) Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/icc_profile.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 namespace gfx { 11 namespace gfx {
12 12
13 TEST(ICCProfile, Conversions) { 13 TEST(ICCProfile, Conversions) {
14 ICCProfile icc_profile = ICCProfileForTestingColorSpin(); 14 ICCProfile icc_profile = ICCProfileForTestingColorSpin();
15 ColorSpace color_space_from_icc_profile = icc_profile.GetColorSpace(); 15 ColorSpace color_space_from_icc_profile = icc_profile.GetColorSpace();
16 16
17 ICCProfile icc_profile_from_color_space = 17 ICCProfile icc_profile_from_color_space =
18 ICCProfile::FromColorSpace(color_space_from_icc_profile); 18 ICCProfile::FromColorSpace(color_space_from_icc_profile);
19 EXPECT_TRUE(icc_profile == icc_profile_from_color_space); 19 EXPECT_TRUE(icc_profile == icc_profile_from_color_space);
20
21 sk_sp<SkColorSpace> sk_color_space_from_color_space =
22 color_space_from_icc_profile.ToSkColorSpace();
23
24 ColorSpace color_space_from_sk_color_space =
25 ColorSpace::FromSkColorSpace(sk_color_space_from_color_space);
26 EXPECT_TRUE(color_space_from_icc_profile == color_space_from_sk_color_space);
27
28 ICCProfile icc_profile_from_color_space_from_sk_color_space =
29 ICCProfile::FromColorSpace(color_space_from_sk_color_space);
30 EXPECT_TRUE(icc_profile == icc_profile_from_color_space_from_sk_color_space);
31 } 20 }
32 21
33 TEST(ICCProfile, SRGB) { 22 TEST(ICCProfile, SRGB) {
34 ColorSpace color_space = ColorSpace::CreateSRGB(); 23 ColorSpace color_space = ColorSpace::CreateSRGB();
35 sk_sp<SkColorSpace> sk_color_space = 24 sk_sp<SkColorSpace> sk_color_space =
36 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); 25 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
37 26
38 ColorSpace color_space_from_sk_color_space = 27 // These should be the same pointer, not just equal.
39 ColorSpace::FromSkColorSpace(sk_color_space); 28 EXPECT_EQ(color_space.ToSkColorSpace().get(), sk_color_space.get());
40 EXPECT_TRUE(color_space == color_space_from_sk_color_space);
41
42 sk_sp<SkColorSpace> sk_color_space_from_color_space =
43 color_space.ToSkColorSpace();
44 EXPECT_TRUE(SkColorSpace::Equals(sk_color_space.get(),
45 sk_color_space_from_color_space.get()));
46 } 29 }
47 30
48 TEST(ICCProfile, Equality) { 31 TEST(ICCProfile, Equality) {
49 ICCProfile spin_profile = ICCProfileForTestingColorSpin(); 32 ICCProfile spin_profile = ICCProfileForTestingColorSpin();
50 ICCProfile adobe_profile = ICCProfileForTestingAdobeRGB(); 33 ICCProfile adobe_profile = ICCProfileForTestingAdobeRGB();
51 EXPECT_TRUE(spin_profile == spin_profile); 34 EXPECT_TRUE(spin_profile == spin_profile);
52 EXPECT_FALSE(spin_profile != spin_profile); 35 EXPECT_FALSE(spin_profile != spin_profile);
53 EXPECT_FALSE(spin_profile == adobe_profile); 36 EXPECT_FALSE(spin_profile == adobe_profile);
54 EXPECT_TRUE(spin_profile != adobe_profile); 37 EXPECT_TRUE(spin_profile != adobe_profile);
55 38
56 gfx::ColorSpace spin_space = spin_profile.GetColorSpace(); 39 gfx::ColorSpace spin_space = spin_profile.GetColorSpace();
57 gfx::ColorSpace adobe_space = adobe_profile.GetColorSpace(); 40 gfx::ColorSpace adobe_space = adobe_profile.GetColorSpace();
58 EXPECT_TRUE(spin_space == spin_space); 41 EXPECT_TRUE(spin_space == spin_space);
59 EXPECT_FALSE(spin_space != spin_space); 42 EXPECT_FALSE(spin_space != spin_space);
60 EXPECT_FALSE(spin_space == adobe_space); 43 EXPECT_FALSE(spin_space == adobe_space);
61 EXPECT_TRUE(spin_space != adobe_space); 44 EXPECT_TRUE(spin_space != adobe_space);
62 45
63 EXPECT_TRUE(spin_profile == ICCProfile::FromColorSpace(spin_space)); 46 EXPECT_TRUE(spin_profile == ICCProfile::FromColorSpace(spin_space));
64 EXPECT_FALSE(spin_profile != ICCProfile::FromColorSpace(spin_space)); 47 EXPECT_FALSE(spin_profile != ICCProfile::FromColorSpace(spin_space));
65 EXPECT_FALSE(spin_profile == ICCProfile::FromColorSpace(adobe_space)); 48 EXPECT_FALSE(spin_profile == ICCProfile::FromColorSpace(adobe_space));
66 EXPECT_TRUE(spin_profile != ICCProfile::FromColorSpace(adobe_space)); 49 EXPECT_TRUE(spin_profile != ICCProfile::FromColorSpace(adobe_space));
50
51 EXPECT_TRUE(!!spin_space.ToSkColorSpace());
52 EXPECT_TRUE(!!adobe_space.ToSkColorSpace());
53 EXPECT_FALSE(SkColorSpace::Equals(
54 spin_space.ToSkColorSpace().get(),
55 adobe_space.ToSkColorSpace().get()));
67 } 56 }
68 57
69 } // namespace gfx 58 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/icc_profile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698