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 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 | 1632 |
1633 // Another app with non-overlapping extent. Should succeed. | 1633 // Another app with non-overlapping extent. Should succeed. |
1634 PackAndInstallExtension(extensions_path.AppendASCII("app2"), true); | 1634 PackAndInstallExtension(extensions_path.AppendASCII("app2"), true); |
1635 ValidatePrefKeyCount(++pref_count); | 1635 ValidatePrefKeyCount(++pref_count); |
1636 | 1636 |
1637 // A third app whose extent overlaps the first. Should fail. | 1637 // A third app whose extent overlaps the first. Should fail. |
1638 PackAndInstallExtension(extensions_path.AppendASCII("app3"), false); | 1638 PackAndInstallExtension(extensions_path.AppendASCII("app3"), false); |
1639 ValidatePrefKeyCount(pref_count); | 1639 ValidatePrefKeyCount(pref_count); |
1640 } | 1640 } |
1641 | 1641 |
| 1642 TEST_F(ExtensionServiceTest, UpdateApps) { |
| 1643 InitializeEmptyExtensionService(); |
| 1644 FilePath extensions_path; |
| 1645 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); |
| 1646 extensions_path = |
| 1647 extensions_path.AppendASCII("extensions").AppendASCII("app_update"); |
| 1648 |
| 1649 // First install v1 of a hosted app. |
| 1650 InstallExtension(extensions_path.AppendASCII("v1.crx"), true); |
| 1651 ASSERT_EQ(1u, service_->extensions()->size()); |
| 1652 std::string id = service_->extensions()->at(0)->id(); |
| 1653 ASSERT_EQ(std::string("1"), |
| 1654 service_->extensions()->at(0)->version()->GetString()); |
| 1655 |
| 1656 // Now try updating to v2. |
| 1657 UpdateExtension(id, |
| 1658 extensions_path.AppendASCII("v2.crx"), |
| 1659 ENABLED); |
| 1660 ASSERT_EQ(std::string("2"), |
| 1661 service_->extensions()->at(0)->version()->GetString()); |
| 1662 } |
| 1663 |
1642 TEST_F(ExtensionServiceTest, InstallAppsWithUnlimtedStorage) { | 1664 TEST_F(ExtensionServiceTest, InstallAppsWithUnlimtedStorage) { |
1643 InitializeEmptyExtensionService(); | 1665 InitializeEmptyExtensionService(); |
1644 EXPECT_TRUE(service_->extensions()->empty()); | 1666 EXPECT_TRUE(service_->extensions()->empty()); |
1645 EXPECT_TRUE(service_->unlimited_storage_map_.empty()); | 1667 EXPECT_TRUE(service_->unlimited_storage_map_.empty()); |
1646 | 1668 |
1647 FilePath extensions_path; | 1669 FilePath extensions_path; |
1648 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); | 1670 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); |
1649 extensions_path = extensions_path.AppendASCII("extensions"); | 1671 extensions_path = extensions_path.AppendASCII("extensions"); |
1650 int pref_count = 0; | 1672 int pref_count = 0; |
1651 ChromeAppCacheService* appcache_service = profile_->GetAppCacheService(); | 1673 ChromeAppCacheService* appcache_service = profile_->GetAppCacheService(); |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3285 // Component extensions shouldn't get recourded in the prefs. | 3307 // Component extensions shouldn't get recourded in the prefs. |
3286 ValidatePrefKeyCount(0); | 3308 ValidatePrefKeyCount(0); |
3287 | 3309 |
3288 // Reload all extensions, and make sure it comes back. | 3310 // Reload all extensions, and make sure it comes back. |
3289 std::string extension_id = service_->extensions()->at(0)->id(); | 3311 std::string extension_id = service_->extensions()->at(0)->id(); |
3290 loaded_.clear(); | 3312 loaded_.clear(); |
3291 service_->ReloadExtensions(); | 3313 service_->ReloadExtensions(); |
3292 ASSERT_EQ(1u, service_->extensions()->size()); | 3314 ASSERT_EQ(1u, service_->extensions()->size()); |
3293 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3315 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
3294 } | 3316 } |
OLD | NEW |