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

Side by Side Diff: chrome/browser/extensions/api/management/management_browsertest.cc

Issue 62713003: Move ExtensionProcessManager to src/extensions, part 4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 28 matching lines...) Expand all
39 // 39 //
40 // Note that 'version' here means something different than the version field 40 // Note that 'version' here means something different than the version field
41 // in the extension's manifest. We use the version as reported by the 41 // in the extension's manifest. We use the version as reported by the
42 // background page to test how overinstalling crx files with the same 42 // background page to test how overinstalling crx files with the same
43 // manifest version works. 43 // manifest version works.
44 bool IsExtensionAtVersion(const Extension* extension, 44 bool IsExtensionAtVersion(const Extension* extension,
45 const std::string& expected_version) { 45 const std::string& expected_version) {
46 // Test that the extension's version from the manifest and reported by the 46 // Test that the extension's version from the manifest and reported by the
47 // background page is correct. This is to ensure that the processes are in 47 // background page is correct. This is to ensure that the processes are in
48 // sync with the Extension. 48 // sync with the Extension.
49 ExtensionProcessManager* manager = 49 extensions::ProcessManager* manager =
50 extensions::ExtensionSystem::Get(browser()->profile())-> 50 extensions::ExtensionSystem::Get(browser()->profile())->
51 process_manager(); 51 process_manager();
52 extensions::ExtensionHost* ext_host = 52 extensions::ExtensionHost* ext_host =
53 manager->GetBackgroundHostForExtension(extension->id()); 53 manager->GetBackgroundHostForExtension(extension->id());
54 EXPECT_TRUE(ext_host); 54 EXPECT_TRUE(ext_host);
55 if (!ext_host) 55 if (!ext_host)
56 return false; 56 return false;
57 57
58 std::string version_from_bg; 58 std::string version_from_bg;
59 bool exec = content::ExecuteScriptAndExtractString( 59 bool exec = content::ExecuteScriptAndExtractString(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 UninstallExtension(id); 131 UninstallExtension(id);
132 132
133 // And the install should succeed when the permissions are accepted. 133 // And the install should succeed when the permissions are accepted.
134 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( 134 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(
135 test_data_dir_.AppendASCII("good.crx"), 1, browser())); 135 test_data_dir_.AppendASCII("good.crx"), 1, browser()));
136 UninstallExtension(id); 136 UninstallExtension(id);
137 } 137 }
138 138
139 // Tests that disabling and re-enabling an extension works. 139 // Tests that disabling and re-enabling an extension works.
140 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) { 140 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) {
141 ExtensionProcessManager* manager = 141 extensions::ProcessManager* manager =
142 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 142 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
143 ExtensionService* service = extensions::ExtensionSystem::Get( 143 ExtensionService* service = extensions::ExtensionSystem::Get(
144 browser()->profile())->extension_service(); 144 browser()->profile())->extension_service();
145 const size_t size_before = service->extensions()->size(); 145 const size_t size_before = service->extensions()->size();
146 146
147 // Load an extension, expect the background page to be available. 147 // Load an extension, expect the background page to be available.
148 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; 148 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
149 ASSERT_TRUE(LoadExtension( 149 ASSERT_TRUE(LoadExtension(
150 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 150 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
151 .AppendASCII(extension_id) 151 .AppendASCII(extension_id)
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); 633 forcelist, kExtensionId, "http://localhost/autoupdate/manifest");
634 } 634 }
635 ASSERT_TRUE(WaitForExtensionInstall()); 635 ASSERT_TRUE(WaitForExtensionInstall());
636 ASSERT_EQ(size_before + 1, service->extensions()->size()); 636 ASSERT_EQ(size_before + 1, service->extensions()->size());
637 extension = service->GetExtensionById(kExtensionId, false); 637 extension = service->GetExtensionById(kExtensionId, false);
638 ASSERT_TRUE(extension); 638 ASSERT_TRUE(extension);
639 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 639 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
640 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 640 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
641 EXPECT_TRUE(service->disabled_extensions()->is_empty()); 641 EXPECT_TRUE(service->disabled_extensions()->is_empty());
642 } 642 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698