Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: chrome/browser/themes/theme_service_browsertest.cc

Issue 2919953002: Revert of Unpack theme data from extensions off of UI thread. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/themes/theme_service.cc ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/threading/thread_restrictions.h"
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/component_loader.h" 10 #include "chrome/browser/extensions/component_loader.h"
12 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/themes/theme_properties.h" 13 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/themes/theme_service_factory.h" 14 #include "chrome/browser/themes/theme_service_factory.h"
16 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
19 #include "content/public/test/test_utils.h"
20 18
21 namespace { 19 namespace {
22 20
23 // The toolbar color specified in the theme. 21 // The toolbar color specified in the theme.
24 const SkColor kThemeToolbarColor = 0xFFCFDDC0; 22 const SkColor kThemeToolbarColor = 0xFFCFDDC0;
25 23
26 bool UsingCustomTheme(const ThemeService& theme_service) { 24 bool UsingCustomTheme(const ThemeService& theme_service) {
27 return !theme_service.UsingSystemTheme() && 25 return !theme_service.UsingSystemTheme() &&
28 !theme_service.UsingDefaultTheme(); 26 !theme_service.UsingDefaultTheme();
29 } 27 }
(...skipping 24 matching lines...) Expand all
54 ThemeService::GetThemeProviderForProfile(profile); 52 ThemeService::GetThemeProviderForProfile(profile);
55 53
56 // Test initial state. 54 // Test initial state.
57 EXPECT_FALSE(UsingCustomTheme(*theme_service)); 55 EXPECT_FALSE(UsingCustomTheme(*theme_service));
58 EXPECT_NE(kThemeToolbarColor, 56 EXPECT_NE(kThemeToolbarColor,
59 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); 57 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR));
60 EXPECT_EQ(base::FilePath(), 58 EXPECT_EQ(base::FilePath(),
61 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); 59 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename));
62 60
63 InstallExtension(test_data_dir_.AppendASCII("theme"), 1); 61 InstallExtension(test_data_dir_.AppendASCII("theme"), 1);
64 // The theme isn't installed synchronously.
65 EXPECT_FALSE(UsingCustomTheme(*theme_service));
66
67 // Wait for the theme to be loaded.
68 content::WindowedNotificationObserver theme_change_observer(
69 chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
70 content::Source<ThemeService>(theme_service));
71 theme_change_observer.Wait();
72 62
73 // Check that the theme was installed. 63 // Check that the theme was installed.
74 EXPECT_TRUE(UsingCustomTheme(*theme_service)); 64 EXPECT_TRUE(UsingCustomTheme(*theme_service));
75 EXPECT_EQ(kThemeToolbarColor, 65 EXPECT_EQ(kThemeToolbarColor,
76 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); 66 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR));
77 EXPECT_NE(base::FilePath(), 67 EXPECT_NE(base::FilePath(),
78 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); 68 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename));
79 // 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
80 // created. 70 // created.
81 // TODO(estade): remove when vestigial .pak file deletion is removed. 71 // TODO(estade): remove when vestigial .pak file deletion is removed.
(...skipping 28 matching lines...) Expand all
110 ->profile() 100 ->profile()
111 ->GetPrefs() 101 ->GetPrefs()
112 ->GetFilePath(prefs::kCurrentThemePackFilename) 102 ->GetFilePath(prefs::kCurrentThemePackFilename)
113 .AppendASCII("Cached Theme Material Design.pak"); 103 .AppendASCII("Cached Theme Material Design.pak");
114 base::ThreadRestrictions::ScopedAllowIO allow_io; 104 base::ThreadRestrictions::ScopedAllowIO allow_io;
115 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: " 105 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: "
116 << old_path.value(); 106 << old_path.value();
117 } 107 }
118 108
119 } // namespace 109 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.cc ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698