OLD | NEW |
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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/extensions/extension_install_prompt.h" | 6 #include "chrome/browser/extensions/extension_install_prompt.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/tab_helper.h" | 8 #include "chrome/browser/extensions/tab_helper.h" |
9 #include "chrome/browser/extensions/webstore_inline_installer.h" | 9 #include "chrome/browser/extensions/webstore_inline_installer.h" |
10 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" | 10 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 WebContents* popup_contents = | 160 WebContents* popup_contents = |
161 popup_browser->tab_strip_model()->GetActiveWebContents(); | 161 popup_browser->tab_strip_model()->GetActiveWebContents(); |
162 EXPECT_EQ(base::ASCIIToUTF16("POPUP"), popup_contents->GetTitle()); | 162 EXPECT_EQ(base::ASCIIToUTF16("POPUP"), popup_contents->GetTitle()); |
163 RunTest(popup_contents, "runTest"); | 163 RunTest(popup_contents, "runTest"); |
164 } | 164 } |
165 | 165 |
166 // Ensure that inline-installing a disabled extension simply re-enables it. | 166 // Ensure that inline-installing a disabled extension simply re-enables it. |
167 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 167 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
168 ReinstallDisabledExtension) { | 168 ReinstallDisabledExtension) { |
169 // Install an extension via inline install, and confirm it is successful. | 169 // Install an extension via inline install, and confirm it is successful. |
170 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 170 AutoAcceptInstall(); |
171 ExtensionInstallPrompt::ACCEPT; | |
172 ui_test_utils::NavigateToURL( | 171 ui_test_utils::NavigateToURL( |
173 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); | 172 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); |
174 RunTest("runTest"); | 173 RunTest("runTest"); |
175 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 174 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
176 ASSERT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); | 175 ASSERT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); |
177 | 176 |
178 // Disable the extension. | 177 // Disable the extension. |
179 ExtensionService* extension_service = | 178 ExtensionService* extension_service = |
180 ExtensionSystem::Get(browser()->profile())->extension_service(); | 179 ExtensionSystem::Get(browser()->profile())->extension_service(); |
181 extension_service->DisableExtension(kTestExtensionId, | 180 extension_service->DisableExtension(kTestExtensionId, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ExtensionInstallPrompt::g_last_prompt_type_for_tests); | 216 ExtensionInstallPrompt::g_last_prompt_type_for_tests); |
218 } | 217 } |
219 | 218 |
220 class WebstoreInlineInstallerListenerTest : public WebstoreInlineInstallerTest { | 219 class WebstoreInlineInstallerListenerTest : public WebstoreInlineInstallerTest { |
221 public: | 220 public: |
222 WebstoreInlineInstallerListenerTest() {} | 221 WebstoreInlineInstallerListenerTest() {} |
223 ~WebstoreInlineInstallerListenerTest() override {} | 222 ~WebstoreInlineInstallerListenerTest() override {} |
224 | 223 |
225 protected: | 224 protected: |
226 void RunTest(const std::string& file_name) { | 225 void RunTest(const std::string& file_name) { |
227 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 226 AutoAcceptInstall(); |
228 ExtensionInstallPrompt::ACCEPT; | |
229 ui_test_utils::NavigateToURL(browser(), | 227 ui_test_utils::NavigateToURL(browser(), |
230 GenerateTestServerUrl(kAppDomain, file_name)); | 228 GenerateTestServerUrl(kAppDomain, file_name)); |
231 WebstoreInstallerTest::RunTest("runTest"); | 229 WebstoreInstallerTest::RunTest("runTest"); |
232 } | 230 } |
233 }; | 231 }; |
234 | 232 |
235 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, | 233 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, |
236 InstallStageListenerTest) { | 234 InstallStageListenerTest) { |
237 RunTest("install_stage_listener.html"); | 235 RunTest("install_stage_listener.html"); |
238 } | 236 } |
239 | 237 |
240 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, | 238 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, |
241 DownloadProgressListenerTest) { | 239 DownloadProgressListenerTest) { |
242 RunTest("download_progress_listener.html"); | 240 RunTest("download_progress_listener.html"); |
243 } | 241 } |
244 | 242 |
245 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { | 243 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { |
246 RunTest("both_listeners.html"); | 244 RunTest("both_listeners.html"); |
247 } | 245 } |
248 | 246 |
249 } // namespace extensions | 247 } // namespace extensions |
OLD | NEW |