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