Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / extension_install_dialog_controller_browsertest.mm
blob9197c055f74fb971c804c59cd56ae2497152ee72
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/extensions/extension_install_prompt_show_params.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
10 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.h"
11 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "extensions/common/extension.h"
16 using extensions::Extension;
18 class ExtensionInstallDialogControllerTest : public InProcessBrowserTest {
19 public:
20   ExtensionInstallDialogControllerTest() {}
22   void SetUpOnMainThread() override {
23     extension_ = chrome::LoadInstallPromptExtension();
24   }
26  protected:
27   scoped_refptr<Extension> extension_;
30 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogControllerTest, BasicTest) {
31   content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
32   ExtensionInstallPromptShowParams show_params(tab);
34   chrome::MockExtensionInstallPromptDelegate delegate;
35   scoped_refptr<ExtensionInstallPrompt::Prompt> prompt =
36       chrome::BuildExtensionInstallPrompt(extension_.get());
38   ExtensionInstallDialogController* controller =
39       new ExtensionInstallDialogController(&show_params,
40                                            &delegate,
41                                            prompt);
43   base::scoped_nsobject<NSWindow> window(
44       [[[controller->view_controller() view] window] retain]);
45   EXPECT_TRUE([window isVisible]);
47   // Press cancel to close the window
48   [[controller->view_controller() cancelButton] performClick:nil];
50   // Wait for the window to finish closing.
51   EXPECT_FALSE([window isVisible]);
54 IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogControllerTest,
55                        DISABLED_Permissions) {
56   content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
57   ExtensionInstallPromptShowParams show_params(tab);
59   chrome::MockExtensionInstallPromptDelegate delegate;
60   scoped_refptr<ExtensionInstallPrompt::Prompt> prompt =
61       chrome::BuildExtensionPostInstallPermissionsPrompt(extension_.get());
63   ExtensionInstallDialogController* controller =
64       new ExtensionInstallDialogController(&show_params,
65                                            &delegate,
66                                            prompt);
68   base::scoped_nsobject<NSWindow> window(
69       [[[controller->view_controller() view] window] retain]);
70   EXPECT_TRUE([window isVisible]);
72   // Press cancel to close the window
73   [[controller->view_controller() cancelButton] performClick:nil];
75   // Wait for the window to finish closing.
76   EXPECT_FALSE([window isVisible]);