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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 2206693002: Improve settings override bubble to indicate policy installed extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase master Created 4 years, 2 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 1704 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
1705 1705
1706 APIPermissionSet expected_api_perms; 1706 APIPermissionSet expected_api_perms;
1707 URLPatternSet expected_host_perms; 1707 URLPatternSet expected_host_perms;
1708 1708
1709 // Make sure there aren't any granted permissions before the 1709 // Make sure there aren't any granted permissions before the
1710 // extension is installed. 1710 // extension is installed.
1711 EXPECT_FALSE(prefs->GetGrantedPermissions(permissions_crx).get()); 1711 EXPECT_FALSE(prefs->GetGrantedPermissions(permissions_crx).get());
1712 1712
1713 const Extension* extension = PackAndInstallCRX( 1713 const Extension* extension = PackAndInstallCRX(
1714 path, pem_path, INSTALL_NEW, Extension::WAS_INSTALLED_BY_DEFAULT); 1714 path, pem_path, INSTALL_NEW, Extension::WAS_INSTALLED_BY_DEFAULT,
1715 Manifest::Location::INTERNAL);
1715 1716
1716 EXPECT_EQ(0u, GetErrors().size()); 1717 EXPECT_EQ(0u, GetErrors().size());
1717 ASSERT_EQ(1u, registry()->enabled_extensions().size()); 1718 ASSERT_EQ(1u, registry()->enabled_extensions().size());
1718 EXPECT_EQ(permissions_crx, extension->id()); 1719 EXPECT_EQ(permissions_crx, extension->id());
1719 1720
1720 // Verify that the valid API permissions have been recognized. 1721 // Verify that the valid API permissions have been recognized.
1721 expected_api_perms.insert(APIPermission::kTab); 1722 expected_api_perms.insert(APIPermission::kTab);
1722 1723
1723 std::unique_ptr<const PermissionSet> known_perms = 1724 std::unique_ptr<const PermissionSet> known_perms =
1724 prefs->GetGrantedPermissions(extension->id()); 1725 prefs->GetGrantedPermissions(extension->id());
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good2->id(), profile())); 2585 EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good2->id(), profile()));
2585 EXPECT_EQ(Extension::DISABLE_USER_ACTION, 2586 EXPECT_EQ(Extension::DISABLE_USER_ACTION,
2586 ExtensionPrefs::Get(profile())->GetDisableReasons(good2->id())); 2587 ExtensionPrefs::Get(profile())->GetDisableReasons(good2->id()));
2587 } 2588 }
2588 2589
2589 // Tests that updating preserves extension location. 2590 // Tests that updating preserves extension location.
2590 TEST_F(ExtensionServiceTest, UpdateExtensionPreservesLocation) { 2591 TEST_F(ExtensionServiceTest, UpdateExtensionPreservesLocation) {
2591 InitializeEmptyExtensionService(); 2592 InitializeEmptyExtensionService();
2592 base::FilePath path = data_dir().AppendASCII("good.crx"); 2593 base::FilePath path = data_dir().AppendASCII("good.crx");
2593 2594
2594 const Extension* good = 2595 const Extension* good = InstallCRX(path, Manifest::EXTERNAL_PREF, INSTALL_NEW,
2595 InstallCRXWithLocation(path, Manifest::EXTERNAL_PREF, INSTALL_NEW); 2596 Extension::NO_FLAGS);
2596 2597
2597 ASSERT_EQ("1.0.0.0", good->VersionString()); 2598 ASSERT_EQ("1.0.0.0", good->VersionString());
2598 ASSERT_EQ(good_crx, good->id()); 2599 ASSERT_EQ(good_crx, good->id());
2599 2600
2600 path = data_dir().AppendASCII("good2.crx"); 2601 path = data_dir().AppendASCII("good2.crx");
2601 UpdateExtension(good_crx, path, ENABLED); 2602 UpdateExtension(good_crx, path, ENABLED);
2602 const Extension* good2 = service()->GetExtensionById(good_crx, false); 2603 const Extension* good2 = service()->GetExtensionById(good_crx, false);
2603 ASSERT_EQ("1.0.0.1", good2->version()->GetString()); 2604 ASSERT_EQ("1.0.0.1", good2->version()->GetString());
2604 EXPECT_EQ(good2->location(), Manifest::EXTERNAL_PREF); 2605 EXPECT_EQ(good2->location(), Manifest::EXTERNAL_PREF);
2605 } 2606 }
(...skipping 4344 matching lines...) Expand 10 before | Expand all | Expand 10 after
6950 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 6951 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
6951 EXPECT_TRUE(registry()->disabled_extensions().Contains(id)); 6952 EXPECT_TRUE(registry()->disabled_extensions().Contains(id));
6952 EXPECT_TRUE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED)); 6953 EXPECT_TRUE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED));
6953 6954
6954 base::FilePath v2_path = data_dir().AppendASCII("good2.crx"); 6955 base::FilePath v2_path = data_dir().AppendASCII("good2.crx");
6955 UpdateExtension(id, v2_path, ENABLED); 6956 UpdateExtension(id, v2_path, ENABLED);
6956 6957
6957 EXPECT_FALSE(registry()->disabled_extensions().Contains(id)); 6958 EXPECT_FALSE(registry()->disabled_extensions().Contains(id));
6958 EXPECT_FALSE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED)); 6959 EXPECT_FALSE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED));
6959 } 6960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698