OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/native_theme/native_theme_mac.h" | 5 #include "ui/native_theme/native_theme_mac.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 // Test to ensure any system colors that are looked up by name exist on all Mac | 12 // Test to ensure any system colors that are looked up by name exist on all Mac |
13 // platforms Chrome supports, and that their colorspace and component count is | 13 // platforms Chrome supports, and that their colorspace and component count is |
14 // sane. | 14 // sane. |
15 TEST(NativeThemeMacTest, SystemColorsExist) { | 15 TEST(NativeThemeMacTest, SystemColorsExist) { |
16 NativeTheme* native_theme = NativeTheme::instance(); | 16 NativeTheme* native_theme = NativeThemeMac::instance(); |
17 ASSERT_TRUE(native_theme); | 17 ASSERT_TRUE(native_theme); |
18 for (int i = 0; i < NativeTheme::kColorId_NumColors; ++i) { | 18 for (int i = 0; i < NativeTheme::kColorId_NumColors; ++i) { |
19 // While 0 is a valid color, no system color should be fully transparent. | 19 // While 0 is a valid color, no system color should be fully transparent. |
20 // This is also to probe for CHECKs. | 20 // This is also to probe for CHECKs. |
21 EXPECT_NE( | 21 EXPECT_NE( |
22 static_cast<SkColor>(0), | 22 static_cast<SkColor>(0), |
23 native_theme->GetSystemColor(static_cast<NativeTheme::ColorId>(i))) | 23 native_theme->GetSystemColor(static_cast<NativeTheme::ColorId>(i))) |
24 << "GetSystemColor() unexpectedly gave a fully transparent color."; | 24 << "GetSystemColor() unexpectedly gave a fully transparent color."; |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 // Spot-check some system colours that can't be changed through System | 28 // Spot-check some system colours that can't be changed through System |
29 // Preferences. | 29 // Preferences. |
30 TEST(NativeThemeMacTest, SystemColorSpotChecks) { | 30 TEST(NativeThemeMacTest, SystemColorSpotChecks) { |
31 NativeTheme* native_theme = NativeTheme::instance(); | 31 NativeTheme* native_theme = NativeThemeMac::instance(); |
32 const SkColor kWindowColorCatsMavericks = SkColorSetARGB(255, 232, 232, 232); | 32 const SkColor kWindowColorCatsMavericks = SkColorSetARGB(255, 232, 232, 232); |
33 const SkColor kWindowColorYosemite = SkColorSetARGB(255, 236, 236, 236); | 33 const SkColor kWindowColorYosemite = SkColorSetARGB(255, 236, 236, 236); |
34 SkColor dialogColor = | 34 SkColor dialogColor = |
35 native_theme->GetSystemColor(NativeTheme::kColorId_WindowBackground); | 35 native_theme->GetSystemColor(NativeTheme::kColorId_WindowBackground); |
36 if (base::mac::IsOSYosemiteOrLater()) | 36 if (base::mac::IsOSYosemiteOrLater()) |
37 EXPECT_EQ(dialogColor, kWindowColorYosemite); | 37 EXPECT_EQ(dialogColor, kWindowColorYosemite); |
38 else | 38 else |
39 EXPECT_EQ(dialogColor, kWindowColorCatsMavericks); | 39 EXPECT_EQ(dialogColor, kWindowColorCatsMavericks); |
40 } | 40 } |
41 | 41 |
42 } // namespace ui | 42 } // namespace ui |
OLD | NEW |