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..e3fa23f1c9647e8b63b8e48720bd4cbdd6f8fc3b 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,15 +54,18 @@ class TestExtensionUninstallDialogDelegate |
typedef InProcessBrowserTest ExtensionUninstallDialogViewBrowserTest; |
+// Following test does not apply on MACOSX. MACOSX have its own implementation |
msw
2016/11/15 00:09:32
grammar nits: "The following tests do not apply to
|
+// for dialog and view life circle. |
+#if !defined(OS_MACOSX) |
lgcheng
2016/11/14 23:51:41
This test won't run on MAC.
1. It run on MAC befo
msw
2016/11/15 00:09:32
extension_uninstall_dialog_cocoa should not be use
tapted
2016/11/15 00:30:14
Try adding
#if defined(OS_MACOSX)
#include "chro
|
+ |
// 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 |
- // 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()); |
@@ -77,3 +82,34 @@ 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) { |
+ 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) |