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

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

Issue 2799003002: Unpack theme data from extensions off of UI thread. (Closed)
Patch Set: fix gtk case 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"
10 #include "chrome/browser/extensions/component_loader.h" 11 #include "chrome/browser/extensions/component_loader.h"
11 #include "chrome/browser/extensions/extension_browsertest.h" 12 #include "chrome/browser/extensions/extension_browsertest.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
14 #include "chrome/browser/themes/theme_service_factory.h" 15 #include "chrome/browser/themes/theme_service_factory.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
19 #include "content/public/test/test_utils.h"
18 20
19 namespace { 21 namespace {
20 22
21 // The toolbar color specified in the theme. 23 // The toolbar color specified in the theme.
22 const SkColor kThemeToolbarColor = 0xFFCFDDC0; 24 const SkColor kThemeToolbarColor = 0xFFCFDDC0;
23 25
24 bool UsingCustomTheme(const ThemeService& theme_service) { 26 bool UsingCustomTheme(const ThemeService& theme_service) {
25 return !theme_service.UsingSystemTheme() && 27 return !theme_service.UsingSystemTheme() &&
26 !theme_service.UsingDefaultTheme(); 28 !theme_service.UsingDefaultTheme();
27 } 29 }
(...skipping 24 matching lines...) Expand all
52 ThemeService::GetThemeProviderForProfile(profile); 54 ThemeService::GetThemeProviderForProfile(profile);
53 55
54 // Test initial state. 56 // Test initial state.
55 EXPECT_FALSE(UsingCustomTheme(*theme_service)); 57 EXPECT_FALSE(UsingCustomTheme(*theme_service));
56 EXPECT_NE(kThemeToolbarColor, 58 EXPECT_NE(kThemeToolbarColor,
57 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); 59 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR));
58 EXPECT_EQ(base::FilePath(), 60 EXPECT_EQ(base::FilePath(),
59 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); 61 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename));
60 62
61 InstallExtension(test_data_dir_.AppendASCII("theme"), 1); 63 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();
62 72
63 // Check that the theme was installed. 73 // Check that the theme was installed.
64 EXPECT_TRUE(UsingCustomTheme(*theme_service)); 74 EXPECT_TRUE(UsingCustomTheme(*theme_service));
65 EXPECT_EQ(kThemeToolbarColor, 75 EXPECT_EQ(kThemeToolbarColor,
66 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR)); 76 theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR));
67 EXPECT_NE(base::FilePath(), 77 EXPECT_NE(base::FilePath(),
68 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename)); 78 profile->GetPrefs()->GetFilePath(prefs::kCurrentThemePackFilename));
69 // Add a vestigial .pak file that should be removed when the new one is 79 // Add a vestigial .pak file that should be removed when the new one is
70 // created. 80 // created.
71 // TODO(estade): remove when vestigial .pak file deletion is removed. 81 // TODO(estade): remove when vestigial .pak file deletion is removed.
(...skipping 28 matching lines...) Expand all
100 ->profile() 110 ->profile()
101 ->GetPrefs() 111 ->GetPrefs()
102 ->GetFilePath(prefs::kCurrentThemePackFilename) 112 ->GetFilePath(prefs::kCurrentThemePackFilename)
103 .AppendASCII("Cached Theme Material Design.pak"); 113 .AppendASCII("Cached Theme Material Design.pak");
104 base::ThreadRestrictions::ScopedAllowIO allow_io; 114 base::ThreadRestrictions::ScopedAllowIO allow_io;
105 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: " 115 EXPECT_FALSE(base::PathExists(old_path)) << "File not deleted: "
106 << old_path.value(); 116 << old_path.value();
107 } 117 }
108 118
109 } // namespace 119 } // 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