This source file includes following definitions.
- UsingCustomTheme
- SetUp
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/themes/theme_service.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
namespace {
const SkColor kThemeToolbarColor = 0xFFCFDDC0;
bool UsingCustomTheme(const ThemeService& theme_service) {
return !theme_service.UsingNativeTheme() &&
!theme_service.UsingDefaultTheme();
}
class ThemeServiceBrowserTest : public ExtensionBrowserTest {
public:
ThemeServiceBrowserTest() {
}
virtual ~ThemeServiceBrowserTest() {
}
virtual void SetUp() OVERRIDE {
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
ExtensionBrowserTest::SetUp();
}
private:
DISALLOW_COPY_AND_ASSIGN(ThemeServiceBrowserTest);
};
IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, PRE_ThemeDataPackInvalid) {
Profile* profile = browser()->profile();
ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile);
EXPECT_FALSE(UsingCustomTheme(*theme_service));
EXPECT_NE(kThemeToolbarColor, theme_service->GetColor(
ThemeProperties::COLOR_TOOLBAR));
EXPECT_EQ(base::FilePath(),
profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename));
InstallExtension(test_data_dir_.AppendASCII("theme"), 1);
EXPECT_TRUE(UsingCustomTheme(*theme_service));
EXPECT_EQ(kThemeToolbarColor, theme_service->GetColor(
ThemeProperties::COLOR_TOOLBAR));
EXPECT_NE(base::FilePath(),
profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename));
profile->GetPrefs()->SetFilePath(
prefs::kCurrentThemePackFilename,
base::FilePath());
}
IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, ThemeDataPackInvalid) {
ThemeService* theme_service = ThemeServiceFactory::GetForProfile(
browser()->profile());
EXPECT_TRUE(UsingCustomTheme(*theme_service));
EXPECT_EQ(kThemeToolbarColor, theme_service->GetColor(
ThemeProperties::COLOR_TOOLBAR));
}
}