Chromium Code Reviews| 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 */); |