This source file includes following definitions.
- SetUseGtkTheme
- BuildProvider
- TEST_F
- TEST_F
#include <gtk/gtk.h>
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "grit/theme_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/skia_utils_gtk.h"
class GtkThemeServiceTest : public testing::Test {
public:
GtkThemeServiceTest() : provider_(NULL) {}
void SetUseGtkTheme(bool use_gtk_theme) {
profile_.GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, use_gtk_theme);
}
void BuildProvider() {
provider_ = GtkThemeService::GetFrom(&profile_);
}
protected:
TestingProfile profile_;
GtkThemeService* provider_;
};
TEST_F(GtkThemeServiceTest, DefaultValues) {
SetUseGtkTheme(false);
BuildProvider();
for (int i = ThemeProperties::COLOR_FRAME;
i <= ThemeProperties::COLOR_BUTTON_BACKGROUND; ++i) {
EXPECT_EQ(provider_->GetColor(i), ThemeProperties::GetDefaultColor(i))
<< "Wrong default color for " << i;
}
}
TEST_F(GtkThemeServiceTest, UsingGtkValues) {
SetUseGtkTheme(true);
BuildProvider();
GtkWidget* fake_label = provider_->fake_label();
GtkStyle* label_style = gtk_rc_get_style(fake_label);
GdkColor label_color = label_style->fg[GTK_STATE_NORMAL];
EXPECT_EQ(provider_->GetColor(ThemeProperties::COLOR_TAB_TEXT),
gfx::GdkColorToSkColor(label_color));
}