| 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 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h
" | 5 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h
" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.
h" | 10 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.
h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 typedef InProcessBrowserTest WindowedInstallDialogControllerBrowserTest; | 30 typedef InProcessBrowserTest WindowedInstallDialogControllerBrowserTest; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 // Test for showing an extension install prompt with no parent WebContents. | 34 // Test for showing an extension install prompt with no parent WebContents. |
| 35 IN_PROC_BROWSER_TEST_F(WindowedInstallDialogControllerBrowserTest, | 35 IN_PROC_BROWSER_TEST_F(WindowedInstallDialogControllerBrowserTest, |
| 36 ShowInstallDialog) { | 36 ShowInstallDialog) { |
| 37 // Construct a prompt with a NULL parent window, the way ExtensionEnableFlow | 37 // Construct a prompt with a NULL parent window, the way ExtensionEnableFlow |
| 38 // will for the Mac app list. For testing, sets a NULL PageNavigator as well. | 38 // will for the Mac app list. For testing, sets a NULL PageNavigator as well. |
| 39 scoped_ptr<ExtensionInstallPrompt> prompt( | 39 scoped_ptr<ExtensionInstallPrompt> prompt( |
| 40 new ExtensionInstallPrompt(browser()->profile(), NULL, NULL)); | 40 new ExtensionInstallPrompt(browser()->profile(), NULL)); |
| 41 | 41 |
| 42 WindowedInstallDialogController* controller = NULL; | 42 WindowedInstallDialogController* controller = NULL; |
| 43 chrome::MockExtensionInstallPromptDelegate delegate; | 43 chrome::MockExtensionInstallPromptDelegate delegate; |
| 44 scoped_refptr<extensions::Extension> extension = | 44 scoped_refptr<extensions::Extension> extension = |
| 45 chrome::LoadInstallPromptExtension("permissions", "many-apis.json"); | 45 chrome::LoadInstallPromptExtension("permissions", "many-apis.json"); |
| 46 prompt->ConfirmInstall( | 46 prompt->ConfirmInstall( |
| 47 &delegate, | 47 &delegate, |
| 48 extension.get(), | 48 extension.get(), |
| 49 base::Bind(&TestingShowAppListInstallDialogController, &controller)); | 49 base::Bind(&TestingShowAppListInstallDialogController, &controller)); |
| 50 | 50 |
| 51 // The prompt needs to load the image, which happens on the blocking pool. | 51 // The prompt needs to load the image, which happens on the blocking pool. |
| 52 content::RunAllBlockingPoolTasksUntilIdle(); | 52 content::RunAllBlockingPoolTasksUntilIdle(); |
| 53 ASSERT_TRUE(controller); | 53 ASSERT_TRUE(controller); |
| 54 | 54 |
| 55 base::scoped_nsobject<NSWindow> window( | 55 base::scoped_nsobject<NSWindow> window( |
| 56 [[[controller->GetViewController() view] window] retain]); | 56 [[[controller->GetViewController() view] window] retain]); |
| 57 EXPECT_TRUE([window isVisible]); | 57 EXPECT_TRUE([window isVisible]); |
| 58 EXPECT_TRUE([window delegate]); | 58 EXPECT_TRUE([window delegate]); |
| 59 EXPECT_EQ(0, delegate.abort_count()); | 59 EXPECT_EQ(0, delegate.abort_count()); |
| 60 | 60 |
| 61 // Press cancel to close the window. | 61 // Press cancel to close the window. |
| 62 [[controller->GetViewController() cancelButton] performClick:nil]; | 62 [[controller->GetViewController() cancelButton] performClick:nil]; |
| 63 EXPECT_FALSE([window delegate]); | 63 EXPECT_FALSE([window delegate]); |
| 64 EXPECT_EQ(1, delegate.abort_count()); | 64 EXPECT_EQ(1, delegate.abort_count()); |
| 65 | 65 |
| 66 // Ensure the window is closed. | 66 // Ensure the window is closed. |
| 67 EXPECT_FALSE([window isVisible]); | 67 EXPECT_FALSE([window isVisible]); |
| 68 } | 68 } |
| OLD | NEW |