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

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: Fix the bug of delegated installs for pre-existing extensions 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, DelegatedAndPreinstalledExtension) {
1688 InitServices(false /* profile_is_supervised */);
1689
1690 // Install an extension.
1691 base::FilePath path = data_dir().AppendASCII("good.crx");
1692 const Extension* extension = InstallCRX(path, INSTALL_NEW);
1693 std::string id = extension->id();
1694 const std::string version("1.0.0.0");
1695
1696 // It should be enabled.
1697 EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
1698
1699 sync_pb::EntitySpecifics specifics;
Marc Treib 2016/06/13 09:37:13 Add a comment about what this does please.
mamir 2016/06/13 11:30:16 Done.
1700 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
1701 ext_specifics->set_id(id);
1702 ext_specifics->set_enabled(true);
1703 ext_specifics->set_disable_reasons(Extension::DISABLE_NONE);
1704 ext_specifics->set_installed_by_custodian(true);
1705 ext_specifics->set_version(version);
1706
1707 SyncChangeList list =
1708 MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE);
1709
1710 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
1711
1712 // Now make the profile supervised.
Marc Treib 2016/06/13 09:37:14 What about the other way around - first it becomes
mamir 2016/06/13 11:30:16 Done.
1713 profile()->AsTestingProfile()->SetSupervisedUserId(
1714 supervised_users::kChildAccountSUID);
1715
1716 // The extension should be enabled.
1717 EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
Marc Treib 2016/06/13 09:37:14 Also check that is has the installed_by_custodian
mamir 2016/06/13 11:30:16 Done.
1718 }
1719
1687 TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) { 1720 TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) {
1688 InitServices(true /* profile_is_supervised */); 1721 InitServices(true /* profile_is_supervised */);
1689 1722
1690 base::FilePath base_path = data_dir().AppendASCII("autoupdate"); 1723 base::FilePath base_path = data_dir().AppendASCII("autoupdate");
1691 base::FilePath pem_path = base_path.AppendASCII("key.pem"); 1724 base::FilePath pem_path = base_path.AppendASCII("key.pem");
1692 1725
1693 const Extension* extension = 1726 const Extension* extension =
1694 PackAndInstallCRX(base_path.AppendASCII("v1"), pem_path, INSTALL_NEW, 1727 PackAndInstallCRX(base_path.AppendASCII("v1"), pem_path, INSTALL_NEW,
1695 Extension::WAS_INSTALLED_BY_CUSTODIAN); 1728 Extension::WAS_INSTALLED_BY_CUSTODIAN);
1696 // The extension must now be installed and enabled. 1729 // The extension must now be installed and enabled.
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 break; 2087 break;
2055 } 2088 }
2056 } 2089 }
2057 } 2090 }
2058 EXPECT_TRUE(found_delete); 2091 EXPECT_TRUE(found_delete);
2059 2092
2060 // Make sure there is one extension, and there are no more apps. 2093 // Make sure there is one extension, and there are no more apps.
2061 EXPECT_EQ(1u, extensions_processor.data().size()); 2094 EXPECT_EQ(1u, extensions_processor.data().size());
2062 EXPECT_TRUE(apps_processor.data().empty()); 2095 EXPECT_TRUE(apps_processor.data().empty());
2063 } 2096 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698