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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 std::string id = extension->id(); 1677 std::string id = extension->id();
1678 1678
1679 // Now make the profile supervised. 1679 // Now make the profile supervised.
1680 profile()->AsTestingProfile()->SetSupervisedUserId( 1680 profile()->AsTestingProfile()->SetSupervisedUserId(
1681 supervised_users::kChildAccountSUID); 1681 supervised_users::kChildAccountSUID);
1682 1682
1683 // The extension should not be enabled anymore. 1683 // The extension should not be enabled anymore.
1684 EXPECT_FALSE(registry()->enabled_extensions().Contains(id)); 1684 EXPECT_FALSE(registry()->enabled_extensions().Contains(id));
1685 } 1685 }
1686 1686
1687 TEST_F(ExtensionServiceTestSupervised,
1688 DelegatedAndPreinstalledExtensionIsSUFirst) {
1689 InitServices(false /* profile_is_supervised */);
1690
1691 // Install an extension.
1692 base::FilePath path = data_dir().AppendASCII("good.crx");
1693 const Extension* extension = InstallCRX(path, INSTALL_NEW);
1694 std::string id = extension->id();
1695 const std::string version("1.0.0.0");
1696
1697 // It should be enabled.
1698 EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
1699
1700 // Now make the profile supervised.
1701 profile()->AsTestingProfile()->SetSupervisedUserId(
1702 supervised_users::kChildAccountSUID);
1703
1704 // 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.
1705 EXPECT_FALSE(registry()->enabled_extensions().Contains(id));
1706
1707 // Simulate data sync with the "was_installed_by_custodian" flag set to 1.
1708 sync_pb::EntitySpecifics specifics;
1709 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
1710 ext_specifics->set_id(id);
1711 ext_specifics->set_enabled(true);
1712 ext_specifics->set_disable_reasons(Extension::DISABLE_NONE);
1713 ext_specifics->set_installed_by_custodian(true);
1714 ext_specifics->set_version(version);
1715
1716 SyncChangeList list =
1717 MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE);
1718
1719 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
1720
1721 // The extension should be enabled again.
1722 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.
1723 Extension* extension = registry()->enabled_extensions().GetByID(id);
1724 ASSERT_TRUE(extension);
1725 EXPECT_TRUE(extension->was_installed_by_custodian());
1726 }
1727
1728 TEST_F(ExtensionServiceTestSupervised,
1729 DelegatedAndPreinstalledExtensionSyncFirst) {
1730 InitServices(false /* profile_is_supervised */);
1731
1732 // Install an extension.
1733 base::FilePath path = data_dir().AppendASCII("good.crx");
1734 const Extension* extension = InstallCRX(path, INSTALL_NEW);
1735 std::string id = extension->id();
1736 const std::string version("1.0.0.0");
1737
1738 // It should be enabled.
1739 EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
1740
1741 // Simulate data sync with the "was_installed_by_custodian" flag set to 1.
1742 sync_pb::EntitySpecifics specifics;
1743 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
1744 ext_specifics->set_id(id);
1745 ext_specifics->set_enabled(true);
1746 ext_specifics->set_disable_reasons(Extension::DISABLE_NONE);
1747 ext_specifics->set_installed_by_custodian(true);
1748 ext_specifics->set_version(version);
1749
1750 SyncChangeList list =
1751 MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE);
1752
1753 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
1754
1755 // Now make the profile supervised.
1756 profile()->AsTestingProfile()->SetSupervisedUserId(
1757 supervised_users::kChildAccountSUID);
1758
1759 // The extension should be enabled.
1760 EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
1761 Extension* extension = registry()->enabled_extensions().GetByID(id);
1762 ASSERT_TRUE(extension);
1763 EXPECT_TRUE(extension->was_installed_by_custodian());
1764 }
1765
1687 TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) { 1766 TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) {
1688 InitServices(true /* profile_is_supervised */); 1767 InitServices(true /* profile_is_supervised */);
1689 1768
1690 base::FilePath base_path = data_dir().AppendASCII("autoupdate"); 1769 base::FilePath base_path = data_dir().AppendASCII("autoupdate");
1691 base::FilePath pem_path = base_path.AppendASCII("key.pem"); 1770 base::FilePath pem_path = base_path.AppendASCII("key.pem");
1692 1771
1693 const Extension* extension = 1772 const Extension* extension =
1694 PackAndInstallCRX(base_path.AppendASCII("v1"), pem_path, INSTALL_NEW, 1773 PackAndInstallCRX(base_path.AppendASCII("v1"), pem_path, INSTALL_NEW,
1695 Extension::WAS_INSTALLED_BY_CUSTODIAN); 1774 Extension::WAS_INSTALLED_BY_CUSTODIAN);
1696 // The extension must now be installed and enabled. 1775 // The extension must now be installed and enabled.
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 break; 2133 break;
2055 } 2134 }
2056 } 2135 }
2057 } 2136 }
2058 EXPECT_TRUE(found_delete); 2137 EXPECT_TRUE(found_delete);
2059 2138
2060 // Make sure there is one extension, and there are no more apps. 2139 // Make sure there is one extension, and there are no more apps.
2061 EXPECT_EQ(1u, extensions_processor.data().size()); 2140 EXPECT_EQ(1u, extensions_processor.data().size());
2062 EXPECT_TRUE(apps_processor.data().empty()); 2141 EXPECT_TRUE(apps_processor.data().empty());
2063 } 2142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698