Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
| diff --git a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
| index eb8799ff8e990522b002d7c2200193f39e1a8eea..c452ac355a0c99dd70d49a769b9f90d445ba7c87 100644 |
| --- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
| +++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
| @@ -4,11 +4,13 @@ |
| #include "base/macros.h" |
| #include "base/run_loop.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_window.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "content/public/test/test_utils.h" |
| +#include "extensions/browser/extension_system.h" |
| #include "extensions/common/extension.h" |
| #include "extensions/common/extension_builder.h" |
| #include "extensions/common/value_builder.h" |
| @@ -52,8 +54,12 @@ class TestExtensionUninstallDialogDelegate |
| typedef InProcessBrowserTest ExtensionUninstallDialogViewBrowserTest; |
| +// Following test does not apply on MACOSX. MACOSX have its own implementation |
| +// for dialog and view life circle. |
| +#if !defined(OS_MACOSX) |
|
Devlin
2016/11/14 17:49:12
By default, we don't use views on Mac. The only t
lgcheng
2016/11/14 19:10:33
Since this existing test is to verify dialog is de
|
| // Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window |
| -// which is passed to ExtensionUninstallDialog::Create() is destroyed. |
| +// which is passed to ExtensionUninstallDialog::Create() is destroyed before |
| +// ExtensionUninstallDialogDelegateView is created. |
| IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
| TrackParentWindowDestruction) { |
| // Create a second browser to prevent the app from exiting when the browser is |
| @@ -61,6 +67,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
| CreateBrowser(browser()->profile()); |
| scoped_refptr<extensions::Extension> extension(BuildTestExtension()); |
| + extensions::ExtensionSystem::Get(browser()->profile())->extension_service() |
| + ->AddExtension(extension.get()); |
| base::RunLoop run_loop; |
| TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure()); |
| @@ -77,3 +85,38 @@ IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
| run_loop.Run(); |
| EXPECT_TRUE(delegate.canceled()); |
| } |
| + |
| +// Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window |
| +// which is passed to ExtensionUninstallDialog::Create() is destroyed after |
| +// ExtensionUninstallDialogDelegateView is created. |
| +IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
| + TrackParentWindowDestructionAfterViewCreation) { |
| + // Create a second browser to prevent the app from exiting when the browser is |
| + // closed. |
| + CreateBrowser(browser()->profile()); |
| + |
| + scoped_refptr<extensions::Extension> extension(BuildTestExtension()); |
| + extensions::ExtensionSystem::Get(browser()->profile())->extension_service() |
| + ->AddExtension(extension.get()); |
| + |
| + base::RunLoop run_loop; |
| + TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure()); |
| + std::unique_ptr<extensions::ExtensionUninstallDialog> dialog( |
| + extensions::ExtensionUninstallDialog::Create( |
| + browser()->profile(), browser()->window()->GetNativeWindow(), |
| + &delegate)); |
| + content::RunAllPendingInMessageLoop(); |
| + |
| + dialog->ConfirmUninstall(extension.get(), |
| + extensions::UNINSTALL_REASON_FOR_TESTING, |
| + extensions::UNINSTALL_SOURCE_FOR_TESTING); |
| + |
| + content::RunAllPendingInMessageLoop(); |
| + |
| + // Kill parent window. |
| + browser()->window()->Close(); |
| + run_loop.Run(); |
| + EXPECT_TRUE(delegate.canceled()); |
| +} |
| + |
| +#endif // !defined(OS_MACOSX) |