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..bf52e64e4d8e63751efc272c813452012061bec4 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 |
| @@ -22,11 +22,8 @@ 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 +33,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 +41,60 @@ class OneClickSigninBubbleControllerTest : public CocoaProfileTest { |
| CocoaProfileTest::TearDown(); |
| } |
| - MOCK_METHOD0(OnLearnMore, void()); |
| - MOCK_METHOD0(OnAdvanced, void()); |
| + MOCK_METHOD1(OnStartSync, void(bool)); |
| protected: |
| base::WeakPtrFactory<OneClickSigninBubbleControllerTest> weak_ptr_factory_; |
| - base::Closure learn_more_callback_; |
| - base::Closure advanced_callback_; |
| + base::Callback<void(bool)> 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); |
|
akalin
2012/05/17 00:39:24
you want _
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
Done.
|
| // 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(true)).Times(1); |
| [controller_ showWindow:nil]; |
| [controller_.release() ok:nil]; |
| } |
| -// Test that the learn more callback is run if its corresponding |
| -// button is clicked. |
| -TEST_F(OneClickSigninBubbleControllerTest, ShowAndClickLearnMore) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(1); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(0); |
| +// Test that the dialog doesn't calls the callback if the Undo button is |
| +// clicked. |
| +TEST_F(OneClickSigninBubbleControllerTest, ShowAndUndo) { |
| + EXPECT_CALL(*this, OnStartSync(testing::_)).Times(0); |
|
akalin
2012/05/17 00:39:24
put 'using ::testing::_;' at top of file
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
Done.
|
| [controller_ showWindow:nil]; |
| - [controller_ onClickLearnMoreLink:nil]; |
| - [controller_.release() ok:nil]; |
| + [controller_.release() undo: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); |
| + EXPECT_CALL(*this, OnStartSync(false)).Times(1); |
| [controller_ showWindow:nil]; |
| [controller_ onClickAdvancedLink:nil]; |
| - [controller_.release() ok:nil]; |
| + [controller_.release() close:nil]; |
|
akalin
2012/05/17 00:39:24
you'll want to remove the close line and instead h
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
Done.
|
| } |
| // Test that the callbacks can be run multiple times. |
| +// TODO(rogerta: what is the point of this test? |
|
akalin
2012/05/17 00:39:24
if you change the advanced handler to auto-close,
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
Added a TODO comment.
|
| TEST_F(OneClickSigninBubbleControllerTest, ShowAndClickMultiple) { |
| - EXPECT_CALL(*this, OnLearnMore()).Times(3); |
| - EXPECT_CALL(*this, OnAdvanced()).Times(4); |
| + EXPECT_CALL(*this, OnStartSync(false)).Times(3); |
| [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() close:nil]; |
| } |
| } // namespace |