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

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

Issue 316863002: Rename "managed (mode|user)" to "supervised user" (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
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/file_util.h" 7 #include "base/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"
(...skipping 12 matching lines...) Expand all
23 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
24 #include "extensions/common/extension.h" 24 #include "extensions/common/extension.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 using extensions::ExtensionRegistry; 27 using extensions::ExtensionRegistry;
28 28
29 namespace theme_service_internal { 29 namespace theme_service_internal {
30 30
31 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { 31 class ThemeServiceTest : public extensions::ExtensionServiceTestBase {
32 public: 32 public:
33 ThemeServiceTest() : is_managed_(false), 33 ThemeServiceTest() : is_supervised_(false),
34 registry_(NULL) {} 34 registry_(NULL) {}
35 virtual ~ThemeServiceTest() {} 35 virtual ~ThemeServiceTest() {}
36 36
37 // Moves a minimal theme to |temp_dir_path| and unpacks it from that 37 // Moves a minimal theme to |temp_dir_path| and unpacks it from that
38 // directory. 38 // directory.
39 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) { 39 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) {
40 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); 40 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json");
41 base::FilePath test_data_dir; 41 base::FilePath test_data_dir;
42 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); 42 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
43 base::FilePath src_manifest_path = 43 base::FilePath src_manifest_path =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 observer.Wait(); 79 observer.Wait();
80 80
81 // Let the ThemeService finish creating the theme pack. 81 // Let the ThemeService finish creating the theme pack.
82 base::MessageLoop::current()->RunUntilIdle(); 82 base::MessageLoop::current()->RunUntilIdle();
83 } 83 }
84 84
85 virtual void SetUp() { 85 virtual void SetUp() {
86 extensions::ExtensionServiceTestBase::SetUp(); 86 extensions::ExtensionServiceTestBase::SetUp();
87 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params = 87 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params =
88 CreateDefaultInitParams(); 88 CreateDefaultInitParams();
89 params.profile_is_managed = is_managed_; 89 params.profile_is_supervised = is_supervised_;
90 InitializeExtensionService(params); 90 InitializeExtensionService(params);
91 service_->Init(); 91 service_->Init();
92 registry_ = ExtensionRegistry::Get(profile_.get()); 92 registry_ = ExtensionRegistry::Get(profile_.get());
93 ASSERT_TRUE(registry_); 93 ASSERT_TRUE(registry_);
94 } 94 }
95 95
96 const CustomThemeSupplier* get_theme_supplier(ThemeService* theme_service) { 96 const CustomThemeSupplier* get_theme_supplier(ThemeService* theme_service) {
97 return theme_service->get_theme_supplier(); 97 return theme_service->get_theme_supplier();
98 } 98 }
99 99
100 protected: 100 protected:
101 bool is_managed_; 101 bool is_supervised_;
102 ExtensionRegistry* registry_; 102 ExtensionRegistry* registry_;
103 103
104 }; 104 };
105 105
106 // Installs then uninstalls a theme and makes sure that the ThemeService 106 // Installs then uninstalls a theme and makes sure that the ThemeService
107 // reverts to the default theme after the uninstall. 107 // reverts to the default theme after the uninstall.
108 TEST_F(ThemeServiceTest, ThemeInstallUninstall) { 108 TEST_F(ThemeServiceTest, ThemeInstallUninstall) {
109 ThemeService* theme_service = 109 ThemeService* theme_service =
110 ThemeServiceFactory::GetForProfile(profile_.get()); 110 ThemeServiceFactory::GetForProfile(profile_.get());
111 theme_service->UseDefaultTheme(); 111 theme_service->UseDefaultTheme();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, 223 EXPECT_TRUE(registry_->GetExtensionById(extension1_id,
224 ExtensionRegistry::DISABLED)); 224 ExtensionRegistry::DISABLED));
225 225
226 // 2) Upgrading a disabled theme should not change the current theme. 226 // 2) Upgrading a disabled theme should not change the current theme.
227 UpdateUnpackedTheme(extension1_id); 227 UpdateUnpackedTheme(extension1_id);
228 EXPECT_EQ(extension2_id, theme_service->GetThemeID()); 228 EXPECT_EQ(extension2_id, theme_service->GetThemeID());
229 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, 229 EXPECT_TRUE(registry_->GetExtensionById(extension1_id,
230 ExtensionRegistry::DISABLED)); 230 ExtensionRegistry::DISABLED));
231 } 231 }
232 232
233 class ThemeServiceManagedUserTest : public ThemeServiceTest { 233 class ThemeServiceSupervisedUserTest : public ThemeServiceTest {
234 public: 234 public:
235 ThemeServiceManagedUserTest() {} 235 ThemeServiceSupervisedUserTest() {}
236 virtual ~ThemeServiceManagedUserTest() {} 236 virtual ~ThemeServiceSupervisedUserTest() {}
237 237
238 virtual void SetUp() OVERRIDE { 238 virtual void SetUp() OVERRIDE {
239 is_managed_ = true; 239 is_supervised_ = true;
240 ThemeServiceTest::SetUp(); 240 ThemeServiceTest::SetUp();
241 } 241 }
242 }; 242 };
243 243
244 // Checks that managed users have their own default theme. 244 // Checks that supervised users have their own default theme.
245 TEST_F(ThemeServiceManagedUserTest, ManagedUserThemeReplacesDefaultTheme) { 245 TEST_F(ThemeServiceSupervisedUserTest,
246 SupervisedUserThemeReplacesDefaultTheme) {
246 ThemeService* theme_service = 247 ThemeService* theme_service =
247 ThemeServiceFactory::GetForProfile(profile_.get()); 248 ThemeServiceFactory::GetForProfile(profile_.get());
248 theme_service->UseDefaultTheme(); 249 theme_service->UseDefaultTheme();
249 EXPECT_TRUE(theme_service->UsingDefaultTheme()); 250 EXPECT_TRUE(theme_service->UsingDefaultTheme());
250 EXPECT_TRUE(get_theme_supplier(theme_service)); 251 EXPECT_TRUE(get_theme_supplier(theme_service));
251 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), 252 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(),
252 CustomThemeSupplier::MANAGED_USER_THEME); 253 CustomThemeSupplier::SUPERVISED_USER_THEME);
253 } 254 }
254 255
255 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 256 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
256 // Checks that managed users don't use the system theme even if it is the 257 // Checks that supervised users don't use the system theme even if it is the
257 // default. The system theme is only available on Linux. 258 // default. The system theme is only available on Linux.
258 TEST_F(ThemeServiceManagedUserTest, ManagedUserThemeReplacesNativeTheme) { 259 TEST_F(ThemeServiceSupervisedUserTest, SupervisedUserThemeReplacesNativeTheme) {
259 profile_->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); 260 profile_->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true);
260 ThemeService* theme_service = 261 ThemeService* theme_service =
261 ThemeServiceFactory::GetForProfile(profile_.get()); 262 ThemeServiceFactory::GetForProfile(profile_.get());
262 theme_service->UseDefaultTheme(); 263 theme_service->UseDefaultTheme();
263 EXPECT_TRUE(theme_service->UsingDefaultTheme()); 264 EXPECT_TRUE(theme_service->UsingDefaultTheme());
264 EXPECT_TRUE(get_theme_supplier(theme_service)); 265 EXPECT_TRUE(get_theme_supplier(theme_service));
265 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), 266 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(),
266 CustomThemeSupplier::MANAGED_USER_THEME); 267 CustomThemeSupplier::SUPERVISED_USER_THEME);
267 } 268 }
268 #endif 269 #endif
269 270
270 }; // namespace theme_service_internal 271 }; // namespace theme_service_internal
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.cc ('k') | chrome/browser/ui/app_list/app_list_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698