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

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..8402d4763b13fee5826a667961b61d8192cdbaad 100644
--- a/chrome/browser/extensions/extension_service_sync_unittest.cc
+++ b/chrome/browser/extensions/extension_service_sync_unittest.cc
@@ -1684,6 +1684,87 @@ 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).
+ 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));
Marc Treib 2016/06/13 12:17:09 This should probably be ASSERT_TRUE - if it's fals
mamir 2016/06/13 14:15:57 Done.
+ EXPECT_TRUE(registry()
+ ->enabled_extensions()
+ .GetByID(id)
+ ->was_installed_by_custodian());
Marc Treib 2016/06/13 12:17:09 Woah, did git cl format do this? Ugh... maybe pull
mamir 2016/06/13 14:15:57 Done.
+}
+
+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));
+ EXPECT_TRUE(registry()
+ ->enabled_extensions()
+ .GetByID(id)
+ ->was_installed_by_custodian());
+}
+
TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) {
InitServices(true /* profile_is_supervised */);
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | chrome/browser/extensions/extension_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698