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

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

Issue 2103663002: [Extensions] Rework inline installation observation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missingfile Created 4 years, 5 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/extensions/webstore_inline_installer.h" 5 #include "chrome/browser/extensions/webstore_inline_installer.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ExtensionInstallPrompt::UNSET_PROMPT_TYPE; 302 ExtensionInstallPrompt::UNSET_PROMPT_TYPE;
303 ui_test_utils::NavigateToURL( 303 ui_test_utils::NavigateToURL(
304 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); 304 browser(), GenerateTestServerUrl(kAppDomain, "install.html"));
305 RunTest("runTest"); 305 RunTest("runTest");
306 // If the extension was already enabled, we should still display an inline 306 // If the extension was already enabled, we should still display an inline
307 // install prompt (until we come up with something better). 307 // install prompt (until we come up with something better).
308 EXPECT_EQ(ExtensionInstallPrompt::INLINE_INSTALL_PROMPT, 308 EXPECT_EQ(ExtensionInstallPrompt::INLINE_INSTALL_PROMPT,
309 ExtensionInstallPrompt::g_last_prompt_type_for_tests); 309 ExtensionInstallPrompt::g_last_prompt_type_for_tests);
310 } 310 }
311 311
312 // Test calling chrome.webstore.install() twice without waiting for the first to
313 // finish.
314 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, DoubleInlineInstallTest) {
315 ui_test_utils::NavigateToURL(
316 browser(), GenerateTestServerUrl(kAppDomain, "double_install.html"));
317 RunTest("runTest");
318 }
319
312 class WebstoreInlineInstallerListenerTest : public WebstoreInlineInstallerTest { 320 class WebstoreInlineInstallerListenerTest : public WebstoreInlineInstallerTest {
313 public: 321 public:
314 WebstoreInlineInstallerListenerTest() {} 322 WebstoreInlineInstallerListenerTest() {}
315 ~WebstoreInlineInstallerListenerTest() override {} 323 ~WebstoreInlineInstallerListenerTest() override {}
316 324
317 protected: 325 protected:
318 void RunTest(const std::string& file_name) { 326 void RunTest(const std::string& file_name) {
319 AutoAcceptInstall(); 327 AutoAcceptInstall();
320 ui_test_utils::NavigateToURL(browser(), 328 ui_test_utils::NavigateToURL(browser(),
321 GenerateTestServerUrl(kAppDomain, file_name)); 329 GenerateTestServerUrl(kAppDomain, file_name));
322 WebstoreInstallerTest::RunTest("runTest"); 330 WebstoreInstallerTest::RunTest("runTest");
323 } 331 }
324 }; 332 };
325 333
326 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, 334 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest,
327 InstallStageListenerTest) { 335 InstallStageListenerTest) {
328 RunTest("install_stage_listener.html"); 336 RunTest("install_stage_listener.html");
329 } 337 }
330 338
331 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, 339 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest,
332 DownloadProgressListenerTest) { 340 DownloadProgressListenerTest) {
333 RunTest("download_progress_listener.html"); 341 RunTest("download_progress_listener.html");
334 } 342 }
335 343
336 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { 344 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) {
337 RunTest("both_listeners.html"); 345 RunTest("both_listeners.html");
346 // The extension should be installed.
347 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
348 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId));
349
350 // Rinse and repeat: uninstall the extension, open a new tab, and install it
351 // again. Regression test for crbug.com/613949.
352 extension_service()->UninstallExtension(
353 kTestExtensionId, UNINSTALL_REASON_FOR_TESTING,
354 base::Bind(&base::DoNothing), nullptr);
355 base::RunLoop().RunUntilIdle();
356 EXPECT_FALSE(registry->enabled_extensions().GetByID(kTestExtensionId));
357 int old_tab_index = browser()->tab_strip_model()->active_index();
358 ui_test_utils::NavigateToURLWithDisposition(
359 browser(), GenerateTestServerUrl(kAppDomain, "both_listeners.html"),
360 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
361 DCHECK_NE(old_tab_index, browser()->tab_strip_model()->active_index());
362 browser()->tab_strip_model()->CloseWebContentsAt(old_tab_index,
363 TabStripModel::CLOSE_NONE);
364 WebstoreInstallerTest::RunTest("runTest");
365 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId));
338 } 366 }
339 367
340 } // namespace extensions 368 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/browser/extensions/webstore_standalone_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698