| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/themes/theme_properties.h" | 9 #include "chrome/browser/themes/theme_properties.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/gfx/skia_utils_gtk.h" | 16 #include "ui/gfx/skia_utils_gtk.h" |
| 16 | 17 |
| 17 class GtkThemeServiceTest : public testing::Test { | 18 class GtkThemeServiceTest : public testing::Test { |
| 18 public: | 19 public: |
| 19 GtkThemeServiceTest() : provider_(NULL) {} | 20 GtkThemeServiceTest() : provider_(NULL) {} |
| 20 | 21 |
| 21 void SetUseGtkTheme(bool use_gtk_theme) { | 22 void SetUseGtkTheme(bool use_gtk_theme) { |
| 22 profile_.GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, use_gtk_theme); | 23 profile_.GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, use_gtk_theme); |
| 23 } | 24 } |
| 24 | 25 |
| 25 void BuildProvider() { | 26 void BuildProvider() { |
| 26 provider_ = GtkThemeService::GetFrom(&profile_); | 27 provider_ = GtkThemeService::GetFrom(&profile_); |
| 27 } | 28 } |
| 28 | 29 |
| 29 protected: | 30 protected: |
| 31 content::TestBrowserThreadBundle thread_bundle_; |
| 30 TestingProfile profile_; | 32 TestingProfile profile_; |
| 31 | 33 |
| 32 GtkThemeService* provider_; | 34 GtkThemeService* provider_; |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 TEST_F(GtkThemeServiceTest, DefaultValues) { | 37 TEST_F(GtkThemeServiceTest, DefaultValues) { |
| 36 SetUseGtkTheme(false); | 38 SetUseGtkTheme(false); |
| 37 BuildProvider(); | 39 BuildProvider(); |
| 38 | 40 |
| 39 // Test that we get the default theme colors back when in normal mode. | 41 // Test that we get the default theme colors back when in normal mode. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 // large, implied global state, it would take some IN_PROCESS_BROWSER_TESTS | 54 // large, implied global state, it would take some IN_PROCESS_BROWSER_TESTS |
| 53 // to write an equivalent of DefaultValues above in a way that wouldn't make | 55 // to write an equivalent of DefaultValues above in a way that wouldn't make |
| 54 // other tests flaky. kColorTabText is the only simple path where there's no | 56 // other tests flaky. kColorTabText is the only simple path where there's no |
| 55 // weird calculations for edge cases so use that as a simple test. | 57 // weird calculations for edge cases so use that as a simple test. |
| 56 GtkWidget* fake_label = provider_->fake_label(); | 58 GtkWidget* fake_label = provider_->fake_label(); |
| 57 GtkStyle* label_style = gtk_rc_get_style(fake_label); | 59 GtkStyle* label_style = gtk_rc_get_style(fake_label); |
| 58 GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; | 60 GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; |
| 59 EXPECT_EQ(provider_->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 61 EXPECT_EQ(provider_->GetColor(ThemeProperties::COLOR_TAB_TEXT), |
| 60 gfx::GdkColorToSkColor(label_color)); | 62 gfx::GdkColorToSkColor(label_color)); |
| 61 } | 63 } |
| OLD | NEW |