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

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

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