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

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

Issue 8822021: Revert 113071 - Revert 113047 - Make ExtensionService use ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
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 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 UpdateExtension(id, 1868 UpdateExtension(id,
1869 extensions_path.AppendASCII("v2.crx"), 1869 extensions_path.AppendASCII("v2.crx"),
1870 ENABLED); 1870 ENABLED);
1871 ASSERT_EQ(std::string("2"), 1871 ASSERT_EQ(std::string("2"),
1872 service_->GetExtensionById(id, false)->version()->GetString()); 1872 service_->GetExtensionById(id, false)->version()->GetString());
1873 } 1873 }
1874 1874
1875 TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) { 1875 TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) {
1876 InitializeEmptyExtensionService(); 1876 InitializeEmptyExtensionService();
1877 InitializeRequestContext(); 1877 InitializeRequestContext();
1878 EXPECT_TRUE(service_->extensions()->empty()); 1878 EXPECT_TRUE(service_->extensions()->is_empty());
1879 1879
1880 int pref_count = 0; 1880 int pref_count = 0;
1881 1881
1882 // Install app1 with unlimited storage. 1882 // Install app1 with unlimited storage.
1883 const Extension* extension = 1883 const Extension* extension =
1884 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 1884 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
1885 ValidatePrefKeyCount(++pref_count); 1885 ValidatePrefKeyCount(++pref_count);
1886 ASSERT_EQ(1u, service_->extensions()->size()); 1886 ASSERT_EQ(1u, service_->extensions()->size());
1887 const std::string id1 = extension->id(); 1887 const std::string id1 = extension->id();
1888 EXPECT_TRUE(extension->HasAPIPermission( 1888 EXPECT_TRUE(extension->HasAPIPermission(
(...skipping 30 matching lines...) Expand all
1919 // Uninstall the other, unlimited storage should be revoked. 1919 // Uninstall the other, unlimited storage should be revoked.
1920 UninstallExtension(id2, false); 1920 UninstallExtension(id2, false);
1921 EXPECT_EQ(0u, service_->extensions()->size()); 1921 EXPECT_EQ(0u, service_->extensions()->size());
1922 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 1922 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
1923 IsStorageUnlimited(origin2)); 1923 IsStorageUnlimited(origin2));
1924 } 1924 }
1925 1925
1926 TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) { 1926 TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
1927 InitializeEmptyExtensionService(); 1927 InitializeEmptyExtensionService();
1928 InitializeRequestContext(); 1928 InitializeRequestContext();
1929 EXPECT_TRUE(service_->extensions()->empty()); 1929 EXPECT_TRUE(service_->extensions()->is_empty());
1930 1930
1931 int pref_count = 0; 1931 int pref_count = 0;
1932 1932
1933 const Extension* extension = 1933 const Extension* extension =
1934 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 1934 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
1935 ValidatePrefKeyCount(++pref_count); 1935 ValidatePrefKeyCount(++pref_count);
1936 ASSERT_EQ(1u, service_->extensions()->size()); 1936 ASSERT_EQ(1u, service_->extensions()->size());
1937 EXPECT_TRUE(extension->is_app()); 1937 EXPECT_TRUE(extension->is_app());
1938 const std::string id1 = extension->id(); 1938 const std::string id1 = extension->id();
1939 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); 1939 const GURL origin1(extension->GetFullLaunchURL().GetOrigin());
1940 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 1940 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
1941 IsStorageProtected(origin1)); 1941 IsStorageProtected(origin1));
1942 1942
1943 // App 4 has a different origin (maps.google.com). 1943 // App 4 has a different origin (maps.google.com).
1944 extension = PackAndInstallCRX(data_dir_.AppendASCII("app4"), INSTALL_NEW); 1944 extension = PackAndInstallCRX(data_dir_.AppendASCII("app4"), INSTALL_NEW);
1945 ValidatePrefKeyCount(++pref_count); 1945 ValidatePrefKeyCount(++pref_count);
1946 ASSERT_EQ(2u, service_->extensions()->size()); 1946 ASSERT_EQ(2u, service_->extensions()->size());
1947 const std::string id2 = extension->id(); 1947 const std::string id2 = extension->id();
1948 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); 1948 const GURL origin2(extension->GetFullLaunchURL().GetOrigin());
1949 ASSERT_NE(origin1, origin2); 1949 ASSERT_NE(origin1, origin2);
1950 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 1950 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
1951 IsStorageProtected(origin2)); 1951 IsStorageProtected(origin2));
1952 1952
1953 UninstallExtension(id1, false); 1953 UninstallExtension(id1, false);
1954 EXPECT_EQ(1u, service_->extensions()->size()); 1954 EXPECT_EQ(1u, service_->extensions()->size());
1955 1955
1956 UninstallExtension(id2, false); 1956 UninstallExtension(id2, false);
1957 1957
1958 EXPECT_TRUE(service_->extensions()->empty()); 1958 EXPECT_TRUE(service_->extensions()->is_empty());
1959 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 1959 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
1960 IsStorageProtected(origin1)); 1960 IsStorageProtected(origin1));
1961 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 1961 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
1962 IsStorageProtected(origin2)); 1962 IsStorageProtected(origin2));
1963 } 1963 }
1964 1964
1965 // Test that when an extension version is reinstalled, nothing happens. 1965 // Test that when an extension version is reinstalled, nothing happens.
1966 TEST_F(ExtensionServiceTest, Reinstall) { 1966 TEST_F(ExtensionServiceTest, Reinstall) {
1967 InitializeEmptyExtensionService(); 1967 InitializeEmptyExtensionService();
1968 1968
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 loop_.RunAllPending(); 2669 loop_.RunAllPending();
2670 ASSERT_EQ(1u, service_->extensions()->size()); 2670 ASSERT_EQ(1u, service_->extensions()->size());
2671 EXPECT_TRUE(service_->GetExtensionById(good_crx, false)); 2671 EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
2672 } 2672 }
2673 2673
2674 // Tests disabling extensions 2674 // Tests disabling extensions
2675 TEST_F(ExtensionServiceTest, DisableExtension) { 2675 TEST_F(ExtensionServiceTest, DisableExtension) {
2676 InitializeEmptyExtensionService(); 2676 InitializeEmptyExtensionService();
2677 2677
2678 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 2678 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
2679 EXPECT_FALSE(service_->extensions()->empty()); 2679 EXPECT_FALSE(service_->extensions()->is_empty());
2680 EXPECT_TRUE(service_->GetExtensionById(good_crx, true)); 2680 EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
2681 EXPECT_TRUE(service_->GetExtensionById(good_crx, false)); 2681 EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
2682 EXPECT_TRUE(service_->disabled_extensions()->empty()); 2682 EXPECT_TRUE(service_->disabled_extensions()->is_empty());
2683 2683
2684 // Disable it. 2684 // Disable it.
2685 service_->DisableExtension(good_crx); 2685 service_->DisableExtension(good_crx);
2686 2686
2687 EXPECT_TRUE(service_->extensions()->empty()); 2687 EXPECT_TRUE(service_->extensions()->is_empty());
2688 EXPECT_TRUE(service_->GetExtensionById(good_crx, true)); 2688 EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
2689 EXPECT_FALSE(service_->GetExtensionById(good_crx, false)); 2689 EXPECT_FALSE(service_->GetExtensionById(good_crx, false));
2690 EXPECT_FALSE(service_->disabled_extensions()->empty()); 2690 EXPECT_FALSE(service_->disabled_extensions()->is_empty());
2691 } 2691 }
2692 2692
2693 TEST_F(ExtensionServiceTest, DisableTerminatedExtension) { 2693 TEST_F(ExtensionServiceTest, DisableTerminatedExtension) {
2694 InitializeEmptyExtensionService(); 2694 InitializeEmptyExtensionService();
2695 2695
2696 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 2696 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
2697 TerminateExtension(good_crx); 2697 TerminateExtension(good_crx);
2698 EXPECT_TRUE(service_->GetTerminatedExtension(good_crx)); 2698 EXPECT_TRUE(service_->GetTerminatedExtension(good_crx));
2699 2699
2700 // Disable it. 2700 // Disable it.
2701 service_->DisableExtension(good_crx); 2701 service_->DisableExtension(good_crx);
2702 2702
2703 EXPECT_FALSE(service_->GetTerminatedExtension(good_crx)); 2703 EXPECT_FALSE(service_->GetTerminatedExtension(good_crx));
2704 EXPECT_TRUE(service_->GetExtensionById(good_crx, true)); 2704 EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
2705 EXPECT_FALSE(service_->disabled_extensions()->empty()); 2705 EXPECT_FALSE(service_->disabled_extensions()->is_empty());
2706 } 2706 }
2707 2707
2708 // Tests disabling all extensions (simulating --disable-extensions flag). 2708 // Tests disabling all extensions (simulating --disable-extensions flag).
2709 TEST_F(ExtensionServiceTest, DisableAllExtensions) { 2709 TEST_F(ExtensionServiceTest, DisableAllExtensions) {
2710 InitializeEmptyExtensionService(); 2710 InitializeEmptyExtensionService();
2711 2711
2712 FilePath path = data_dir_.AppendASCII("good.crx"); 2712 FilePath path = data_dir_.AppendASCII("good.crx");
2713 InstallCRX(path, INSTALL_NEW); 2713 InstallCRX(path, INSTALL_NEW);
2714 2714
2715 EXPECT_EQ(1u, service_->extensions()->size()); 2715 EXPECT_EQ(1u, service_->extensions()->size());
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4290 ASSERT_FALSE(AddPendingSyncInstall()); 4290 ASSERT_FALSE(AddPendingSyncInstall());
4291 4291
4292 // Wait for the external source to install. 4292 // Wait for the external source to install.
4293 WaitForCrxInstall(crx_path_, INSTALL_NEW); 4293 WaitForCrxInstall(crx_path_, INSTALL_NEW);
4294 ASSERT_TRUE(IsCrxInstalled()); 4294 ASSERT_TRUE(IsCrxInstalled());
4295 4295
4296 // Now that the extension is installed, sync request should fail 4296 // Now that the extension is installed, sync request should fail
4297 // because the extension is already installed. 4297 // because the extension is already installed.
4298 ASSERT_FALSE(AddPendingSyncInstall()); 4298 ASSERT_FALSE(AddPendingSyncInstall());
4299 } 4299 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_startup_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698