| OLD | NEW |
| 1 // Copyright (c) 2012 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 "chrome/browser/ui/browser.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | |
| 12 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/common/page_transition_types.h" | 12 #include "content/public/common/page_transition_types.h" |
| 14 #include "ui/views/controls/button/label_button.h" | 13 #include "ui/views/controls/button/label_button.h" |
| 14 #include "ui/views/test/views_test_base.h" |
| 15 #include "ui/views/widget/widget.h" |
| 15 | 16 |
| 16 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest { | 17 class OneClickSigninBubbleViewTest : public views::ViewsTestBase, |
| 18 public views::WidgetDelegate { |
| 17 public: | 19 public: |
| 18 OneClickSigninBubbleViewBrowserTest() | 20 OneClickSigninBubbleViewTest() |
| 19 : on_start_sync_called_(false), | 21 : on_start_sync_called_(false), |
| 20 mode_(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST) { | 22 mode_(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST), |
| 23 bubble_learn_more_click_count_(0), |
| 24 dialog_learn_more_click_count_(0), |
| 25 advanced_click_count_(0), |
| 26 anchor_view_(NULL) { |
| 21 } | 27 } |
| 22 | 28 |
| 29 virtual void SetUp() OVERRIDE { |
| 30 views::ViewsTestBase::SetUp(); |
| 31 |
| 32 anchor_view_ = new views::View(); |
| 33 |
| 34 // Create a widget to host the anchor view. |
| 35 views::Widget* widget = new views::Widget; |
| 36 views::Widget::InitParams widget_params = CreateParams( |
| 37 views::Widget::InitParams::TYPE_WINDOW); |
| 38 widget_params.delegate = this; |
| 39 widget->Init(widget_params); |
| 40 widget->Show(); |
| 41 } |
| 42 |
| 43 virtual void TearDown() OVERRIDE { |
| 44 OneClickSigninBubbleView::Hide(); |
| 45 GetWidget()->Close(); |
| 46 views::ViewsTestBase::TearDown(); |
| 47 } |
| 48 |
| 49 protected: |
| 23 OneClickSigninBubbleView* ShowOneClickSigninBubble( | 50 OneClickSigninBubbleView* ShowOneClickSigninBubble( |
| 24 BrowserWindow::OneClickSigninBubbleType bubble_type) { | 51 BrowserWindow::OneClickSigninBubbleType bubble_type) { |
| 25 browser()->window()->ShowOneClickSigninBubble( | 52 |
| 53 scoped_ptr<OneClickSigninBubbleDelegate> delegate; |
| 54 delegate.reset(new OneClickSigninBubbleTestDelegate(this)); |
| 55 |
| 56 OneClickSigninBubbleView::ShowBubble( |
| 26 bubble_type, | 57 bubble_type, |
| 27 string16(), | 58 string16(), |
| 28 string16(), | 59 string16(), |
| 29 base::Bind(&OneClickSigninBubbleViewBrowserTest::OnStartSync, this)); | 60 delegate.Pass(), |
| 61 anchor_view_, |
| 62 base::Bind(&OneClickSigninBubbleViewTest::OnStartSync, |
| 63 base::Unretained(this))); |
| 30 | 64 |
| 31 OneClickSigninBubbleView* view = | 65 OneClickSigninBubbleView* view = |
| 32 OneClickSigninBubbleView::view_for_testing(); | 66 OneClickSigninBubbleView::view_for_testing(); |
| 33 EXPECT_TRUE(view != NULL); | 67 EXPECT_TRUE(view != NULL); |
| 34 view->message_loop_for_testing_ = base::MessageLoop::current(); | 68 view->message_loop_for_testing_ = base::MessageLoop::current(); |
| 35 return view; | 69 return view; |
| 36 } | 70 } |
| 37 | 71 |
| 38 void OnStartSync(OneClickSigninSyncStarter::StartSyncMode mode) { | 72 void OnStartSync(OneClickSigninSyncStarter::StartSyncMode mode) { |
| 39 on_start_sync_called_ = true; | 73 on_start_sync_called_ = true; |
| 40 mode_ = mode; | 74 mode_ = mode; |
| 41 } | 75 } |
| 42 | 76 |
| 43 protected: | |
| 44 bool on_start_sync_called_; | 77 bool on_start_sync_called_; |
| 45 OneClickSigninSyncStarter::StartSyncMode mode_; | 78 OneClickSigninSyncStarter::StartSyncMode mode_; |
| 79 int bubble_learn_more_click_count_; |
| 80 int dialog_learn_more_click_count_; |
| 81 int advanced_click_count_; |
| 46 | 82 |
| 47 private: | 83 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest); | 84 friend class OneClickSigninBubbleTestDelegate; |
| 85 |
| 86 class OneClickSigninBubbleTestDelegate |
| 87 : public OneClickSigninBubbleDelegate { |
| 88 public: |
| 89 // |test| is not owned by this object. |
| 90 explicit OneClickSigninBubbleTestDelegate( |
| 91 OneClickSigninBubbleViewTest* test) : test_(test) {} |
| 92 |
| 93 // OneClickSigninBubbleDelegate: |
| 94 virtual void OnLearnMoreLinkClicked(bool is_dialog) OVERRIDE { |
| 95 if (is_dialog) |
| 96 ++test_->dialog_learn_more_click_count_; |
| 97 else |
| 98 ++test_->bubble_learn_more_click_count_; |
| 99 } |
| 100 virtual void OnAdvancedLinkClicked() OVERRIDE { |
| 101 ++test_->advanced_click_count_; |
| 102 } |
| 103 |
| 104 private: |
| 105 OneClickSigninBubbleViewTest* test_; |
| 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleTestDelegate); |
| 108 }; |
| 109 |
| 110 // views::WidgetDelegate: |
| 111 virtual views::View* GetContentsView() OVERRIDE { |
| 112 return anchor_view_; |
| 113 } |
| 114 |
| 115 virtual views::Widget* GetWidget() OVERRIDE { |
| 116 return anchor_view_->GetWidget(); |
| 117 } |
| 118 |
| 119 virtual const views::Widget* GetWidget() const OVERRIDE { |
| 120 return anchor_view_->GetWidget(); |
| 121 } |
| 122 |
| 123 // Anchor view of the bubble. |
| 124 views::View* anchor_view_; |
| 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewTest); |
| 49 }; | 127 }; |
| 50 | 128 |
| 51 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, ShowBubble) { | 129 TEST_F(OneClickSigninBubbleViewTest, ShowBubble) { |
| 52 ShowOneClickSigninBubble(BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 130 ShowOneClickSigninBubble(BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 53 content::RunAllPendingInMessageLoop(); | 131 content::RunAllPendingInMessageLoop(); |
| 54 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); | 132 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); |
| 55 } | 133 } |
| 56 | 134 |
| 57 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, ShowDialog) { | 135 TEST_F(OneClickSigninBubbleViewTest, ShowDialog) { |
| 58 ShowOneClickSigninBubble( | 136 ShowOneClickSigninBubble( |
| 59 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 137 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 60 content::RunAllPendingInMessageLoop(); | 138 content::RunAllPendingInMessageLoop(); |
| 61 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); | 139 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); |
| 62 } | 140 } |
| 63 | 141 |
| 64 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, HideBubble) { | 142 TEST_F(OneClickSigninBubbleViewTest, HideBubble) { |
| 65 ShowOneClickSigninBubble(BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 143 ShowOneClickSigninBubble(BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 66 | 144 |
| 67 OneClickSigninBubbleView::Hide(); | 145 OneClickSigninBubbleView::Hide(); |
| 68 content::RunAllPendingInMessageLoop(); | 146 content::RunAllPendingInMessageLoop(); |
| 69 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 147 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 70 } | 148 } |
| 71 | 149 |
| 72 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, HideDialog) { | 150 TEST_F(OneClickSigninBubbleViewTest, HideDialog) { |
| 73 ShowOneClickSigninBubble( | 151 ShowOneClickSigninBubble( |
| 74 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 152 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 75 | 153 |
| 76 OneClickSigninBubbleView::Hide(); | 154 OneClickSigninBubbleView::Hide(); |
| 77 content::RunAllPendingInMessageLoop(); | 155 content::RunAllPendingInMessageLoop(); |
| 78 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 156 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 79 EXPECT_TRUE(on_start_sync_called_); | 157 EXPECT_TRUE(on_start_sync_called_); |
| 80 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); | 158 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); |
| 81 } | 159 } |
| 82 | 160 |
| 83 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, BubbleOkButton) { | 161 TEST_F(OneClickSigninBubbleViewTest, BubbleOkButton) { |
| 84 OneClickSigninBubbleView* view = | 162 OneClickSigninBubbleView* view = |
| 85 ShowOneClickSigninBubble( | 163 ShowOneClickSigninBubble( |
| 86 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 164 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 87 | 165 |
| 88 // Simulate pressing the OK button. Set the message loop in the bubble | 166 // Simulate pressing the OK button. Set the message loop in the bubble |
| 89 // view so that it can be quit once the bubble is hidden. | 167 // view so that it can be quit once the bubble is hidden. |
| 90 views::ButtonListener* listener = view; | 168 views::ButtonListener* listener = view; |
| 91 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, | 169 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, |
| 92 gfx::Point(), gfx::Point(), | 170 gfx::Point(), gfx::Point(), |
| 93 0); | 171 0); |
| 94 listener->ButtonPressed(view->ok_button_, event); | 172 listener->ButtonPressed(view->ok_button_, event); |
| 95 | 173 |
| 96 // View should no longer be showing. The message loop will exit once the | 174 // View should no longer be showing. The message loop will exit once the |
| 97 // fade animation of the bubble is done. | 175 // fade animation of the bubble is done. |
| 98 content::RunAllPendingInMessageLoop(); | 176 content::RunAllPendingInMessageLoop(); |
| 99 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 177 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 100 } | 178 } |
| 101 | 179 |
| 102 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, DialogOkButton) { | 180 TEST_F(OneClickSigninBubbleViewTest, DialogOkButton) { |
| 103 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 181 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 104 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 182 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 105 | 183 |
| 106 // Simulate pressing the OK button. Set the message loop in the bubble | 184 // Simulate pressing the OK button. Set the message loop in the bubble |
| 107 // view so that it can be quit once the bubble is hidden. | 185 // view so that it can be quit once the bubble is hidden. |
| 108 views::ButtonListener* listener = view; | 186 views::ButtonListener* listener = view; |
| 109 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, | 187 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, |
| 110 gfx::Point(), gfx::Point(), | 188 gfx::Point(), gfx::Point(), |
| 111 0); | 189 0); |
| 112 listener->ButtonPressed(view->ok_button_, event); | 190 listener->ButtonPressed(view->ok_button_, event); |
| 113 | 191 |
| 114 // View should no longer be showing and sync should start | 192 // View should no longer be showing and sync should start |
| 115 // The message loop will exit once the fade animation of the dialog is done. | 193 // The message loop will exit once the fade animation of the dialog is done. |
| 116 content::RunAllPendingInMessageLoop(); | 194 content::RunAllPendingInMessageLoop(); |
| 117 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 195 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 118 EXPECT_TRUE(on_start_sync_called_); | 196 EXPECT_TRUE(on_start_sync_called_); |
| 119 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); | 197 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); |
| 120 } | 198 } |
| 121 | 199 |
| 122 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 200 TEST_F(OneClickSigninBubbleViewTest, DialogUndoButton) { |
| 123 DialogUndoButton) { | |
| 124 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 201 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 125 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 202 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 126 | 203 |
| 127 // Simulate pressing the undo button. Set the message loop in the bubble | 204 // Simulate pressing the undo button. Set the message loop in the bubble |
| 128 // view so that it can be quit once the bubble is hidden. | 205 // view so that it can be quit once the bubble is hidden. |
| 129 views::ButtonListener* listener = view; | 206 views::ButtonListener* listener = view; |
| 130 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, | 207 const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, |
| 131 gfx::Point(), gfx::Point(), | 208 gfx::Point(), gfx::Point(), |
| 132 0); | 209 0); |
| 133 listener->ButtonPressed(view->undo_button_, event); | 210 listener->ButtonPressed(view->undo_button_, event); |
| 134 | 211 |
| 135 // View should no longer be showing. The message loop will exit once the | 212 // View should no longer be showing. The message loop will exit once the |
| 136 // fade animation of the bubble is done. | 213 // fade animation of the bubble is done. |
| 137 content::RunAllPendingInMessageLoop(); | 214 content::RunAllPendingInMessageLoop(); |
| 138 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 215 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 139 EXPECT_TRUE(on_start_sync_called_); | 216 EXPECT_TRUE(on_start_sync_called_); |
| 140 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); | 217 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); |
| 141 } | 218 } |
| 142 | 219 |
| 143 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 220 TEST_F(OneClickSigninBubbleViewTest, BubbleAdvancedLink) { |
| 144 BubbleAdvancedLink) { | |
| 145 int starting_tab_count = browser()->tab_strip_model()->count(); | |
| 146 | |
| 147 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 221 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 148 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 222 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 149 | 223 |
| 150 // Simulate pressing a link in the bubble.This should replace the current tab. | 224 // Simulate pressing a link in the bubble. |
| 151 views::LinkListener* listener = view; | 225 views::LinkListener* listener = view; |
| 152 listener->LinkClicked(view->advanced_link_, 0); | 226 listener->LinkClicked(view->advanced_link_, 0); |
| 153 | 227 |
| 154 // View should no longer be showing and the current tab should be replaced. | 228 // View should no longer be showing and the OnAdvancedLinkClicked method |
| 229 // of the delegate should have been called. |
| 155 content::RunAllPendingInMessageLoop(); | 230 content::RunAllPendingInMessageLoop(); |
| 156 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 231 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 157 int tab_count = browser()->tab_strip_model()->count(); | 232 EXPECT_EQ(1, advanced_click_count_); |
| 158 EXPECT_EQ(starting_tab_count, tab_count); | |
| 159 } | 233 } |
| 160 | 234 |
| 161 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 235 TEST_F(OneClickSigninBubbleViewTest, DialogAdvancedLink) { |
| 162 DialogAdvancedLink) { | |
| 163 int starting_tab_count = browser()->tab_strip_model()->count(); | |
| 164 | |
| 165 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 236 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 166 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 237 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 167 | 238 |
| 168 // Simulate pressing a link in the bubble. This should open a new tab. | 239 // Simulate pressing a link in the bubble. |
| 169 views::LinkListener* listener = view; | 240 views::LinkListener* listener = view; |
| 170 listener->LinkClicked(view->advanced_link_, 0); | 241 listener->LinkClicked(view->advanced_link_, 0); |
| 171 | 242 |
| 172 // View should no longer be showing and a new tab should be opened. | 243 // View should no longer be showing. No delegate method should have been |
| 244 // called: the callback is responsible to open the settings page. |
| 173 content::RunAllPendingInMessageLoop(); | 245 content::RunAllPendingInMessageLoop(); |
| 174 EXPECT_TRUE(on_start_sync_called_); | 246 EXPECT_TRUE(on_start_sync_called_); |
| 175 EXPECT_EQ(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, mode_); | 247 EXPECT_EQ(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST, mode_); |
| 176 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 248 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 177 int tab_count = browser()->tab_strip_model()->count(); | 249 EXPECT_EQ(0, advanced_click_count_); |
| 178 EXPECT_EQ(starting_tab_count, tab_count); | |
| 179 } | 250 } |
| 180 | 251 |
| 181 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 252 TEST_F(OneClickSigninBubbleViewTest, BubbleLearnMoreLink) { |
| 182 BubbleLearnMoreLink) { | |
| 183 int starting_tab_count = browser()->tab_strip_model()->count(); | |
| 184 | |
| 185 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( | 253 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 186 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 254 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 187 | 255 |
| 188 // View should no longer be showing and a new tab should be added. | |
| 189 views::LinkListener* listener = view; | 256 views::LinkListener* listener = view; |
| 190 listener->LinkClicked(view->learn_more_link_, 0); | 257 listener->LinkClicked(view->learn_more_link_, 0); |
| 191 | 258 |
| 259 // View should no longer be showing and the OnLearnMoreLinkClicked method |
| 260 // of the delegate should have been called with |is_dialog| == false. |
| 192 content::RunAllPendingInMessageLoop(); | 261 content::RunAllPendingInMessageLoop(); |
| 193 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 262 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 194 int tab_count = browser()->tab_strip_model()->count(); | 263 EXPECT_EQ(1, bubble_learn_more_click_count_); |
| 195 EXPECT_EQ(starting_tab_count + 1, tab_count); | 264 EXPECT_EQ(0, dialog_learn_more_click_count_); |
| 196 } | 265 } |
| 197 | 266 |
| 198 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 267 TEST_F(OneClickSigninBubbleViewTest, DialogLearnMoreLink) { |
| 199 BubblePressEnterKey) { | 268 OneClickSigninBubbleView* view = ShowOneClickSigninBubble( |
| 269 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 270 |
| 271 views::LinkListener* listener = view; |
| 272 listener->LinkClicked(view->learn_more_link_, 0); |
| 273 |
| 274 // View should still be showing and the OnLearnMoreLinkClicked method |
| 275 // of the delegate should have been called with |is_dialog| == true. |
| 276 content::RunAllPendingInMessageLoop(); |
| 277 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); |
| 278 EXPECT_EQ(0, bubble_learn_more_click_count_); |
| 279 EXPECT_EQ(1, dialog_learn_more_click_count_); |
| 280 } |
| 281 |
| 282 TEST_F(OneClickSigninBubbleViewTest, BubblePressEnterKey) { |
| 200 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( | 283 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( |
| 201 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 284 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 202 | 285 |
| 203 // Simulate pressing the Enter key. | 286 // Simulate pressing the Enter key. |
| 204 views::View* view = one_click_view; | 287 views::View* view = one_click_view; |
| 205 const ui::Accelerator accelerator(ui::VKEY_RETURN, 0); | 288 const ui::Accelerator accelerator(ui::VKEY_RETURN, 0); |
| 206 view->AcceleratorPressed(accelerator); | 289 view->AcceleratorPressed(accelerator); |
| 207 | 290 |
| 208 // View should no longer be showing. The message loop will exit once the | 291 // View should no longer be showing. The message loop will exit once the |
| 209 // fade animation of the bubble is done. | 292 // fade animation of the bubble is done. |
| 210 content::RunAllPendingInMessageLoop(); | 293 content::RunAllPendingInMessageLoop(); |
| 211 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 294 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 212 } | 295 } |
| 213 | 296 |
| 214 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 297 TEST_F(OneClickSigninBubbleViewTest, DialogPressEnterKey) { |
| 215 DialogPressEnterKey) { | |
| 216 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( | 298 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( |
| 217 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 299 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 218 | 300 |
| 219 // Simulate pressing the Enter key. | 301 // Simulate pressing the Enter key. |
| 220 views::View* view = one_click_view; | 302 views::View* view = one_click_view; |
| 221 const ui::Accelerator accelerator(ui::VKEY_RETURN, 0); | 303 const ui::Accelerator accelerator(ui::VKEY_RETURN, 0); |
| 222 view->AcceleratorPressed(accelerator); | 304 view->AcceleratorPressed(accelerator); |
| 223 | 305 |
| 224 // View should no longer be showing. The message loop will exit once the | 306 // View should no longer be showing. The message loop will exit once the |
| 225 // fade animation of the bubble is done. | 307 // fade animation of the bubble is done. |
| 226 content::RunAllPendingInMessageLoop(); | 308 content::RunAllPendingInMessageLoop(); |
| 227 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 309 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 228 EXPECT_TRUE(on_start_sync_called_); | 310 EXPECT_TRUE(on_start_sync_called_); |
| 229 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); | 311 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); |
| 230 } | 312 } |
| 231 | 313 |
| 232 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 314 TEST_F(OneClickSigninBubbleViewTest, BubblePressEscapeKey) { |
| 233 BubblePressEscapeKey) { | |
| 234 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( | 315 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( |
| 235 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); | 316 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE); |
| 236 | 317 |
| 237 // Simulate pressing the Escape key. | 318 // Simulate pressing the Escape key. |
| 238 views::View* view = one_click_view; | 319 views::View* view = one_click_view; |
| 239 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); | 320 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); |
| 240 view->AcceleratorPressed(accelerator); | 321 view->AcceleratorPressed(accelerator); |
| 241 | 322 |
| 242 // View should no longer be showing. The message loop will exit once the | 323 // View should no longer be showing. The message loop will exit once the |
| 243 // fade animation of the bubble is done. | 324 // fade animation of the bubble is done. |
| 244 content::RunAllPendingInMessageLoop(); | 325 content::RunAllPendingInMessageLoop(); |
| 245 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 326 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 246 } | 327 } |
| 247 | 328 |
| 248 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, | 329 TEST_F(OneClickSigninBubbleViewTest, DialogPressEscapeKey) { |
| 249 DialogPressEscapeKey) { | |
| 250 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( | 330 OneClickSigninBubbleView* one_click_view = ShowOneClickSigninBubble( |
| 251 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); | 331 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG); |
| 252 | 332 |
| 253 // Simulate pressing the Escape key. | 333 // Simulate pressing the Escape key. |
| 254 views::View* view = one_click_view; | 334 views::View* view = one_click_view; |
| 255 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); | 335 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); |
| 256 view->AcceleratorPressed(accelerator); | 336 view->AcceleratorPressed(accelerator); |
| 257 | 337 |
| 258 // View should no longer be showing. The message loop will exit once the | 338 // View should no longer be showing. The message loop will exit once the |
| 259 // fade animation of the bubble is done. | 339 // fade animation of the bubble is done. |
| 260 content::RunAllPendingInMessageLoop(); | 340 content::RunAllPendingInMessageLoop(); |
| 261 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 341 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
| 262 EXPECT_FALSE(on_start_sync_called_); | 342 EXPECT_FALSE(on_start_sync_called_); |
| 263 } | 343 } |
| OLD | NEW |