Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / extension_install_dialog_controller_browsertest.mm
blob3ba4616ffb106645b9a9bb760c3a99725379ca0f
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 {
18 public:
19   ExtensionInstallDialogControllerTest() {
20     extension_ = chrome::LoadInstallPromptExtension();
21   }
23  protected:
24   scoped_refptr<Extension> extension_;
27 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogControllerTest, BasicTest) {
28   content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
29   ExtensionInstallPrompt::ShowParams show_params(tab);
31   chrome::MockExtensionInstallPromptDelegate delegate;
32   ExtensionInstallPrompt::Prompt prompt =
33       chrome::BuildExtensionInstallPrompt(extension_.get());
35   ExtensionInstallDialogController* controller =
36       new ExtensionInstallDialogController(show_params,
37                                            &delegate,
38                                            prompt);
40   base::scoped_nsobject<NSWindow> window(
41       [[[controller->view_controller() view] window] retain]);
42   EXPECT_TRUE([window isVisible]);
44   // Press cancel to close the window
45   [[controller->view_controller() cancelButton] performClick:nil];
47   // Wait for the window to finish closing.
48   EXPECT_FALSE([window isVisible]);
51 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogControllerTest,
52                        DISABLED_Permissions) {
53   content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
54   ExtensionInstallPrompt::ShowParams show_params(tab);
56   chrome::MockExtensionInstallPromptDelegate delegate;
57   ExtensionInstallPrompt::Prompt prompt =
58       chrome::BuildExtensionPostInstallPermissionsPrompt(extension_.get());
60   ExtensionInstallDialogController* controller =
61       new ExtensionInstallDialogController(show_params,
62                                            &delegate,
63                                            prompt);
65   base::scoped_nsobject<NSWindow> window(
66       [[[controller->view_controller() view] window] retain]);
67   EXPECT_TRUE([window isVisible]);
69   // Press cancel to close the window
70   [[controller->view_controller() cancelButton] performClick:nil];
72   // Wait for the window to finish closing.
73   EXPECT_FALSE([window isVisible]);