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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc

Issue 1132493004: Enable extensions error button test that was failing on stable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply feedback Created 5 years, 7 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/webui/extensions/extension_settings_browsertest.h" 5 #include "chrome/browser/ui/webui/extensions/extension_settings_browsertest.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 16 matching lines...) Expand all
27 #include "extensions/browser/api/management/management_api.h" 27 #include "extensions/browser/api/management/management_api.h"
28 #include "extensions/browser/extension_registry.h" 28 #include "extensions/browser/extension_registry.h"
29 #include "extensions/browser/extension_system.h" 29 #include "extensions/browser/extension_system.h"
30 #include "extensions/browser/test_extension_registry_observer.h" 30 #include "extensions/browser/test_extension_registry_observer.h"
31 #include "extensions/common/extension_set.h" 31 #include "extensions/common/extension_set.h"
32 32
33 using extensions::Extension; 33 using extensions::Extension;
34 using extensions::TestManagementPolicyProvider; 34 using extensions::TestManagementPolicyProvider;
35 35
36 ExtensionSettingsUIBrowserTest::ExtensionSettingsUIBrowserTest() 36 ExtensionSettingsUIBrowserTest::ExtensionSettingsUIBrowserTest()
37 : profile_(NULL), 37 : profile_(nullptr),
38 policy_provider_(TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS | 38 policy_provider_(TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS |
39 TestManagementPolicyProvider::MUST_REMAIN_ENABLED | 39 TestManagementPolicyProvider::MUST_REMAIN_ENABLED |
40 TestManagementPolicyProvider::MUST_REMAIN_INSTALLED) { 40 TestManagementPolicyProvider::MUST_REMAIN_INSTALLED) {
41 CHECK(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); 41 CHECK(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
42 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); 42 test_data_dir_ = test_data_dir_.AppendASCII("extensions");
43 } 43 }
44 44
45 ExtensionSettingsUIBrowserTest::~ExtensionSettingsUIBrowserTest() {} 45 ExtensionSettingsUIBrowserTest::~ExtensionSettingsUIBrowserTest() {}
46 46
47 Profile* ExtensionSettingsUIBrowserTest::GetProfile() { 47 Profile* ExtensionSettingsUIBrowserTest::GetProfile() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 void ExtensionSettingsUIBrowserTest::AddManagedPolicyProvider() { 84 void ExtensionSettingsUIBrowserTest::AddManagedPolicyProvider() {
85 auto* extension_service = extensions::ExtensionSystem::Get(GetProfile()); 85 auto* extension_service = extensions::ExtensionSystem::Get(GetProfile());
86 extension_service->management_policy()->RegisterProvider(&policy_provider_); 86 extension_service->management_policy()->RegisterProvider(&policy_provider_);
87 } 87 }
88 88
89 void ExtensionSettingsUIBrowserTest::SetAutoConfirmUninstall() { 89 void ExtensionSettingsUIBrowserTest::SetAutoConfirmUninstall() {
90 extensions::ManagementUninstallFunctionBase::SetAutoConfirmForTest(true); 90 extensions::ManagementUninstallFunctionBase::SetAutoConfirmForTest(true);
91 } 91 }
92 92
93 void ExtensionSettingsUIBrowserTest::EnableErrorConsole() {
94 error_console_override_.reset(new extensions::FeatureSwitch::ScopedOverride(
95 extensions::FeatureSwitch::error_console(), true));
96 }
97
93 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { 98 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt {
94 public: 99 public:
95 explicit MockAutoConfirmExtensionInstallPrompt( 100 explicit MockAutoConfirmExtensionInstallPrompt(
96 content::WebContents* web_contents) 101 content::WebContents* web_contents)
97 : ExtensionInstallPrompt(web_contents) {} 102 : ExtensionInstallPrompt(web_contents) {}
98 103
99 // Proceed without confirmation prompt. 104 // Proceed without confirmation prompt.
100 void ConfirmInstall(Delegate* delegate, 105 void ConfirmInstall(Delegate* delegate,
101 const Extension* extension, 106 const Extension* extension,
102 const ShowDialogCallback& show_dialog_callback) override { 107 const ShowDialogCallback& show_dialog_callback) override {
103 delegate->InstallUIProceed(); 108 delegate->InstallUIProceed();
104 } 109 }
105 }; 110 };
106 111
107 const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension( 112 const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension(
108 const base::FilePath& path) { 113 const base::FilePath& path) {
109 if (path.empty()) 114 if (path.empty())
110 return NULL; 115 return nullptr;
111 116
112 Profile* profile = GetProfile(); 117 Profile* profile = GetProfile();
113 ExtensionService* service = 118 ExtensionService* service =
114 extensions::ExtensionSystem::Get(profile)->extension_service(); 119 extensions::ExtensionSystem::Get(profile)->extension_service();
115 service->set_show_extensions_prompts(false); 120 service->set_show_extensions_prompts(false);
116 extensions::ExtensionRegistry* registry = 121 extensions::ExtensionRegistry* registry =
117 extensions::ExtensionRegistry::Get(profile); 122 extensions::ExtensionRegistry::Get(profile);
118 extensions::TestExtensionRegistryObserver observer(registry); 123 extensions::TestExtensionRegistryObserver observer(registry);
119 extensions::UnpackedInstaller::Create(service)->Load(path); 124 extensions::UnpackedInstaller::Create(service)->Load(path);
120 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); 125 base::FilePath extension_path = base::MakeAbsoluteFilePath(path);
(...skipping 15 matching lines...) Expand all
136 service->set_show_extensions_prompts(false); 141 service->set_show_extensions_prompts(false);
137 size_t num_before = registry->enabled_extensions().size(); 142 size_t num_before = registry->enabled_extensions().size();
138 { 143 {
139 scoped_ptr<ExtensionInstallPrompt> install_ui; 144 scoped_ptr<ExtensionInstallPrompt> install_ui;
140 install_ui.reset(new MockAutoConfirmExtensionInstallPrompt( 145 install_ui.reset(new MockAutoConfirmExtensionInstallPrompt(
141 browser()->tab_strip_model()->GetActiveWebContents())); 146 browser()->tab_strip_model()->GetActiveWebContents()));
142 147
143 base::FilePath crx_path = path; 148 base::FilePath crx_path = path;
144 DCHECK(crx_path.Extension() == FILE_PATH_LITERAL(".crx")); 149 DCHECK(crx_path.Extension() == FILE_PATH_LITERAL(".crx"));
145 if (crx_path.empty()) 150 if (crx_path.empty())
146 return NULL; 151 return nullptr;
147 152
148 scoped_refptr<extensions::CrxInstaller> installer( 153 scoped_refptr<extensions::CrxInstaller> installer(
149 extensions::CrxInstaller::Create(service, install_ui.Pass())); 154 extensions::CrxInstaller::Create(service, install_ui.Pass()));
150 installer->set_expected_id(std::string()); 155 installer->set_expected_id(std::string());
151 installer->set_is_gallery_install(false); 156 installer->set_is_gallery_install(false);
152 installer->set_install_source(extensions::Manifest::INTERNAL); 157 installer->set_install_source(extensions::Manifest::INTERNAL);
153 installer->set_install_immediately(true); 158 installer->set_install_immediately(true);
154 installer->set_off_store_install_allow_reason( 159 installer->set_off_store_install_allow_reason(
155 extensions::CrxInstaller::OffStoreInstallAllowedInTest); 160 extensions::CrxInstaller::OffStoreInstallAllowedInTest);
156 161
(...skipping 16 matching lines...) Expand all
173 registry->enabled_extensions()) 178 registry->enabled_extensions())
174 VLOG(1) << " " << extension->id(); 179 VLOG(1) << " " << extension->id();
175 180
176 VLOG(1) << "Errors follow:"; 181 VLOG(1) << "Errors follow:";
177 const std::vector<base::string16>* errors = 182 const std::vector<base::string16>* errors =
178 ExtensionErrorReporter::GetInstance()->GetErrors(); 183 ExtensionErrorReporter::GetInstance()->GetErrors();
179 for (std::vector<base::string16>::const_iterator iter = errors->begin(); 184 for (std::vector<base::string16>::const_iterator iter = errors->begin();
180 iter != errors->end(); ++iter) 185 iter != errors->end(); ++iter)
181 VLOG(1) << *iter; 186 VLOG(1) << *iter;
182 187
183 return NULL; 188 return nullptr;
184 } 189 }
185 190
186 if (!observer_->WaitForExtensionViewsToLoad()) 191 if (!observer_->WaitForExtensionViewsToLoad())
187 return NULL; 192 return nullptr;
188 return service->GetExtensionById(last_loaded_extension_id(), false); 193 return service->GetExtensionById(last_loaded_extension_id(), false);
189 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698