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

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

Issue 1028123002: Supervised users: Include extension version in update requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit_tests Created 5 years, 9 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 6624 matching lines...) Expand 10 before | Expand all | Expand 10 after
6635 ~MockPermissionRequestCreator() override {} 6635 ~MockPermissionRequestCreator() override {}
6636 6636
6637 bool IsEnabled() const override { return true; } 6637 bool IsEnabled() const override { return true; }
6638 6638
6639 void CreateURLAccessRequest(const GURL& url_requested, 6639 void CreateURLAccessRequest(const GURL& url_requested,
6640 const SuccessCallback& callback) override { 6640 const SuccessCallback& callback) override {
6641 FAIL(); 6641 FAIL();
6642 } 6642 }
6643 6643
6644 MOCK_METHOD2(CreateExtensionUpdateRequest, 6644 MOCK_METHOD2(CreateExtensionUpdateRequest,
6645 void(const std::string& extension_id, 6645 void(const std::string& id,
6646 const SupervisedUserService::SuccessCallback& callback)); 6646 const SupervisedUserService::SuccessCallback& callback));
6647 6647
6648 private: 6648 private:
6649 DISALLOW_COPY_AND_ASSIGN(MockPermissionRequestCreator); 6649 DISALLOW_COPY_AND_ASSIGN(MockPermissionRequestCreator);
6650 }; 6650 };
6651 6651
6652 TEST_F(ExtensionServiceTest, SupervisedUser_InstallOnlyAllowedByCustodian) { 6652 TEST_F(ExtensionServiceTest, SupervisedUser_InstallOnlyAllowedByCustodian) {
6653 ExtensionServiceInitParams params = CreateDefaultInitParams(); 6653 ExtensionServiceInitParams params = CreateDefaultInitParams();
6654 params.profile_is_supervised = true; 6654 params.profile_is_supervised = true;
6655 InitializeExtensionService(params); 6655 InitializeExtensionService(params);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
6730 // The extension must now be installed and enabled. 6730 // The extension must now be installed and enabled.
6731 ASSERT_TRUE(extension); 6731 ASSERT_TRUE(extension);
6732 ASSERT_TRUE(registry()->enabled_extensions().Contains(extension->id())); 6732 ASSERT_TRUE(registry()->enabled_extensions().Contains(extension->id()));
6733 6733
6734 // Save the id, as the extension object will be destroyed during updating. 6734 // Save the id, as the extension object will be destroyed during updating.
6735 std::string id = extension->id(); 6735 std::string id = extension->id();
6736 6736
6737 std::string old_version = extension->VersionString(); 6737 std::string old_version = extension->VersionString();
6738 6738
6739 // Update to a new version with increased permissions. 6739 // Update to a new version with increased permissions.
6740 EXPECT_CALL(*creator, CreateExtensionUpdateRequest(id, testing::_)); 6740 EXPECT_CALL(*creator,
6741 CreateExtensionUpdateRequest(id + ":2", testing::_));
6741 path = base_path.AppendASCII("v2"); 6742 path = base_path.AppendASCII("v2");
6742 PackCRXAndUpdateExtension(id, path, pem_path, DISABLED); 6743 PackCRXAndUpdateExtension(id, path, pem_path, DISABLED);
6743 6744
6744 // The extension should still be there, but disabled. 6745 // The extension should still be there, but disabled.
6745 EXPECT_FALSE(registry()->enabled_extensions().Contains(id)); 6746 EXPECT_FALSE(registry()->enabled_extensions().Contains(id));
6746 extension = registry()->disabled_extensions().GetByID(id); 6747 extension = registry()->disabled_extensions().GetByID(id);
6747 ASSERT_TRUE(extension); 6748 ASSERT_TRUE(extension);
6748 // The version should have changed. 6749 // The version should have changed.
6749 EXPECT_NE(extension->VersionString(), old_version); 6750 EXPECT_NE(extension->VersionString(), old_version);
6750 } 6751 }
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
7722 7723
7723 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 7724 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
7724 content::Source<Profile>(profile()), 7725 content::Source<Profile>(profile()),
7725 content::NotificationService::NoDetails()); 7726 content::NotificationService::NoDetails());
7726 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 7727 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
7727 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 7728 EXPECT_EQ(0u, registry()->enabled_extensions().size());
7728 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 7729 EXPECT_EQ(0u, registry()->disabled_extensions().size());
7729 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 7730 EXPECT_EQ(0u, registry()->terminated_extensions().size());
7730 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 7731 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
7731 } 7732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698