| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" | 5 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" | 10 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 TEST_F(OneClickSigninBubbleViewTest, BubbleOkButton) { | 142 TEST_F(OneClickSigninBubbleViewTest, BubbleOkButton) { |
| 143 OneClickSigninBubbleView* view = | 143 OneClickSigninBubbleView* view = |
| 144 ShowOneClickSigninBubble( | 144 ShowOneClickSigninBubble( |
| 145 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 145 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 146 | 146 |
| 147 // Simulate pressing the OK button. Set the message loop in the bubble | 147 // Simulate pressing the OK button. Set the message loop in the bubble |
| 148 // view so that it can be quit once the bubble is hidden. | 148 // view so that it can be quit once the bubble is hidden. |
| 149 views::ButtonListener* listener = view; | 149 views::ButtonListener* listener = view; |
| 150 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 150 const ui::MouseEvent event( |
| 151 ui::EventTimeForNow(), 0, 0); | 151 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 152 0, 0, ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 152 listener->ButtonPressed(view->ok_button_, event); | 153 listener->ButtonPressed(view->ok_button_, event); |
| 153 | 154 |
| 154 // View should no longer be showing. The message loop will exit once the | 155 // View should no longer be showing. The message loop will exit once the |
| 155 // fade animation of the bubble is done. | 156 // fade animation of the bubble is done. |
| 156 content::RunAllPendingInMessageLoop(); | 157 content::RunAllPendingInMessageLoop(); |
| 157 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 158 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 158 } | 159 } |
| 159 | 160 |
| 160 TEST_F(OneClickSigninBubbleViewTest, DialogOkButton) { | 161 TEST_F(OneClickSigninBubbleViewTest, DialogOkButton) { |
| 161 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 162 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 162 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 163 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 163 | 164 |
| 164 // Simulate pressing the OK button. Set the message loop in the bubble | 165 // Simulate pressing the OK button. Set the message loop in the bubble |
| 165 // view so that it can be quit once the bubble is hidden. | 166 // view so that it can be quit once the bubble is hidden. |
| 166 views::ButtonListener* listener = view; | 167 views::ButtonListener* listener = view; |
| 167 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 168 const ui::MouseEvent event( |
| 168 ui::EventTimeForNow(), 0, 0); | 169 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 170 0, 0, ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 169 listener->ButtonPressed(view->ok_button_, event); | 171 listener->ButtonPressed(view->ok_button_, event); |
| 170 | 172 |
| 171 // View should no longer be showing and sync should start | 173 // View should no longer be showing and sync should start |
| 172 // The message loop will exit once the fade animation of the dialog is done. | 174 // The message loop will exit once the fade animation of the dialog is done. |
| 173 content::RunAllPendingInMessageLoop(); | 175 content::RunAllPendingInMessageLoop(); |
| 174 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 176 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 175 EXPECT_TRUE(on_start_sync_called_); | 177 EXPECT_TRUE(on_start_sync_called_); |
| 176 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); | 178 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); |
| 177 } | 179 } |
| 178 | 180 |
| 179 TEST_F(OneClickSigninBubbleViewTest, DialogUndoButton) { | 181 TEST_F(OneClickSigninBubbleViewTest, DialogUndoButton) { |
| 180 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 182 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 181 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 183 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 182 | 184 |
| 183 // Simulate pressing the undo button. Set the message loop in the bubble | 185 // Simulate pressing the undo button. Set the message loop in the bubble |
| 184 // view so that it can be quit once the bubble is hidden. | 186 // view so that it can be quit once the bubble is hidden. |
| 185 views::ButtonListener* listener = view; | 187 views::ButtonListener* listener = view; |
| 186 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 188 const ui::MouseEvent event( |
| 187 ui::EventTimeForNow(), 0, 0); | 189 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 190 0, 0, ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 188 listener->ButtonPressed(view->undo_button_, event); | 191 listener->ButtonPressed(view->undo_button_, event); |
| 189 | 192 |
| 190 // View should no longer be showing. The message loop will exit once the | 193 // View should no longer be showing. The message loop will exit once the |
| 191 // fade animation of the bubble is done. | 194 // fade animation of the bubble is done. |
| 192 content::RunAllPendingInMessageLoop(); | 195 content::RunAllPendingInMessageLoop(); |
| 193 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 196 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 194 EXPECT_TRUE(on_start_sync_called_); | 197 EXPECT_TRUE(on_start_sync_called_); |
| 195 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); | 198 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); |
| 196 } | 199 } |
| 197 | 200 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); | 316 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); |
| 314 view->AcceleratorPressed(accelerator); | 317 view->AcceleratorPressed(accelerator); |
| 315 | 318 |
| 316 // View should no longer be showing. The message loop will exit once the | 319 // View should no longer be showing. The message loop will exit once the |
| 317 // fade animation of the bubble is done. | 320 // fade animation of the bubble is done. |
| 318 content::RunAllPendingInMessageLoop(); | 321 content::RunAllPendingInMessageLoop(); |
| 319 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 322 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 320 EXPECT_TRUE(on_start_sync_called_); | 323 EXPECT_TRUE(on_start_sync_called_); |
| 321 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); | 324 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); |
| 322 } | 325 } |
| OLD | NEW |