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 "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "base/threading/thread_restrictions.h" |
9 #include "chrome/browser/extensions/component_loader.h" | 10 #include "chrome/browser/extensions/component_loader.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
13 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 // Check that the theme was installed. | 63 // Check that the theme was installed. |
63 EXPECT_TRUE(UsingCustomTheme(*theme_service)); | 64 EXPECT_TRUE(UsingCustomTheme(*theme_service)); |
64 EXPECT_EQ(kThemeToolbarColor, | 65 EXPECT_EQ(kThemeToolbarColor, |
65 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); | 66 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
66 EXPECT_NE(base::FilePath(), | 67 EXPECT_NE(base::FilePath(), |
67 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); | 68 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); |
68 // Add a vestigial .pak file that should be removed when the new one is | 69 // Add a vestigial .pak file that should be removed when the new one is |
69 // created. | 70 // created. |
70 // TODO(estade): remove when vestigial .pak file deletion is removed. | 71 // TODO(estade): remove when vestigial .pak file deletion is removed. |
| 72 base::ThreadRestrictions::ScopedAllowIO allow_io; |
71 EXPECT_EQ( | 73 EXPECT_EQ( |
72 1, base::WriteFile(profile->GetPrefs() | 74 1, base::WriteFile(profile->GetPrefs() |
73 ->GetFilePath(prefs::kCurrentThemePackFilename) | 75 ->GetFilePath(prefs::kCurrentThemePackFilename) |
74 .AppendASCII("Cached Theme Material Design.pak"), | 76 .AppendASCII("Cached Theme Material Design.pak"), |
75 "a", 1)); | 77 "a", 1)); |
76 | 78 |
77 // Change the theme data pack path to an invalid location such that second | 79 // Change the theme data pack path to an invalid location such that second |
78 // part of the test is forced to recreate the theme pack when the theme | 80 // part of the test is forced to recreate the theme pack when the theme |
79 // service is initialized. | 81 // service is initialized. |
80 profile->GetPrefs()->SetFilePath( | 82 profile->GetPrefs()->SetFilePath( |
(...skipping 11 matching lines...) Expand all Loading... |
92 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); | 94 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); |
93 | 95 |
94 // TODO(estade): remove when vestigial .pak file deletion is removed. | 96 // TODO(estade): remove when vestigial .pak file deletion is removed. |
95 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 97 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
96 base::FilePath old_path = | 98 base::FilePath old_path = |
97 browser() | 99 browser() |
98 ->profile() | 100 ->profile() |
99 ->GetPrefs() | 101 ->GetPrefs() |
100 ->GetFilePath(prefs::kCurrentThemePackFilename) | 102 ->GetFilePath(prefs::kCurrentThemePackFilename) |
101 .AppendASCII("Cached Theme Material Design.pak"); | 103 .AppendASCII("Cached Theme Material Design.pak"); |
| 104 base::ThreadRestrictions::ScopedAllowIO allow_io; |
102 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: " | 105 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: " |
103 << old_path.value(); | 106 << old_path.value(); |
104 } | 107 } |
105 | 108 |
106 } // namespace | 109 } // namespace |
OLD | NEW |