Chromium Code Reviews| Index: chrome/browser/ui/cocoa/one_click_signin_bubble_controller_unittest.mm |
| diff --git a/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_unittest.mm |
| index 93f7ed104d0ae278cab94f45e206f487eb69398d..7b6f9435da54d1b156b11b7bc17e850cc29acc52 100644 |
| --- a/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_unittest.mm |
| @@ -12,21 +12,21 @@ |
| #include "base/memory/weak_ptr.h" |
| #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| +#include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #import "testing/gtest_mac.h" |
| +using testing::_; |
|
Peter Kasting
2012/05/24 22:25:18
Nit: Just explicitly-qualify the one usage
Roger Tawa OOO till Jul 10th
2012/05/25 16:04:08
Done.
|
| + |
| namespace { |
| class OneClickSigninBubbleControllerTest : public CocoaProfileTest { |
| public: |
| OneClickSigninBubbleControllerTest() |
| : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| - learn_more_callback_( |
| - base::Bind(&OneClickSigninBubbleControllerTest::OnLearnMore, |
| - weak_ptr_factory_.GetWeakPtr())), |
| - advanced_callback_( |
| - base::Bind(&OneClickSigninBubbleControllerTest::OnAdvanced, |
| + start_sync_callback_( |
| + base::Bind(&OneClickSigninBubbleControllerTest::OnStartSync, |
| weak_ptr_factory_.GetWeakPtr())) {} |
| virtual void SetUp() { |
| @@ -36,8 +36,7 @@ class OneClickSigninBubbleControllerTest : public CocoaProfileTest { |
| controller_.reset( |
| [[OneClickSigninBubbleController alloc] |
| initWithBrowserWindowController:browser_window->cocoa_controller() |
| - learnMoreCallback:learn_more_callback_ |
| - advancedCallback:advanced_callback_]); |
| + start_sync_callback:start_sync_callback_]); |
| } |
| virtual void TearDown() { |
| @@ -45,70 +44,47 @@ class OneClickSigninBubbleControllerTest : public CocoaProfileTest { |
| CocoaProfileTest::TearDown(); |
| } |
| - MOCK_METHOD0(OnLearnMore, void()); |
| - MOCK_METHOD0(OnAdvanced, void()); |
| + MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode)); |
| protected: |
| base::WeakPtrFactory<OneClickSigninBubbleControllerTest> weak_ptr_factory_; |
| - base::Closure learn_more_callback_; |
| - base::Closure advanced_callback_; |
| + BrowserWindow::StartSyncCallback start_sync_callback_; |
| scoped_nsobject<OneClickSigninBubbleController> controller_; |
| }; |
| // Test that the dialog loads from its nib properly. |
| TEST_F(OneClickSigninBubbleControllerTest, NibLoad) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(0); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(0); |
| + EXPECT_CALL(*this, OnStartSync(_)).Times(0); |
| // Force nib load. |
| [controller_ window]; |
| EXPECT_NSEQ(@"OneClickSigninBubble", [controller_ windowNibName]); |
| } |
| -// Test that the dialog doesn't call any callback if the OK button is |
| -// clicked. |
| +// Test that the dialog calls the callback if the OK button is clicked. |
| TEST_F(OneClickSigninBubbleControllerTest, ShowAndOK) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(0); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(0); |
| + EXPECT_CALL(*this, |
| + OnStartSync( |
|
Peter Kasting
2012/05/24 22:25:18
Nit: Weird indenting; how about:
EXPECT_CALL(*t
Roger Tawa OOO till Jul 10th
2012/05/25 16:04:08
That leaves the second line beyond 80 chars. The
Peter Kasting
2012/05/25 16:58:06
No it doesn't:
1234567890123456789012345678901234
Roger Tawa OOO till Jul 10th
2012/05/25 18:49:51
Done.
|
| + OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)). |
| + Times(1); |
| [controller_ showWindow:nil]; |
| [controller_.release() ok:nil]; |
| } |
| -// Test that the learn more callback is run if its corresponding |
| +// TODO(akalin): Test that the dialog doesn't calls the callback if the Undo |
|
Peter Kasting
2012/05/24 22:25:18
Nit: calls -> call
Roger Tawa OOO till Jul 10th
2012/05/25 16:04:08
Done.
|
| // button is clicked. |
| -TEST_F(OneClickSigninBubbleControllerTest, ShowAndClickLearnMore) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(1); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(0); |
| - |
| - [controller_ showWindow:nil]; |
| - [controller_ onClickLearnMoreLink:nil]; |
| - [controller_.release() ok:nil]; |
| -} |
| // Test that the advanced callback is run if its corresponding button |
| // is clicked. |
| TEST_F(OneClickSigninBubbleControllerTest, ShowAndClickAdvanced) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(0); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(1); |
| - |
| - [controller_ showWindow:nil]; |
| - [controller_ onClickAdvancedLink:nil]; |
| - [controller_.release() ok:nil]; |
| -} |
| - |
| -// Test that the callbacks can be run multiple times. |
| -TEST_F(OneClickSigninBubbleControllerTest, ShowAndClickMultiple) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(3); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(4); |
| + EXPECT_CALL(*this, |
| + OnStartSync( |
| + OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST)). |
| + Times(1); |
| [controller_ showWindow:nil]; |
| - for (int i = 0; i < 3; ++i) { |
| - [controller_ onClickLearnMoreLink:nil]; |
| - [controller_ onClickAdvancedLink:nil]; |
| - } |
| - [controller_ onClickAdvancedLink:nil]; |
| - [controller_.release() ok:nil]; |
| + [controller_.release() onClickAdvancedLink:nil]; |
| } |
| } // namespace |