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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 355233002: Fix build when ENABLE_MANAGED_USERS is not defined (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include missing browsertest .js file in chrome_tests.gypi Created 6 years, 2 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 | « no previous file | chrome/browser/search/search_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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" 53 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h"
54 #include "chrome/browser/extensions/installed_loader.h" 54 #include "chrome/browser/extensions/installed_loader.h"
55 #include "chrome/browser/extensions/pack_extension_job.h" 55 #include "chrome/browser/extensions/pack_extension_job.h"
56 #include "chrome/browser/extensions/pending_extension_info.h" 56 #include "chrome/browser/extensions/pending_extension_info.h"
57 #include "chrome/browser/extensions/pending_extension_manager.h" 57 #include "chrome/browser/extensions/pending_extension_manager.h"
58 #include "chrome/browser/extensions/test_blacklist.h" 58 #include "chrome/browser/extensions/test_blacklist.h"
59 #include "chrome/browser/extensions/test_extension_system.h" 59 #include "chrome/browser/extensions/test_extension_system.h"
60 #include "chrome/browser/extensions/unpacked_installer.h" 60 #include "chrome/browser/extensions/unpacked_installer.h"
61 #include "chrome/browser/extensions/updater/extension_updater.h" 61 #include "chrome/browser/extensions/updater/extension_updater.h"
62 #include "chrome/browser/prefs/pref_service_syncable.h" 62 #include "chrome/browser/prefs/pref_service_syncable.h"
63 #include "chrome/browser/supervised_user/supervised_user_service.h"
64 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
65 #include "chrome/browser/sync/profile_sync_service.h" 63 #include "chrome/browser/sync/profile_sync_service.h"
66 #include "chrome/browser/sync/profile_sync_service_factory.h" 64 #include "chrome/browser/sync/profile_sync_service_factory.h"
67 #include "chrome/common/chrome_constants.h" 65 #include "chrome/common/chrome_constants.h"
68 #include "chrome/common/chrome_switches.h" 66 #include "chrome/common/chrome_switches.h"
69 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 67 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
70 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 68 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
71 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 69 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
72 #include "chrome/common/extensions/manifest_url_handler.h" 70 #include "chrome/common/extensions/manifest_url_handler.h"
73 #include "chrome/common/pref_names.h" 71 #include "chrome/common/pref_names.h"
74 #include "chrome/common/url_constants.h" 72 #include "chrome/common/url_constants.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #include "sync/api/sync_error_factory.h" 121 #include "sync/api/sync_error_factory.h"
124 #include "sync/api/sync_error_factory_mock.h" 122 #include "sync/api/sync_error_factory_mock.h"
125 #include "sync/api/syncable_service.h" 123 #include "sync/api/syncable_service.h"
126 #include "sync/protocol/app_specifics.pb.h" 124 #include "sync/protocol/app_specifics.pb.h"
127 #include "sync/protocol/extension_specifics.pb.h" 125 #include "sync/protocol/extension_specifics.pb.h"
128 #include "sync/protocol/sync.pb.h" 126 #include "sync/protocol/sync.pb.h"
129 #include "testing/gtest/include/gtest/gtest.h" 127 #include "testing/gtest/include/gtest/gtest.h"
130 #include "testing/platform_test.h" 128 #include "testing/platform_test.h"
131 #include "url/gurl.h" 129 #include "url/gurl.h"
132 130
131 #if defined(ENABLE_MANAGED_USERS)
132 #include "chrome/browser/supervised_user/supervised_user_service.h"
133 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
134 #endif
135
133 #if defined(OS_CHROMEOS) 136 #if defined(OS_CHROMEOS)
134 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 137 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
135 #include "chrome/browser/chromeos/settings/cros_settings.h" 138 #include "chrome/browser/chromeos/settings/cros_settings.h"
136 #include "chrome/browser/chromeos/settings/device_settings_service.h" 139 #include "chrome/browser/chromeos/settings/device_settings_service.h"
137 #endif 140 #endif
138 141
139 // The blacklist tests rely on safe browsing. 142 // The blacklist tests rely on safe browsing.
140 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 143 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
141 #define ENABLE_BLACKLIST_TESTS 144 #define ENABLE_BLACKLIST_TESTS
142 #endif 145 #endif
(...skipping 5961 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 const extensions::PendingExtensionInfo* info; 6107 const extensions::PendingExtensionInfo* info;
6105 EXPECT_TRUE( 6108 EXPECT_TRUE(
6106 (info = service()->pending_extension_manager()->GetById(good_crx))); 6109 (info = service()->pending_extension_manager()->GetById(good_crx)));
6107 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec()); 6110 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec());
6108 EXPECT_TRUE(info->is_from_sync()); 6111 EXPECT_TRUE(info->is_from_sync());
6109 EXPECT_TRUE(info->install_silently()); 6112 EXPECT_TRUE(info->install_silently());
6110 EXPECT_EQ(Manifest::INTERNAL, info->install_source()); 6113 EXPECT_EQ(Manifest::INTERNAL, info->install_source());
6111 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. 6114 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|.
6112 } 6115 }
6113 6116
6117 #if defined(ENABLE_MANAGED_USERS)
6114 TEST_F(ExtensionServiceTest, SupervisedUser_InstallOnlyAllowedByCustodian) { 6118 TEST_F(ExtensionServiceTest, SupervisedUser_InstallOnlyAllowedByCustodian) {
6115 ExtensionServiceInitParams params = CreateDefaultInitParams(); 6119 ExtensionServiceInitParams params = CreateDefaultInitParams();
6116 params.profile_is_supervised = true; 6120 params.profile_is_supervised = true;
6117 InitializeExtensionService(params); 6121 InitializeExtensionService(params);
6118 6122
6119 SupervisedUserService* supervised_user_service = 6123 SupervisedUserService* supervised_user_service =
6120 SupervisedUserServiceFactory::GetForProfile(profile()); 6124 SupervisedUserServiceFactory::GetForProfile(profile());
6121 GetManagementPolicy()->RegisterProvider(supervised_user_service); 6125 GetManagementPolicy()->RegisterProvider(supervised_user_service);
6122 6126
6123 base::FilePath path1 = data_dir().AppendASCII("good.crx"); 6127 base::FilePath path1 = data_dir().AppendASCII("good.crx");
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
6258 extension_sync_service()->ProcessSyncChanges(FROM_HERE, change_list); 6262 extension_sync_service()->ProcessSyncChanges(FROM_HERE, change_list);
6259 6263
6260 // Uninstalling the extension without installed_by_custodian should have been 6264 // Uninstalling the extension without installed_by_custodian should have been
6261 // blocked by policy, so it should still be there. 6265 // blocked by policy, so it should still be there.
6262 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_ids[0])); 6266 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_ids[0]));
6263 6267
6264 // But installed_by_custodian should result in bypassing the policy check. 6268 // But installed_by_custodian should result in bypassing the policy check.
6265 EXPECT_FALSE( 6269 EXPECT_FALSE(
6266 registry()->GenerateInstalledExtensionsSet()->Contains(extension_ids[1])); 6270 registry()->GenerateInstalledExtensionsSet()->Contains(extension_ids[1]));
6267 } 6271 }
6272 #endif // defined(ENABLE_MANAGED_USERS)
6268 6273
6269 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { 6274 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) {
6270 InitializeEmptyExtensionService(); 6275 InitializeEmptyExtensionService();
6271 6276
6272 base::FilePath path = data_dir().AppendASCII("good.crx"); 6277 base::FilePath path = data_dir().AppendASCII("good.crx");
6273 InstallCRX(path, INSTALL_NEW); 6278 InstallCRX(path, INSTALL_NEW);
6274 ValidatePrefKeyCount(1u); 6279 ValidatePrefKeyCount(1u);
6275 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 6280 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
6276 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 6281 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
6277 6282
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
7144 7149
7145 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 7150 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
7146 content::Source<Profile>(profile()), 7151 content::Source<Profile>(profile()),
7147 content::NotificationService::NoDetails()); 7152 content::NotificationService::NoDetails());
7148 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 7153 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
7149 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 7154 EXPECT_EQ(0u, registry()->enabled_extensions().size());
7150 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 7155 EXPECT_EQ(0u, registry()->disabled_extensions().size());
7151 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 7156 EXPECT_EQ(0u, registry()->terminated_extensions().size());
7152 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 7157 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
7153 } 7158 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698