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..80f40fd8d42d0c99febd68d690ef841a86b5d948 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 |
| @@ -9,6 +9,7 @@ |
| #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_registry.h" |
| #include "extensions/common/extension.h" |
| #include "extensions/common/extension_builder.h" |
| #include "extensions/common/value_builder.h" |
| @@ -53,7 +54,8 @@ class TestExtensionUninstallDialogDelegate |
| typedef InProcessBrowserTest ExtensionUninstallDialogViewBrowserTest; |
| // 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 |
| @@ -68,7 +70,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
| extensions::ExtensionUninstallDialog::Create( |
| browser()->profile(), browser()->window()->GetNativeWindow(), |
| &delegate)); |
|
lgcheng
2016/11/03 22:30:50
This test is still working with what I have change
Devlin
2016/11/05 06:26:18
Yeah, we should make sure the extension is added.
lgcheng
2016/11/10 21:39:51
Done.
|
| - browser()->window()->Close(); |
| +// browser()->window()->Close(); |
| content::RunAllPendingInMessageLoop(); |
| dialog->ConfirmUninstall(extension.get(), |
| @@ -77,3 +79,41 @@ 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::ExtensionRegistry* registry = |
|
lgcheng
2016/11/03 22:30:50
Add extension to ExtensionRegistry so that uninsta
Devlin
2016/11/05 06:26:18
Doing
ExtensionSystem::Get(browser()->profile())->
lgcheng
2016/11/10 21:39:51
Done.
|
| + extensions::ExtensionRegistry::Get(browser()->profile()); |
| + DCHECK(registry); |
| + |
| + std::string extension_id = extension->id(); |
| + DCHECK(registry->AddEnabled(extension)); |
|
Devlin
2016/11/05 06:26:18
moot with the above comment, but prefer ASSERT_TRU
lgcheng
2016/11/10 21:39:51
Done.
|
| + |
| + 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( |
| + registry->GetExtensionById(extension_id, |
| + extensions::ExtensionRegistry::EVERYTHING), |
| + extensions::UNINSTALL_REASON_FOR_TESTING, |
| + extensions::UNINSTALL_SOURCE_FOR_TESTING); |
| + |
|
lgcheng
2016/11/03 22:30:50
The test fails on Mac because on Mac it has differ
|
| + // Kill parent window. |
| + browser()->window()->Close(); |
| + |
| + run_loop.Run(); |
| + EXPECT_TRUE(delegate.canceled()); |
| +} |