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

Unified Diff: chrome/browser/extensions/extension_service_sync_unittest.cc

Issue 2054773002: Replace the WAS_INSTALLED_BY_CUSTODIAN creation flag with a pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to code review by treib@ Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service_sync_unittest.cc
diff --git a/chrome/browser/extensions/extension_service_sync_unittest.cc b/chrome/browser/extensions/extension_service_sync_unittest.cc
index 8e9ac8d150782cd6541ad382d8d1def162acb17d..3cac7305298eb4386e615e8c63f88f3935ec1107 100644
--- a/chrome/browser/extensions/extension_service_sync_unittest.cc
+++ b/chrome/browser/extensions/extension_service_sync_unittest.cc
@@ -1684,6 +1684,85 @@ TEST_F(ExtensionServiceTestSupervised, PreinstalledExtension) {
EXPECT_FALSE(registry()->enabled_extensions().Contains(id));
}
+TEST_F(ExtensionServiceTestSupervised,
+ DelegatedAndPreinstalledExtensionIsSUFirst) {
+ InitServices(false /* profile_is_supervised */);
+
+ // Install an extension.
+ base::FilePath path = data_dir().AppendASCII("good.crx");
+ const Extension* extension = InstallCRX(path, INSTALL_NEW);
+ std::string id = extension->id();
+ const std::string version("1.0.0.0");
+
+ // It should be enabled.
+ EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
+
+ // Now make the profile supervised.
+ profile()->AsTestingProfile()->SetSupervisedUserId(
+ supervised_users::kChildAccountSUID);
+
+ // It should not be enabled now (it is not loaded at all actually).
Devlin 2016/06/13 14:36:58 nit: you have an extra space between "now" and "("
mamir 2016/06/13 15:25:31 Done.
+ EXPECT_FALSE(registry()->enabled_extensions().Contains(id));
+
+ // Simulate data sync with the "was_installed_by_custodian" flag set to 1.
+ sync_pb::EntitySpecifics specifics;
+ sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
+ ext_specifics->set_id(id);
+ ext_specifics->set_enabled(true);
+ ext_specifics->set_disable_reasons(Extension::DISABLE_NONE);
+ ext_specifics->set_installed_by_custodian(true);
+ ext_specifics->set_version(version);
+
+ SyncChangeList list =
+ MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE);
+
+ extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
+
+ // The extension should be enabled again.
+ EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
Devlin 2016/06/13 14:36:58 This check is redundant with the check below.
mamir 2016/06/13 15:25:31 Done.
+ Extension* extension = registry()->enabled_extensions().GetByID(id);
+ ASSERT_TRUE(extension);
+ EXPECT_TRUE(extension->was_installed_by_custodian());
+}
+
+TEST_F(ExtensionServiceTestSupervised,
+ DelegatedAndPreinstalledExtensionSyncFirst) {
+ InitServices(false /* profile_is_supervised */);
+
+ // Install an extension.
+ base::FilePath path = data_dir().AppendASCII("good.crx");
+ const Extension* extension = InstallCRX(path, INSTALL_NEW);
+ std::string id = extension->id();
+ const std::string version("1.0.0.0");
+
+ // It should be enabled.
+ EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
+
+ // Simulate data sync with the "was_installed_by_custodian" flag set to 1.
+ sync_pb::EntitySpecifics specifics;
+ sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
+ ext_specifics->set_id(id);
+ ext_specifics->set_enabled(true);
+ ext_specifics->set_disable_reasons(Extension::DISABLE_NONE);
+ ext_specifics->set_installed_by_custodian(true);
+ ext_specifics->set_version(version);
+
+ SyncChangeList list =
+ MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE);
+
+ extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
+
+ // Now make the profile supervised.
+ profile()->AsTestingProfile()->SetSupervisedUserId(
+ supervised_users::kChildAccountSUID);
+
+ // The extension should be enabled.
+ EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
+ Extension* extension = registry()->enabled_extensions().GetByID(id);
+ ASSERT_TRUE(extension);
+ EXPECT_TRUE(extension->was_installed_by_custodian());
+}
+
TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) {
InitServices(true /* profile_is_supervised */);

Powered by Google App Engine
This is Rietveld 408576698