1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
9 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.h"
10 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "extensions/common/extension.h"
15 using extensions::Extension;
17 class ExtensionInstallDialogControllerTest : public InProcessBrowserTest {
19 ExtensionInstallDialogControllerTest() {}
21 virtual void SetUpOnMainThread() OVERRIDE {
22 extension_ = chrome::LoadInstallPromptExtension();
26 scoped_refptr<Extension> extension_;
29 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogControllerTest, BasicTest) {
30 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
31 ExtensionInstallPrompt::ShowParams show_params(tab);
33 chrome::MockExtensionInstallPromptDelegate delegate;
34 ExtensionInstallPrompt::Prompt prompt =
35 chrome::BuildExtensionInstallPrompt(extension_.get());
37 ExtensionInstallDialogController* controller =
38 new ExtensionInstallDialogController(show_params,
42 base::scoped_nsobject<NSWindow> window(
43 [[[controller->view_controller() view] window] retain]);
44 EXPECT_TRUE([window isVisible]);
46 // Press cancel to close the window
47 [[controller->view_controller() cancelButton] performClick:nil];
49 // Wait for the window to finish closing.
50 EXPECT_FALSE([window isVisible]);
53 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogControllerTest,
54 DISABLED_Permissions) {
55 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
56 ExtensionInstallPrompt::ShowParams show_params(tab);
58 chrome::MockExtensionInstallPromptDelegate delegate;
59 ExtensionInstallPrompt::Prompt prompt =
60 chrome::BuildExtensionPostInstallPermissionsPrompt(extension_.get());
62 ExtensionInstallDialogController* controller =
63 new ExtensionInstallDialogController(show_params,
67 base::scoped_nsobject<NSWindow> window(
68 [[[controller->view_controller() view] window] retain]);
69 EXPECT_TRUE([window isVisible]);
71 // Press cancel to close the window
72 [[controller->view_controller() cancelButton] performClick:nil];
74 // Wait for the window to finish closing.
75 EXPECT_FALSE([window isVisible]);