| 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/macros.h" | 7 #include "base/macros.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); | 57 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); |
| 58 | 58 |
| 59 InstallExtension(test_data_dir_.AppendASCII("theme"), 1); | 59 InstallExtension(test_data_dir_.AppendASCII("theme"), 1); |
| 60 | 60 |
| 61 // Check that the theme was installed. | 61 // Check that the theme was installed. |
| 62 EXPECT_TRUE(UsingCustomTheme(*theme_service)); | 62 EXPECT_TRUE(UsingCustomTheme(*theme_service)); |
| 63 EXPECT_EQ(kThemeToolbarColor, | 63 EXPECT_EQ(kThemeToolbarColor, |
| 64 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); | 64 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 65 EXPECT_NE(base::FilePath(), | 65 EXPECT_NE(base::FilePath(), |
| 66 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); | 66 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); |
| 67 // Add a vestigial .pak file that should be removed when the new one is |
| 68 // created. |
| 69 // TODO(estade): remove when vestigial .pak file deletion is removed. |
| 70 EXPECT_EQ( |
| 71 1, base::WriteFile(profile->GetPrefs() |
| 72 ->GetFilePath(prefs::kCurrentThemePackFilename) |
| 73 .AppendASCII("Cached Theme Material Design.pak"), |
| 74 "a", 1)); |
| 67 | 75 |
| 68 // Change the theme data pack path to an invalid location such that second | 76 // Change the theme data pack path to an invalid location such that second |
| 69 // part of the test is forced to recreate the theme pack when the theme | 77 // part of the test is forced to recreate the theme pack when the theme |
| 70 // service is initialized. | 78 // service is initialized. |
| 71 profile->GetPrefs()->SetFilePath( | 79 profile->GetPrefs()->SetFilePath( |
| 72 prefs::kCurrentThemePackFilename, | 80 prefs::kCurrentThemePackFilename, |
| 73 base::FilePath()); | 81 base::FilePath()); |
| 74 } | 82 } |
| 75 | 83 |
| 76 IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, ThemeDataPackInvalid) { | 84 IN_PROC_BROWSER_TEST_F(ThemeServiceBrowserTest, ThemeDataPackInvalid) { |
| 77 ThemeService* theme_service = ThemeServiceFactory::GetForProfile( | 85 ThemeService* theme_service = ThemeServiceFactory::GetForProfile( |
| 78 browser()->profile()); | 86 browser()->profile()); |
| 79 const ui::ThemeProvider& theme_provider = | 87 const ui::ThemeProvider& theme_provider = |
| 80 ThemeService::GetThemeProviderForProfile(browser()->profile()); | 88 ThemeService::GetThemeProviderForProfile(browser()->profile()); |
| 81 EXPECT_TRUE(UsingCustomTheme(*theme_service)); | 89 EXPECT_TRUE(UsingCustomTheme(*theme_service)); |
| 82 EXPECT_EQ(kThemeToolbarColor, | 90 EXPECT_EQ(kThemeToolbarColor, |
| 83 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); | 91 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 92 |
| 93 // TODO(estade): remove when vestigial .pak file deletion is removed. |
| 94 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 95 base::FilePath old_path = |
| 96 browser() |
| 97 ->profile() |
| 98 ->GetPrefs() |
| 99 ->GetFilePath(prefs::kCurrentThemePackFilename) |
| 100 .AppendASCII("Cached Theme Material Design.pak"); |
| 101 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: " |
| 102 << old_path.value(); |
| 84 } | 103 } |
| 85 | 104 |
| 86 } // namespace | 105 } // namespace |
| OLD | NEW |