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

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

Issue 965233002: Remove deprecated extension notification from theme_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to private Created 5 years, 9 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_factory.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_service_test_base.h" 11 #include "chrome/browser/extensions/extension_service_test_base.h"
12 #include "chrome/browser/extensions/unpacked_installer.h" 12 #include "chrome/browser/extensions/unpacked_installer.h"
13 #include "chrome/browser/themes/custom_theme_supplier.h" 13 #include "chrome/browser/themes/custom_theme_supplier.h"
14 #include "chrome/browser/themes/theme_service_factory.h" 14 #include "chrome/browser/themes/theme_service_factory.h"
15 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "chrome/test/base/testing_profile_manager.h" 19 #include "chrome/test/base/testing_profile_manager.h"
20 #include "content/public/test/test_utils.h" 20 #include "content/public/test/test_utils.h"
21 #include "extensions/browser/extension_registry.h" 21 #include "extensions/browser/extension_registry.h"
22 #include "extensions/browser/test_extension_registry_observer.h"
22 #include "extensions/browser/uninstall_reason.h" 23 #include "extensions/browser/uninstall_reason.h"
23 #include "extensions/common/extension.h" 24 #include "extensions/common/extension.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 #if defined(ENABLE_SUPERVISED_USERS) 27 #if defined(ENABLE_SUPERVISED_USERS)
27 #include "chrome/browser/supervised_user/supervised_user_service.h" 28 #include "chrome/browser/supervised_user/supervised_user_service.h"
28 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 29 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
29 #endif 30 #endif
30 31
31 using extensions::ExtensionRegistry; 32 using extensions::ExtensionRegistry;
(...skipping 11 matching lines...) Expand all
43 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) { 44 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) {
44 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); 45 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json");
45 base::FilePath test_data_dir; 46 base::FilePath test_data_dir;
46 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); 47 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
47 base::FilePath src_manifest_path = 48 base::FilePath src_manifest_path =
48 test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json"); 49 test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json");
49 EXPECT_TRUE(base::CopyFile(src_manifest_path, dst_manifest_path)); 50 EXPECT_TRUE(base::CopyFile(src_manifest_path, dst_manifest_path));
50 51
51 scoped_refptr<extensions::UnpackedInstaller> installer( 52 scoped_refptr<extensions::UnpackedInstaller> installer(
52 extensions::UnpackedInstaller::Create(service_)); 53 extensions::UnpackedInstaller::Create(service_));
53 content::WindowedNotificationObserver observer( 54 extensions::TestExtensionRegistryObserver observer(
54 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 55 ExtensionRegistry::Get(profile()));
55 content::Source<Profile>(profile_.get()));
56 installer->Load(temp_dir); 56 installer->Load(temp_dir);
57 observer.Wait(); 57 std::string extension_id = observer.WaitForExtensionLoaded()->id();
58
59 std::string extension_id =
60 content::Details<extensions::Extension>(observer.details())->id();
61 58
62 // Let the ThemeService finish creating the theme pack. 59 // Let the ThemeService finish creating the theme pack.
63 base::MessageLoop::current()->RunUntilIdle(); 60 base::MessageLoop::current()->RunUntilIdle();
64 61
65 return extension_id; 62 return extension_id;
66 } 63 }
67 64
68 // Update the theme with |extension_id|. 65 // Update the theme with |extension_id|.
69 void UpdateUnpackedTheme(const std::string& extension_id) { 66 void UpdateUnpackedTheme(const std::string& extension_id) {
70 int updated_notification =
71 service_->IsExtensionEnabled(extension_id)
72 ? extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED
73 : extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED;
74
75 const base::FilePath& path = 67 const base::FilePath& path =
76 service_->GetInstalledExtension(extension_id)->path(); 68 service_->GetInstalledExtension(extension_id)->path();
77 69
78 scoped_refptr<extensions::UnpackedInstaller> installer( 70 scoped_refptr<extensions::UnpackedInstaller> installer(
79 extensions::UnpackedInstaller::Create(service_)); 71 extensions::UnpackedInstaller::Create(service_));
80 content::WindowedNotificationObserver observer(updated_notification, 72 if (service_->IsExtensionEnabled(extension_id)) {
81 content::Source<Profile>(profile_.get())); 73 extensions::TestExtensionRegistryObserver observer(
82 installer->Load(path); 74 ExtensionRegistry::Get(profile()));
83 observer.Wait(); 75 installer->Load(path);
76 observer.WaitForExtensionLoaded();
77 } else {
78 content::WindowedNotificationObserver observer(
79 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
80 content::Source<Profile>(profile_.get()));
81 installer->Load(path);
82 observer.Wait();
83 }
84 84
85 // Let the ThemeService finish creating the theme pack. 85 // Let the ThemeService finish creating the theme pack.
86 base::MessageLoop::current()->RunUntilIdle(); 86 base::MessageLoop::current()->RunUntilIdle();
87 } 87 }
88 88
89 void SetUp() override { 89 void SetUp() override {
90 extensions::ExtensionServiceTestBase::SetUp(); 90 extensions::ExtensionServiceTestBase::SetUp();
91 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params = 91 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params =
92 CreateDefaultInitParams(); 92 CreateDefaultInitParams();
93 params.profile_is_supervised = is_supervised_; 93 params.profile_is_supervised = is_supervised_;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 theme_service->UseDefaultTheme(); 271 theme_service->UseDefaultTheme();
272 EXPECT_TRUE(theme_service->UsingDefaultTheme()); 272 EXPECT_TRUE(theme_service->UsingDefaultTheme());
273 EXPECT_TRUE(get_theme_supplier(theme_service)); 273 EXPECT_TRUE(get_theme_supplier(theme_service));
274 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), 274 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(),
275 CustomThemeSupplier::SUPERVISED_USER_THEME); 275 CustomThemeSupplier::SUPERVISED_USER_THEME);
276 } 276 }
277 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) 277 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
278 #endif // defined(ENABLE_SUPERVISED_USERS) 278 #endif // defined(ENABLE_SUPERVISED_USERS)
279 279
280 }; // namespace theme_service_internal 280 }; // namespace theme_service_internal
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698