OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/base/testing_browser_process_test.h" | |
12 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
13 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 // Converts a GdkColor to a SkColor. | 17 // Converts a GdkColor to a SkColor. |
19 SkColor GdkToSkColor(GdkColor* color) { | 18 SkColor GdkToSkColor(GdkColor* color) { |
20 return SkColorSetRGB(color->red >> 8, | 19 return SkColorSetRGB(color->red >> 8, |
21 color->green >> 8, | 20 color->green >> 8, |
22 color->blue >> 8); | 21 color->blue >> 8); |
23 } | 22 } |
24 | 23 |
25 } // namespace | 24 } // namespace |
26 | 25 |
27 class GtkThemeServiceTest : public TestingBrowserProcessTest { | 26 class GtkThemeServiceTest : public testing::Test { |
28 public: | 27 public: |
29 GtkThemeServiceTest() : provider_(NULL) {} | 28 GtkThemeServiceTest() : provider_(NULL) {} |
30 | 29 |
31 void SetUseGtkTheme(bool use_gtk_theme) { | 30 void SetUseGtkTheme(bool use_gtk_theme) { |
32 profile_.GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, use_gtk_theme); | 31 profile_.GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, use_gtk_theme); |
33 } | 32 } |
34 | 33 |
35 void BuildProvider() { | 34 void BuildProvider() { |
36 provider_ = GtkThemeService::GetFrom(&profile_); | 35 provider_ = GtkThemeService::GetFrom(&profile_); |
37 } | 36 } |
(...skipping 24 matching lines...) Expand all Loading... |
62 // large, implied global state, it would take some IN_PROCESS_BROWSER_TESTS | 61 // large, implied global state, it would take some IN_PROCESS_BROWSER_TESTS |
63 // to write an equivalent of DefaultValues above in a way that wouldn't make | 62 // to write an equivalent of DefaultValues above in a way that wouldn't make |
64 // other tests flaky. kColorTabText is the only simple path where there's no | 63 // other tests flaky. kColorTabText is the only simple path where there's no |
65 // weird calculations for edge cases so use that as a simple test. | 64 // weird calculations for edge cases so use that as a simple test. |
66 GtkWidget* fake_label = provider_->fake_label(); | 65 GtkWidget* fake_label = provider_->fake_label(); |
67 GtkStyle* label_style = gtk_rc_get_style(fake_label); | 66 GtkStyle* label_style = gtk_rc_get_style(fake_label); |
68 GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; | 67 GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; |
69 EXPECT_EQ(provider_->GetColor(ThemeService::COLOR_TAB_TEXT), | 68 EXPECT_EQ(provider_->GetColor(ThemeService::COLOR_TAB_TEXT), |
70 GdkToSkColor(&label_color)); | 69 GdkToSkColor(&label_color)); |
71 } | 70 } |
OLD | NEW |