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" |
11 #import "base/memory/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 15 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h" |
15 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 16 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
16 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h" | |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #import "testing/gtest_mac.h" | 19 #import "testing/gtest_mac.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 using ::testing::_; | 23 using ::testing::_; |
24 | 24 |
25 class OneClickSigninBubbleControllerTest : public CocoaProfileTest { | 25 class OneClickSigninBubbleControllerTest : public CocoaProfileTest { |
26 public: | 26 public: |
(...skipping 20 matching lines...) Expand all Loading... |
47 virtual void TearDown() OVERRIDE { | 47 virtual void TearDown() OVERRIDE { |
48 controller_.reset(); | 48 controller_.reset(); |
49 CocoaProfileTest::TearDown(); | 49 CocoaProfileTest::TearDown(); |
50 } | 50 } |
51 | 51 |
52 MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode)); | 52 MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode)); |
53 | 53 |
54 protected: | 54 protected: |
55 base::WeakPtrFactory<OneClickSigninBubbleControllerTest> weak_ptr_factory_; | 55 base::WeakPtrFactory<OneClickSigninBubbleControllerTest> weak_ptr_factory_; |
56 BrowserWindow::StartSyncCallback start_sync_callback_; | 56 BrowserWindow::StartSyncCallback start_sync_callback_; |
57 scoped_nsobject<OneClickSigninBubbleController> controller_; | 57 base::scoped_nsobject<OneClickSigninBubbleController> controller_; |
58 | 58 |
59 private: | 59 private: |
60 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest); | 60 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest); |
61 }; | 61 }; |
62 | 62 |
63 // Test that the bubble does not sync if the OK button is clicked. | 63 // Test that the bubble does not sync if the OK button is clicked. |
64 TEST_F(OneClickSigninBubbleControllerTest, OK) { | 64 TEST_F(OneClickSigninBubbleControllerTest, OK) { |
65 EXPECT_CALL(*this, OnStartSync( | 65 EXPECT_CALL(*this, OnStartSync( |
66 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(0); | 66 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(0); |
67 [[controller_ viewController] ok:nil]; | 67 [[controller_ viewController] ok:nil]; |
68 } | 68 } |
69 | 69 |
70 // Test that the bubble does not sync if the Undo button | 70 // Test that the bubble does not sync if the Undo button |
71 // is clicked. Callback should be called to abort the sync. | 71 // is clicked. Callback should be called to abort the sync. |
72 TEST_F(OneClickSigninBubbleControllerTest, Undo) { | 72 TEST_F(OneClickSigninBubbleControllerTest, Undo) { |
73 EXPECT_CALL(*this, OnStartSync( | 73 EXPECT_CALL(*this, OnStartSync( |
74 OneClickSigninSyncStarter::UNDO_SYNC)).Times(0); | 74 OneClickSigninSyncStarter::UNDO_SYNC)).Times(0); |
75 [[controller_ viewController] onClickUndo:nil]; | 75 [[controller_ viewController] onClickUndo:nil]; |
76 } | 76 } |
77 | 77 |
78 // Test that the bubble does not sync if the bubble is closed. | 78 // Test that the bubble does not sync if the bubble is closed. |
79 TEST_F(OneClickSigninBubbleControllerTest, Close) { | 79 TEST_F(OneClickSigninBubbleControllerTest, Close) { |
80 EXPECT_CALL(*this, OnStartSync( | 80 EXPECT_CALL(*this, OnStartSync( |
81 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(0); | 81 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(0); |
82 [controller_ close]; | 82 [controller_ close]; |
83 } | 83 } |
84 | 84 |
85 } // namespace | 85 } // namespace |
OLD | NEW |