| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/extensions/component_loader.h" | 8 #include "chrome/browser/extensions/component_loader.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 DISALLOW_COPY_AND_ASSIGN(ThemeServiceBrowserTest); | 38 DISALLOW_COPY_AND_ASSIGN(ThemeServiceBrowserTest); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Test that the theme is recreated from the extension when the data pack is | 41 // Test that the theme is recreated from the extension when the data pack is |
| 42 // unavailable or invalid (such as when the theme pack version is incremented). | 42 // unavailable or invalid (such as when the theme pack version is incremented). |
| 43 // The PRE_ part of the test installs the theme and changes where Chrome looks | 43 // The PRE_ part of the test installs the theme and changes where Chrome looks |
| 44 // for the theme data pack to make sure that Chrome does not find it. | 44 // for the theme data pack to make sure that Chrome does not find it. |
| 45 IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, PRE_ThemeDataPackInvalid) { | 45 IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, PRE_ThemeDataPackInvalid) { |
| 46 Profile* profile = browser()->profile(); | 46 Profile* profile = browser()->profile(); |
| 47 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 47 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
| 48 const ui::ThemeProvider& theme_provider = |
| 49 ThemeService::GetThemeProviderForProfile(profile); |
| 48 | 50 |
| 49 // Test initial state. | 51 // Test initial state. |
| 50 EXPECT_FALSE(UsingCustomTheme(*theme_service)); | 52 EXPECT_FALSE(UsingCustomTheme(*theme_service)); |
| 51 EXPECT_NE(kThemeToolbarColor, theme_service->GetColor( | 53 EXPECT_NE(kThemeToolbarColor, |
| 52 ThemeProperties::COLOR_TOOLBAR)); | 54 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 53 EXPECT_EQ(base::FilePath(), | 55 EXPECT_EQ(base::FilePath(), |
| 54 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); | 56 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); |
| 55 | 57 |
| 56 InstallExtension(test_data_dir_.AppendASCII("theme"), 1); | 58 InstallExtension(test_data_dir_.AppendASCII("theme"), 1); |
| 57 | 59 |
| 58 // Check that the theme was installed. | 60 // Check that the theme was installed. |
| 59 EXPECT_TRUE(UsingCustomTheme(*theme_service)); | 61 EXPECT_TRUE(UsingCustomTheme(*theme_service)); |
| 60 EXPECT_EQ(kThemeToolbarColor, theme_service->GetColor( | 62 EXPECT_EQ(kThemeToolbarColor, |
| 61 ThemeProperties::COLOR_TOOLBAR)); | 63 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 62 EXPECT_NE(base::FilePath(), | 64 EXPECT_NE(base::FilePath(), |
| 63 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); | 65 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); |
| 64 | 66 |
| 65 // Change the theme data pack path to an invalid location such that second | 67 // Change the theme data pack path to an invalid location such that second |
| 66 // part of the test is forced to recreate the theme pack when the theme | 68 // part of the test is forced to recreate the theme pack when the theme |
| 67 // service is initialized. | 69 // service is initialized. |
| 68 profile->GetPrefs()->SetFilePath( | 70 profile->GetPrefs()->SetFilePath( |
| 69 prefs::kCurrentThemePackFilename, | 71 prefs::kCurrentThemePackFilename, |
| 70 base::FilePath()); | 72 base::FilePath()); |
| 71 } | 73 } |
| 72 | 74 |
| 73 IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, ThemeDataPackInvalid) { | 75 IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, ThemeDataPackInvalid) { |
| 74 ThemeService* theme_service = ThemeServiceFactory::GetForProfile( | 76 ThemeService* theme_service = ThemeServiceFactory::GetForProfile( |
| 75 browser()->profile()); | 77 browser()->profile()); |
| 78 const ui::ThemeProvider& theme_provider = |
| 79 ThemeService::GetThemeProviderForProfile(browser()->profile()); |
| 76 EXPECT_TRUE(UsingCustomTheme(*theme_service)); | 80 EXPECT_TRUE(UsingCustomTheme(*theme_service)); |
| 77 EXPECT_EQ(kThemeToolbarColor, theme_service->GetColor( | 81 EXPECT_EQ(kThemeToolbarColor, |
| 78 ThemeProperties::COLOR_TOOLBAR)); | 82 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 79 } | 83 } |
| 80 | 84 |
| 81 } // namespace | 85 } // namespace |
| OLD | NEW |