Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / one_click_signin_bubble_controller_browsertest.mm
blob3b6eff277423024a5d49c0bc65e2b47af168bf0d
1 // Copyright (c) 2013 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/one_click_signin_bubble_controller.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_finder.h"
9 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
10 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #import "testing/gtest_mac.h"
15 class OneClickSigninBubbleControllerTest : public InProcessBrowserTest {
16  public:
17   OneClickSigninBubbleControllerTest()
18     : controller_(NULL),
19       callback_count_(0) {
20   }
22  protected:
23   void SetUpOnMainThread() override {
24     content::WebContents* web_contents =
25         browser()->tab_strip_model()->GetWebContentsAt(0);
26     BrowserWindow::StartSyncCallback callback = base::Bind(
27         &OneClickSigninBubbleControllerTest::OnStartSyncCallback,
28         base::Unretained(this));
30     BrowserWindowCocoa* browser_window =
31         static_cast<BrowserWindowCocoa*>(browser()->window());
32     controller_.reset([[OneClickSigninBubbleController alloc]
33             initWithBrowserWindowController:browser_window->cocoa_controller()
34                                 webContents:web_contents
35                                errorMessage:nil
36                                    callback:callback]);
37     [controller_ showWindow:nil];
38     EXPECT_NSEQ(@"OneClickSigninBubble",
39                 [[controller_ viewController] nibName]);
40   }
42   base::scoped_nsobject<OneClickSigninBubbleController> controller_;
43   int callback_count_;
45  private:
46   void OnStartSyncCallback(OneClickSigninSyncStarter::StartSyncMode mode) {
47     ++callback_count_;
48   }
50   DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest);
53 // Test that the bubble does not start sync if the OK button is clicked.
54 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, OK) {
55   [[controller_ viewController] ok:nil];
56   EXPECT_EQ(0, callback_count_);
59 // Test that the bubble does not start sync if the Undo button is clicked.
60 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Undo) {
61   [[controller_ viewController] onClickUndo:nil];
62   EXPECT_EQ(0, callback_count_);
65 // Test that the bubble does not start sync if the bubble is closed.
66 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Close) {
67   [controller_ close];
68   EXPECT_EQ(0, callback_count_);
71 // Test that the advanced page is opened in the current tab and that
72 // the bubble does not start sync.
73 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Advanced) {
74   EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
75   EXPECT_EQ(1, browser()->tab_strip_model()->count());
76   [[controller_ viewController] onClickAdvancedLink:nil];
77   EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
78   EXPECT_EQ(1, browser()->tab_strip_model()->count());
79   EXPECT_EQ(0, callback_count_);
82 // Test that clicking the learn more link opens a new tab and that
83 // the bubble does not start sync.
84 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, LearnMore) {
85   EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
86   EXPECT_EQ(1, browser()->tab_strip_model()->count());
87   [[controller_ viewController] textView:nil
88                            clickedOnLink:nil
89                                  atIndex:0];
90   EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
91   EXPECT_EQ(2, browser()->tab_strip_model()->count());
92   EXPECT_EQ(0, callback_count_);