OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3697 PendingExtensionInfo info; | 3697 PendingExtensionInfo info; |
3698 EXPECT_TRUE( | 3698 EXPECT_TRUE( |
3699 service_->pending_extension_manager()->GetById(good_crx, &info)); | 3699 service_->pending_extension_manager()->GetById(good_crx, &info)); |
3700 EXPECT_EQ(extension_sync_data.update_url, info.update_url()); | 3700 EXPECT_EQ(extension_sync_data.update_url, info.update_url()); |
3701 EXPECT_TRUE(info.is_from_sync()); | 3701 EXPECT_TRUE(info.is_from_sync()); |
3702 EXPECT_TRUE(info.install_silently()); | 3702 EXPECT_TRUE(info.install_silently()); |
3703 EXPECT_EQ(Extension::INTERNAL, info.install_source()); | 3703 EXPECT_EQ(Extension::INTERNAL, info.install_source()); |
3704 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. | 3704 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. |
3705 } | 3705 } |
3706 | 3706 |
| 3707 TEST_F(ExtensionServiceTest, HigherPriorityInstall) { |
| 3708 InitializeEmptyExtensionService(); |
| 3709 |
| 3710 FilePath path = data_dir_.AppendASCII("good.crx"); |
| 3711 InstallCrx(path, true); |
| 3712 ValidatePrefKeyCount(1u); |
| 3713 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); |
| 3714 ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); |
| 3715 |
| 3716 PendingExtensionManager* pending = service_->pending_extension_manager(); |
| 3717 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
| 3718 |
| 3719 // Skip install when the location is the same. |
| 3720 service_->OnExternalExtensionUpdateUrlFound(kGoodId, GURL(kGoodUpdateURL), |
| 3721 Extension::INTERNAL); |
| 3722 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
| 3723 // Force install when the location has higher priority. |
| 3724 service_->OnExternalExtensionUpdateUrlFound(kGoodId, GURL(kGoodUpdateURL), |
| 3725 Extension::EXTERNAL_POLICY_DOWNLOAD); |
| 3726 EXPECT_TRUE(pending->IsIdPending(kGoodId)); |
| 3727 pending->Remove(kGoodId); |
| 3728 // Skip install when the location has lower priority. |
| 3729 service_->OnExternalExtensionUpdateUrlFound(kGoodId, GURL(kGoodUpdateURL), |
| 3730 Extension::INTERNAL); |
| 3731 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
| 3732 } |
| 3733 |
3707 // Test that when multiple sources try to install an extension, | 3734 // Test that when multiple sources try to install an extension, |
3708 // we consistently choose the right one. To make tests easy to read, | 3735 // we consistently choose the right one. To make tests easy to read, |
3709 // methods that fake requests to install crx files in several ways | 3736 // methods that fake requests to install crx files in several ways |
3710 // are provided. | 3737 // are provided. |
3711 class ExtensionSourcePriorityTest : public ExtensionServiceTest { | 3738 class ExtensionSourcePriorityTest : public ExtensionServiceTest { |
3712 public: | 3739 public: |
3713 void SetUp() { | 3740 void SetUp() { |
3714 ExtensionServiceTest::SetUp(); | 3741 ExtensionServiceTest::SetUp(); |
3715 | 3742 |
3716 // All tests use a single extension. Put the id and path in member vars | 3743 // All tests use a single extension. Put the id and path in member vars |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3848 ASSERT_FALSE(AddPendingSyncInstall()); | 3875 ASSERT_FALSE(AddPendingSyncInstall()); |
3849 | 3876 |
3850 // Wait for the external source to install. | 3877 // Wait for the external source to install. |
3851 WaitForCrxInstall(crx_path_, true); | 3878 WaitForCrxInstall(crx_path_, true); |
3852 ASSERT_TRUE(IsCrxInstalled()); | 3879 ASSERT_TRUE(IsCrxInstalled()); |
3853 | 3880 |
3854 // Now that the extension is installed, sync request should fail | 3881 // Now that the extension is installed, sync request should fail |
3855 // because the extension is already installed. | 3882 // because the extension is already installed. |
3856 ASSERT_FALSE(AddPendingSyncInstall()); | 3883 ASSERT_FALSE(AddPendingSyncInstall()); |
3857 } | 3884 } |
OLD | NEW |