OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions_service_unittest.h" | 5 #include "chrome/browser/extensions/extensions_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), theme_crx)); | 1656 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), theme_crx)); |
1657 | 1657 |
1658 const Extension* extension = service_->GetExtensionById(theme_crx, true); | 1658 const Extension* extension = service_->GetExtensionById(theme_crx, true); |
1659 ASSERT_TRUE(extension); | 1659 ASSERT_TRUE(extension); |
1660 | 1660 |
1661 EXPECT_EQ(Extension::ENABLED, | 1661 EXPECT_EQ(Extension::ENABLED, |
1662 service_->extension_prefs()->GetExtensionState(extension->id())); | 1662 service_->extension_prefs()->GetExtensionState(extension->id())); |
1663 EXPECT_FALSE(service_->IsIncognitoEnabled(extension)); | 1663 EXPECT_FALSE(service_->IsIncognitoEnabled(extension)); |
1664 } | 1664 } |
1665 | 1665 |
| 1666 // Test updating a pending CRX as if the source is an external extension |
| 1667 // with an update URL. The external update should overwrite a sync update, |
| 1668 // but a sync update should not overwrite a non-sync update. |
| 1669 TEST_F(ExtensionsServiceTest, UpdatePendingExternalCrxWinsOverSync) { |
| 1670 InitializeEmptyExtensionsService(); |
| 1671 |
| 1672 // Add a crx to be installed from the update mechanism. |
| 1673 service_->AddPendingExtensionFromSync( |
| 1674 kGoodId, GURL(kGoodUpdateURL), kCrxTypeExtension, |
| 1675 kGoodInstallSilently, kGoodInitialState, |
| 1676 kGoodInitialIncognitoEnabled); |
| 1677 |
| 1678 // Check that there is a pending crx, with is_from_sync set to true. |
| 1679 PendingExtensionMap::const_iterator it; |
| 1680 it = service_->pending_extensions().find(kGoodId); |
| 1681 ASSERT_TRUE(it != service_->pending_extensions().end()); |
| 1682 EXPECT_TRUE(it->second.is_from_sync); |
| 1683 |
| 1684 // Add a crx to be updated, with the same ID, from a non-sync source. |
| 1685 service_->AddPendingExtensionFromExternalUpdateUrl( |
| 1686 kGoodId, GURL(kGoodUpdateURL)); |
| 1687 |
| 1688 // Check that there is a pending crx, with is_from_sync set to false. |
| 1689 it = service_->pending_extensions().find(kGoodId); |
| 1690 ASSERT_TRUE(it != service_->pending_extensions().end()); |
| 1691 EXPECT_FALSE(it->second.is_from_sync); |
| 1692 |
| 1693 // Add a crx to be installed from the update mechanism. |
| 1694 service_->AddPendingExtensionFromSync( |
| 1695 kGoodId, GURL(kGoodUpdateURL), kCrxTypeExtension, |
| 1696 kGoodInstallSilently, kGoodInitialState, |
| 1697 kGoodInitialIncognitoEnabled); |
| 1698 |
| 1699 // Check that the external, non-sync update was not overridden. |
| 1700 it = service_->pending_extensions().find(kGoodId); |
| 1701 ASSERT_TRUE(it != service_->pending_extensions().end()); |
| 1702 EXPECT_FALSE(it->second.is_from_sync); |
| 1703 } |
| 1704 |
1666 // Updating a theme should fail if the updater is explicitly told that | 1705 // Updating a theme should fail if the updater is explicitly told that |
1667 // the CRX is not a theme. | 1706 // the CRX is not a theme. |
1668 TEST_F(ExtensionsServiceTest, UpdatePendingCrxThemeMismatch) { | 1707 TEST_F(ExtensionsServiceTest, UpdatePendingCrxThemeMismatch) { |
1669 InitializeEmptyExtensionsService(); | 1708 InitializeEmptyExtensionsService(); |
1670 service_->AddPendingExtensionFromSync( | 1709 service_->AddPendingExtensionFromSync( |
1671 theme_crx, GURL(), | 1710 theme_crx, GURL(), |
1672 PendingExtensionInfo::EXTENSION, | 1711 PendingExtensionInfo::EXTENSION, |
1673 true, Extension::ENABLED, false); | 1712 true, Extension::ENABLED, false); |
1674 | 1713 |
1675 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), theme_crx)); | 1714 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), theme_crx)); |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2715 // Component extensions shouldn't get recourded in the prefs. | 2754 // Component extensions shouldn't get recourded in the prefs. |
2716 ValidatePrefKeyCount(0); | 2755 ValidatePrefKeyCount(0); |
2717 | 2756 |
2718 // Reload all extensions, and make sure it comes back. | 2757 // Reload all extensions, and make sure it comes back. |
2719 std::string extension_id = service_->extensions()->at(0)->id(); | 2758 std::string extension_id = service_->extensions()->at(0)->id(); |
2720 loaded_.clear(); | 2759 loaded_.clear(); |
2721 service_->ReloadExtensions(); | 2760 service_->ReloadExtensions(); |
2722 ASSERT_EQ(1u, service_->extensions()->size()); | 2761 ASSERT_EQ(1u, service_->extensions()->size()); |
2723 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 2762 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
2724 } | 2763 } |
OLD | NEW |