Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" | |
| 6 | |
| 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" | |
| 14 | |
| 15 class OneClickSigninBubbleControllerTest : public InProcessBrowserTest { | |
| 16 public: | |
| 17 OneClickSigninBubbleControllerTest() | |
| 18 : InProcessBrowserTest(), | |
|
Alexei Svitkine (slow)
2013/04/24 15:26:27
Nit: I don't think you need to explicitly call the
noms (inactive)
2013/04/25 18:29:58
Done.
| |
| 19 controller_(NULL), | |
| 20 sync_mode_(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS), | |
| 21 callback_count_(0) { | |
| 22 } | |
| 23 | |
| 24 protected: | |
| 25 virtual void SetUpOnMainThread() OVERRIDE { | |
| 26 content::WebContents* web_contents = | |
| 27 browser()->tab_strip_model()->GetWebContentsAt(0); | |
| 28 BrowserWindow::StartSyncCallback callback = base::Bind( | |
| 29 &OneClickSigninBubbleControllerTest::OnStartSyncCallback, | |
| 30 base::Unretained(this)); | |
| 31 | |
| 32 BrowserWindowCocoa* browser_window = | |
| 33 static_cast<BrowserWindowCocoa*>(browser()->window()); | |
| 34 controller_.reset([[OneClickSigninBubbleController alloc] | |
| 35 initWithBrowserWindowController:browser_window->cocoa_controller() | |
| 36 webContents:web_contents | |
| 37 errorMessage:nil | |
| 38 callback:callback]); | |
| 39 [controller_ showWindow:nil]; | |
| 40 EXPECT_NSEQ(@"OneClickSigninBubble", | |
| 41 [[controller_ viewController] nibName]); | |
| 42 } | |
| 43 | |
| 44 scoped_nsobject<OneClickSigninBubbleController> controller_; | |
|
Alexei Svitkine (slow)
2013/04/24 15:26:27
Make all variables private and provide accessors t
| |
| 45 OneClickSigninSyncStarter::StartSyncMode sync_mode_; | |
|
Alexei Svitkine (slow)
2013/04/24 15:26:27
Are you using this anywhere?
noms (inactive)
2013/04/25 18:29:58
Done.
| |
| 46 int callback_count_; | |
| 47 | |
| 48 private: | |
| 49 void OnStartSyncCallback(OneClickSigninSyncStarter::StartSyncMode mode) { | |
| 50 sync_mode_ = mode; | |
| 51 ++callback_count_; | |
| 52 } | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest); | |
| 55 }; | |
| 56 | |
| 57 // Test that the bubble does not start sync if the OK button is clicked. | |
| 58 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, OK) { | |
| 59 [[controller_ viewController] ok:nil]; | |
| 60 EXPECT_EQ(0, callback_count_); | |
| 61 } | |
| 62 | |
| 63 // Test that the bubble does not start sync if the Undo button is clicked. | |
| 64 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Undo) { | |
| 65 [[controller_ viewController] onClickUndo:nil]; | |
| 66 EXPECT_EQ(0, callback_count_); | |
| 67 } | |
| 68 | |
| 69 // Test that the bubble does not start sync if the bubble is closed. | |
| 70 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Close) { | |
| 71 [controller_ close]; | |
| 72 EXPECT_EQ(0, callback_count_); | |
| 73 } | |
| 74 | |
| 75 // Test that the advanced page is opened in the current tab and that | |
| 76 // the bubble does not start sync. | |
| 77 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Advanced) { | |
| 78 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | |
| 79 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | |
| 80 [[controller_ viewController] onClickAdvancedLink:nil]; | |
| 81 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | |
| 82 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | |
| 83 EXPECT_EQ(0, callback_count_); | |
| 84 } | |
| 85 | |
| 86 // Test that clicking the learn more link opens a new tab and that | |
| 87 // the bubble does not start sync. | |
| 88 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, LearnMore) { | |
| 89 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | |
| 90 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | |
| 91 [[controller_ viewController] textView:nil | |
| 92 clickedOnLink:nil | |
|
Alexei Svitkine (slow)
2013/04/24 15:26:27
Nit: Align the :'s.
noms (inactive)
2013/04/25 18:29:58
Done.
| |
| 93 atIndex:0]; | |
| 94 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | |
| 95 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | |
| 96 EXPECT_EQ(0, callback_count_); | |
| 97 } | |
| OLD | NEW |