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