Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 start_sync_callback_( | 29 start_sync_callback_( |
| 30 base::Bind(&OneClickSigninBubbleControllerTest::OnStartSync, | 30 base::Bind(&OneClickSigninBubbleControllerTest::OnStartSync, |
| 31 weak_ptr_factory_.GetWeakPtr())) {} | 31 weak_ptr_factory_.GetWeakPtr())) {} |
| 32 | 32 |
| 33 virtual void SetUp() OVERRIDE { | 33 virtual void SetUp() OVERRIDE { |
| 34 CocoaProfileTest::SetUp(); | 34 CocoaProfileTest::SetUp(); |
| 35 BrowserWindowCocoa* browser_window = | 35 BrowserWindowCocoa* browser_window = |
| 36 static_cast<BrowserWindowCocoa*>(browser()->window()); | 36 static_cast<BrowserWindowCocoa*>(browser()->window()); |
| 37 controller_.reset([[OneClickSigninBubbleController alloc] | 37 controller_.reset([[OneClickSigninBubbleController alloc] |
| 38 initWithBrowserWindowController:browser_window->cocoa_controller() | 38 initWithBrowserWindowController:browser_window->cocoa_controller() |
| 39 webContents:nil | |
| 40 errorMessage:nil | |
| 39 callback:start_sync_callback_]); | 41 callback:start_sync_callback_]); |
| 40 [controller_ showWindow:nil]; | 42 [controller_ showWindow:nil]; |
| 41 EXPECT_NSEQ(@"OneClickSigninBubble", | 43 EXPECT_NSEQ(@"OneClickSigninBubble", |
| 42 [[controller_ viewController] nibName]); | 44 [[controller_ viewController] nibName]); |
| 43 } | 45 } |
| 44 | 46 |
| 45 virtual void TearDown() OVERRIDE { | 47 virtual void TearDown() OVERRIDE { |
| 46 controller_.reset(); | 48 controller_.reset(); |
| 47 CocoaProfileTest::TearDown(); | 49 CocoaProfileTest::TearDown(); |
| 48 } | 50 } |
| 49 | 51 |
| 50 MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode)); | 52 MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode)); |
| 51 | 53 |
| 52 protected: | 54 protected: |
| 53 base::WeakPtrFactory<OneClickSigninBubbleControllerTest> weak_ptr_factory_; | 55 base::WeakPtrFactory<OneClickSigninBubbleControllerTest> weak_ptr_factory_; |
| 54 BrowserWindow::StartSyncCallback start_sync_callback_; | 56 BrowserWindow::StartSyncCallback start_sync_callback_; |
| 55 scoped_nsobject<OneClickSigninBubbleController> controller_; | 57 scoped_nsobject<OneClickSigninBubbleController> controller_; |
| 56 | 58 |
| 57 private: | 59 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest); | 60 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest); |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 // Test that the bubble calls the callback if the OK button is clicked. | 63 // Test that the bubble does not sync if the OK button is clicked. |
| 62 // Callback should be called to setup sync with default settings. | |
| 63 TEST_F(OneClickSigninBubbleControllerTest, OK) { | 64 TEST_F(OneClickSigninBubbleControllerTest, OK) { |
| 64 EXPECT_CALL(*this, OnStartSync( | 65 EXPECT_CALL(*this, OnStartSync( |
| 65 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)); | 66 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(0); |
| 66 [[controller_ viewController] ok:nil]; | 67 [[controller_ viewController] ok:nil]; |
| 67 } | 68 } |
| 68 | 69 |
| 69 // Test that the dialog calls the callback if the Undo button | 70 // Test that the bubble does not sync if the Undo button |
| 70 // is clicked. Callback should be called to abort the sync. | 71 // is clicked. Callback should be called to abort the sync. |
| 71 TEST_F(OneClickSigninBubbleControllerTest, Undo) { | 72 TEST_F(OneClickSigninBubbleControllerTest, Undo) { |
| 72 EXPECT_CALL(*this, OnStartSync( | 73 EXPECT_CALL(*this, OnStartSync( |
| 73 OneClickSigninSyncStarter::UNDO_SYNC)).Times(1); | 74 OneClickSigninSyncStarter::UNDO_SYNC)).Times(0); |
| 74 [[controller_ viewController] onClickUndo:nil]; | 75 [[controller_ viewController] onClickUndo:nil]; |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Test that the advanced callback is run if its corresponding button | 78 // Test that the bubble does not sync if the bubble is closed. |
| 78 // is clicked. | |
| 79 TEST_F(OneClickSigninBubbleControllerTest, Advanced) { | |
|
Alexei Svitkine (slow)
2013/04/23 19:43:24
Why is this test being deleted?
noms (inactive)
2013/04/24 14:49:30
The new code for the Advanced link event handler o
| |
| 80 EXPECT_CALL(*this, OnStartSync( | |
| 81 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST)); | |
| 82 [[controller_ viewController] onClickAdvancedLink:nil]; | |
| 83 } | |
| 84 | |
| 85 // Test that the bubble calls the callback if the bubble is closed. | |
| 86 // Callback should be called to setup sync with default settings. | |
| 87 TEST_F(OneClickSigninBubbleControllerTest, Close) { | 79 TEST_F(OneClickSigninBubbleControllerTest, Close) { |
| 88 EXPECT_CALL(*this, OnStartSync( | 80 EXPECT_CALL(*this, OnStartSync( |
| 89 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)); | 81 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(0); |
| 90 [controller_ close]; | 82 [controller_ close]; |
| 91 } | 83 } |
| 92 | 84 |
| 93 } // namespace | 85 } // namespace |
| OLD | NEW |