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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Waits for a views::Widget dialog to show up. | 58 // Waits for a views::Widget dialog to show up. |
59 class DialogWaiter : public aura::EnvObserver, | 59 class DialogWaiter : public aura::EnvObserver, |
60 public views::WidgetObserver { | 60 public views::WidgetObserver { |
61 public: | 61 public: |
62 DialogWaiter() | 62 DialogWaiter() |
63 : dialog_created_(false), | 63 : dialog_created_(false), |
64 dialog_(NULL) { | 64 dialog_(NULL) { |
65 aura::Env::GetInstance()->AddObserver(this); | 65 aura::Env::GetInstance()->AddObserver(this); |
66 } | 66 } |
67 | 67 |
68 virtual ~DialogWaiter() { | 68 ~DialogWaiter() override { aura::Env::GetInstance()->RemoveObserver(this); } |
69 aura::Env::GetInstance()->RemoveObserver(this); | |
70 } | |
71 | 69 |
72 views::Widget* WaitForDialog() { | 70 views::Widget* WaitForDialog() { |
73 if (dialog_created_) | 71 if (dialog_created_) |
74 return dialog_; | 72 return dialog_; |
75 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 73 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
76 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 74 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
77 base::RunLoop run_loop; | 75 base::RunLoop run_loop; |
78 quit_closure_ = run_loop.QuitClosure(); | 76 quit_closure_ = run_loop.QuitClosure(); |
79 run_loop.Run(); | 77 run_loop.Run(); |
80 return dialog_; | 78 return dialog_; |
81 } | 79 } |
82 | 80 |
83 private: | 81 private: |
84 // aura::EnvObserver: | 82 // aura::EnvObserver: |
85 virtual void OnWindowInitialized(aura::Window* window) override { | 83 void OnWindowInitialized(aura::Window* window) override { |
86 if (dialog_) | 84 if (dialog_) |
87 return; | 85 return; |
88 views::Widget* widget = views::Widget::GetWidgetForNativeView(window); | 86 views::Widget* widget = views::Widget::GetWidgetForNativeView(window); |
89 if (!widget || !widget->IsDialogBox()) | 87 if (!widget || !widget->IsDialogBox()) |
90 return; | 88 return; |
91 dialog_ = widget; | 89 dialog_ = widget; |
92 dialog_->AddObserver(this); | 90 dialog_->AddObserver(this); |
93 } | 91 } |
94 | 92 |
95 // views::WidgetObserver: | 93 // views::WidgetObserver: |
96 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | 94 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override { |
97 bool visible) override { | |
98 CHECK_EQ(dialog_, widget); | 95 CHECK_EQ(dialog_, widget); |
99 if (visible) { | 96 if (visible) { |
100 dialog_created_ = true; | 97 dialog_created_ = true; |
101 dialog_->RemoveObserver(this); | 98 dialog_->RemoveObserver(this); |
102 if (!quit_closure_.is_null()) | 99 if (!quit_closure_.is_null()) |
103 quit_closure_.Run(); | 100 quit_closure_.Run(); |
104 } | 101 } |
105 } | 102 } |
106 | 103 |
107 bool dialog_created_; | 104 bool dialog_created_; |
108 views::Widget* dialog_; | 105 views::Widget* dialog_; |
109 base::Closure quit_closure_; | 106 base::Closure quit_closure_; |
110 | 107 |
111 DISALLOW_COPY_AND_ASSIGN(DialogWaiter); | 108 DISALLOW_COPY_AND_ASSIGN(DialogWaiter); |
112 }; | 109 }; |
113 | 110 |
114 // Waits for a dialog to terminate. | 111 // Waits for a dialog to terminate. |
115 class DialogCloseWaiter : public views::WidgetObserver { | 112 class DialogCloseWaiter : public views::WidgetObserver { |
116 public: | 113 public: |
117 explicit DialogCloseWaiter(views::Widget* dialog) | 114 explicit DialogCloseWaiter(views::Widget* dialog) |
118 : dialog_closed_(false) { | 115 : dialog_closed_(false) { |
119 dialog->AddObserver(this); | 116 dialog->AddObserver(this); |
120 } | 117 } |
121 | 118 |
122 virtual ~DialogCloseWaiter() { | 119 ~DialogCloseWaiter() override { |
123 // It is not necessary to remove |this| from the dialog's observer, since | 120 // It is not necessary to remove |this| from the dialog's observer, since |
124 // the dialog is destroyed before this waiter. | 121 // the dialog is destroyed before this waiter. |
125 } | 122 } |
126 | 123 |
127 void WaitForDialogClose() { | 124 void WaitForDialogClose() { |
128 if (dialog_closed_) | 125 if (dialog_closed_) |
129 return; | 126 return; |
130 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 127 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
131 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 128 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
132 base::RunLoop run_loop; | 129 base::RunLoop run_loop; |
133 quit_closure_ = run_loop.QuitClosure(); | 130 quit_closure_ = run_loop.QuitClosure(); |
134 run_loop.Run(); | 131 run_loop.Run(); |
135 } | 132 } |
136 | 133 |
137 private: | 134 private: |
138 // views::WidgetObserver: | 135 // views::WidgetObserver: |
139 virtual void OnWidgetDestroyed(views::Widget* widget) override { | 136 void OnWidgetDestroyed(views::Widget* widget) override { |
140 dialog_closed_ = true; | 137 dialog_closed_ = true; |
141 if (!quit_closure_.is_null()) | 138 if (!quit_closure_.is_null()) |
142 quit_closure_.Run(); | 139 quit_closure_.Run(); |
143 } | 140 } |
144 | 141 |
145 bool dialog_closed_; | 142 bool dialog_closed_; |
146 base::Closure quit_closure_; | 143 base::Closure quit_closure_; |
147 | 144 |
148 DISALLOW_COPY_AND_ASSIGN(DialogCloseWaiter); | 145 DISALLOW_COPY_AND_ASSIGN(DialogCloseWaiter); |
149 }; | 146 }; |
150 | 147 |
151 // Waits for a views::Widget to receive a Tab key. | 148 // Waits for a views::Widget to receive a Tab key. |
152 class TabKeyWaiter : public ui::EventHandler { | 149 class TabKeyWaiter : public ui::EventHandler { |
153 public: | 150 public: |
154 explicit TabKeyWaiter(views::Widget* widget) | 151 explicit TabKeyWaiter(views::Widget* widget) |
155 : widget_(widget), | 152 : widget_(widget), |
156 received_tab_(false) { | 153 received_tab_(false) { |
157 widget_->GetNativeView()->AddPreTargetHandler(this); | 154 widget_->GetNativeView()->AddPreTargetHandler(this); |
158 } | 155 } |
159 | 156 |
160 virtual ~TabKeyWaiter() { | 157 ~TabKeyWaiter() override { |
161 widget_->GetNativeView()->RemovePreTargetHandler(this); | 158 widget_->GetNativeView()->RemovePreTargetHandler(this); |
162 } | 159 } |
163 | 160 |
164 void WaitForTab() { | 161 void WaitForTab() { |
165 if (received_tab_) | 162 if (received_tab_) |
166 return; | 163 return; |
167 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 164 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
168 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 165 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
169 base::RunLoop run_loop; | 166 base::RunLoop run_loop; |
170 quit_closure_ = run_loop.QuitClosure(); | 167 quit_closure_ = run_loop.QuitClosure(); |
171 run_loop.Run(); | 168 run_loop.Run(); |
172 } | 169 } |
173 | 170 |
174 private: | 171 private: |
175 // ui::EventHandler: | 172 // ui::EventHandler: |
176 virtual void OnKeyEvent(ui::KeyEvent* event) override { | 173 void OnKeyEvent(ui::KeyEvent* event) override { |
177 if (event->type() == ui::ET_KEY_RELEASED && | 174 if (event->type() == ui::ET_KEY_RELEASED && |
178 event->key_code() == ui::VKEY_TAB) { | 175 event->key_code() == ui::VKEY_TAB) { |
179 received_tab_ = true; | 176 received_tab_ = true; |
180 if (!quit_closure_.is_null()) | 177 if (!quit_closure_.is_null()) |
181 quit_closure_.Run(); | 178 quit_closure_.Run(); |
182 } | 179 } |
183 } | 180 } |
184 | 181 |
185 views::Widget* widget_; | 182 views::Widget* widget_; |
186 bool received_tab_; | 183 bool received_tab_; |
187 base::Closure quit_closure_; | 184 base::Closure quit_closure_; |
188 | 185 |
189 DISALLOW_COPY_AND_ASSIGN(TabKeyWaiter); | 186 DISALLOW_COPY_AND_ASSIGN(TabKeyWaiter); |
190 }; | 187 }; |
191 | 188 |
192 void MoveMouseAndPress(const gfx::Point& screen_pos, | 189 void MoveMouseAndPress(const gfx::Point& screen_pos, |
193 ui_controls::MouseButton button, | 190 ui_controls::MouseButton button, |
194 int state, | 191 int state, |
195 const base::Closure& closure) { | 192 const base::Closure& closure) { |
196 ui_controls::SendMouseMove(screen_pos.x(), screen_pos.y()); | 193 ui_controls::SendMouseMove(screen_pos.x(), screen_pos.y()); |
197 ui_controls::SendMouseEventsNotifyWhenDone(button, state, closure); | 194 ui_controls::SendMouseEventsNotifyWhenDone(button, state, closure); |
198 } | 195 } |
199 | 196 |
200 // PageNavigator implementation that records the URL. | 197 // PageNavigator implementation that records the URL. |
201 class TestingPageNavigator : public PageNavigator { | 198 class TestingPageNavigator : public PageNavigator { |
202 public: | 199 public: |
203 virtual WebContents* OpenURL(const OpenURLParams& params) override { | 200 WebContents* OpenURL(const OpenURLParams& params) override { |
204 url_ = params.url; | 201 url_ = params.url; |
205 return NULL; | 202 return NULL; |
206 } | 203 } |
207 | 204 |
208 GURL url_; | 205 GURL url_; |
209 }; | 206 }; |
210 | 207 |
211 // TODO(erg): Fix bookmark DND tests on linux_aura. crbug.com/163931 | 208 // TODO(erg): Fix bookmark DND tests on linux_aura. crbug.com/163931 |
212 #if defined(OS_LINUX) && defined(USE_AURA) | 209 #if defined(OS_LINUX) && defined(USE_AURA) |
213 #define MAYBE(x) DISABLED_##x | 210 #define MAYBE(x) DISABLED_##x |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // the names f1-f100. | 244 // the names f1-f100. |
248 // | 245 // |
249 // Subclasses should be sure and invoke super's implementation of SetUp and | 246 // Subclasses should be sure and invoke super's implementation of SetUp and |
250 // TearDown. | 247 // TearDown. |
251 class BookmarkBarViewEventTestBase : public ViewEventTestBase { | 248 class BookmarkBarViewEventTestBase : public ViewEventTestBase { |
252 public: | 249 public: |
253 BookmarkBarViewEventTestBase() | 250 BookmarkBarViewEventTestBase() |
254 : ViewEventTestBase(), | 251 : ViewEventTestBase(), |
255 model_(NULL) {} | 252 model_(NULL) {} |
256 | 253 |
257 virtual void SetUp() override { | 254 void SetUp() override { |
258 content_client_.reset(new ChromeContentClient); | 255 content_client_.reset(new ChromeContentClient); |
259 content::SetContentClient(content_client_.get()); | 256 content::SetContentClient(content_client_.get()); |
260 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); | 257 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); |
261 content::SetBrowserClientForTesting(browser_content_client_.get()); | 258 content::SetBrowserClientForTesting(browser_content_client_.get()); |
262 | 259 |
263 views::MenuController::TurnOffMenuSelectionHoldForTest(); | 260 views::MenuController::TurnOffMenuSelectionHoldForTest(); |
264 BookmarkBarView::DisableAnimationsForTesting(true); | 261 BookmarkBarView::DisableAnimationsForTesting(true); |
265 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); | 262 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); |
266 | 263 |
267 profile_.reset(new TestingProfile()); | 264 profile_.reset(new TestingProfile()); |
(...skipping 29 matching lines...) Expand all Loading... |
297 bb_view_pref_.set_width(1000); | 294 bb_view_pref_.set_width(1000); |
298 do { | 295 do { |
299 bb_view_pref_.set_width(bb_view_pref_.width() - 25); | 296 bb_view_pref_.set_width(bb_view_pref_.width() - 25); |
300 bb_view_->SetBounds(0, 0, bb_view_pref_.width(), bb_view_pref_.height()); | 297 bb_view_->SetBounds(0, 0, bb_view_pref_.width(), bb_view_pref_.height()); |
301 bb_view_->Layout(); | 298 bb_view_->Layout(); |
302 } while (GetBookmarkButton(6)->visible()); | 299 } while (GetBookmarkButton(6)->visible()); |
303 | 300 |
304 ViewEventTestBase::SetUp(); | 301 ViewEventTestBase::SetUp(); |
305 } | 302 } |
306 | 303 |
307 virtual void TearDown() { | 304 void TearDown() override { |
308 // Destroy everything, then run the message loop to ensure we delete all | 305 // Destroy everything, then run the message loop to ensure we delete all |
309 // Tasks and fully shut down. | 306 // Tasks and fully shut down. |
310 browser_->tab_strip_model()->CloseAllTabs(); | 307 browser_->tab_strip_model()->CloseAllTabs(); |
311 bb_view_.reset(); | 308 bb_view_.reset(); |
312 browser_.reset(); | 309 browser_.reset(); |
313 profile_.reset(); | 310 profile_.reset(); |
314 | 311 |
315 // Run the message loop to ensure we delete allTasks and fully shut down. | 312 // Run the message loop to ensure we delete allTasks and fully shut down. |
316 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 313 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
317 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 314 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
318 base::RunLoop run_loop; | 315 base::RunLoop run_loop; |
319 loop->PostTask(FROM_HERE, run_loop.QuitClosure()); | 316 loop->PostTask(FROM_HERE, run_loop.QuitClosure()); |
320 run_loop.Run(); | 317 run_loop.Run(); |
321 | 318 |
322 ViewEventTestBase::TearDown(); | 319 ViewEventTestBase::TearDown(); |
323 BookmarkBarView::DisableAnimationsForTesting(false); | 320 BookmarkBarView::DisableAnimationsForTesting(false); |
324 SetConstrainedWindowViewsClient(scoped_ptr<ConstrainedWindowViewsClient>()); | 321 SetConstrainedWindowViewsClient(scoped_ptr<ConstrainedWindowViewsClient>()); |
325 | 322 |
326 browser_content_client_.reset(); | 323 browser_content_client_.reset(); |
327 content_client_.reset(); | 324 content_client_.reset(); |
328 content::SetContentClient(NULL); | 325 content::SetContentClient(NULL); |
329 } | 326 } |
330 | 327 |
331 protected: | 328 protected: |
332 virtual views::View* CreateContentsView() override { | 329 views::View* CreateContentsView() override { return bb_view_.get(); } |
333 return bb_view_.get(); | |
334 } | |
335 | 330 |
336 virtual gfx::Size GetPreferredSize() const override { return bb_view_pref_; } | 331 gfx::Size GetPreferredSize() const override { return bb_view_pref_; } |
337 | 332 |
338 views::LabelButton* GetBookmarkButton(int view_index) { | 333 views::LabelButton* GetBookmarkButton(int view_index) { |
339 return bb_view_->GetBookmarkButton(view_index); | 334 return bb_view_->GetBookmarkButton(view_index); |
340 } | 335 } |
341 | 336 |
342 // See comment above class description for what this does. | 337 // See comment above class description for what this does. |
343 virtual bool CreateBigMenu() { return false; } | 338 virtual bool CreateBigMenu() { return false; } |
344 | 339 |
345 BookmarkModel* model_; | 340 BookmarkModel* model_; |
346 scoped_ptr<BookmarkBarView> bb_view_; | 341 scoped_ptr<BookmarkBarView> bb_view_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; | 379 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; |
385 scoped_ptr<TestingProfile> profile_; | 380 scoped_ptr<TestingProfile> profile_; |
386 scoped_ptr<Browser> browser_; | 381 scoped_ptr<Browser> browser_; |
387 scoped_ptr<ScopedTestingLocalState> local_state_; | 382 scoped_ptr<ScopedTestingLocalState> local_state_; |
388 }; | 383 }; |
389 | 384 |
390 // Clicks on first menu, makes sure button is depressed. Moves mouse to first | 385 // Clicks on first menu, makes sure button is depressed. Moves mouse to first |
391 // child, clicks it and makes sure a navigation occurs. | 386 // child, clicks it and makes sure a navigation occurs. |
392 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { | 387 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { |
393 protected: | 388 protected: |
394 virtual void DoTestOnMessageLoop() override { | 389 void DoTestOnMessageLoop() override { |
395 // Move the mouse to the first folder on the bookmark bar and press the | 390 // Move the mouse to the first folder on the bookmark bar and press the |
396 // mouse. | 391 // mouse. |
397 views::LabelButton* button = GetBookmarkButton(0); | 392 views::LabelButton* button = GetBookmarkButton(0); |
398 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 393 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
399 ui_controls::DOWN | ui_controls::UP, | 394 ui_controls::DOWN | ui_controls::UP, |
400 CreateEventTask(this, &BookmarkBarViewTest1::Step2)); | 395 CreateEventTask(this, &BookmarkBarViewTest1::Step2)); |
401 } | 396 } |
402 | 397 |
403 private: | 398 private: |
404 void Step2() { | 399 void Step2() { |
(...skipping 30 matching lines...) Expand all Loading... |
435 | 430 |
436 Done(); | 431 Done(); |
437 } | 432 } |
438 }; | 433 }; |
439 | 434 |
440 VIEW_TEST(BookmarkBarViewTest1, Basic) | 435 VIEW_TEST(BookmarkBarViewTest1, Basic) |
441 | 436 |
442 // Brings up menu, clicks on empty space and make sure menu hides. | 437 // Brings up menu, clicks on empty space and make sure menu hides. |
443 class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { | 438 class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { |
444 protected: | 439 protected: |
445 virtual void DoTestOnMessageLoop() override { | 440 void DoTestOnMessageLoop() override { |
446 // Move the mouse to the first folder on the bookmark bar and press the | 441 // Move the mouse to the first folder on the bookmark bar and press the |
447 // mouse. | 442 // mouse. |
448 views::LabelButton* button = GetBookmarkButton(0); | 443 views::LabelButton* button = GetBookmarkButton(0); |
449 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 444 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
450 ui_controls::DOWN | ui_controls::UP, | 445 ui_controls::DOWN | ui_controls::UP, |
451 CreateEventTask(this, &BookmarkBarViewTest2::Step2)); | 446 CreateEventTask(this, &BookmarkBarViewTest2::Step2)); |
452 } | 447 } |
453 | 448 |
454 private: | 449 private: |
455 void Step2() { | 450 void Step2() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 #else | 491 #else |
497 #define MAYBE_HideOnDesktopClick HideOnDesktopClick | 492 #define MAYBE_HideOnDesktopClick HideOnDesktopClick |
498 #endif | 493 #endif |
499 | 494 |
500 VIEW_TEST(BookmarkBarViewTest2, MAYBE_HideOnDesktopClick) | 495 VIEW_TEST(BookmarkBarViewTest2, MAYBE_HideOnDesktopClick) |
501 | 496 |
502 // Brings up menu. Moves over child to make sure submenu appears, moves over | 497 // Brings up menu. Moves over child to make sure submenu appears, moves over |
503 // another child and make sure next menu appears. | 498 // another child and make sure next menu appears. |
504 class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { | 499 class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { |
505 protected: | 500 protected: |
506 virtual void DoTestOnMessageLoop() override { | 501 void DoTestOnMessageLoop() override { |
507 // Move the mouse to the first folder on the bookmark bar and press the | 502 // Move the mouse to the first folder on the bookmark bar and press the |
508 // mouse. | 503 // mouse. |
509 views::MenuButton* button = bb_view_->other_bookmarked_button(); | 504 views::MenuButton* button = bb_view_->other_bookmarked_button(); |
510 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 505 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
511 ui_controls::DOWN | ui_controls::UP, | 506 ui_controls::DOWN | ui_controls::UP, |
512 CreateEventTask(this, &BookmarkBarViewTest3::Step2)); | 507 CreateEventTask(this, &BookmarkBarViewTest3::Step2)); |
513 } | 508 } |
514 | 509 |
515 private: | 510 private: |
516 void Step2() { | 511 void Step2() { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 class BookmarkContextMenuNotificationObserver | 572 class BookmarkContextMenuNotificationObserver |
578 : public content::NotificationObserver { | 573 : public content::NotificationObserver { |
579 public: | 574 public: |
580 explicit BookmarkContextMenuNotificationObserver(const base::Closure& task) | 575 explicit BookmarkContextMenuNotificationObserver(const base::Closure& task) |
581 : task_(task) { | 576 : task_(task) { |
582 registrar_.Add(this, | 577 registrar_.Add(this, |
583 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, | 578 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, |
584 content::NotificationService::AllSources()); | 579 content::NotificationService::AllSources()); |
585 } | 580 } |
586 | 581 |
587 virtual void Observe(int type, | 582 void Observe(int type, |
588 const content::NotificationSource& source, | 583 const content::NotificationSource& source, |
589 const content::NotificationDetails& details) override { | 584 const content::NotificationDetails& details) override { |
590 base::MessageLoop::current()->PostTask(FROM_HERE, task_); | 585 base::MessageLoop::current()->PostTask(FROM_HERE, task_); |
591 } | 586 } |
592 | 587 |
593 // Sets the task that is posted when the context menu is shown. | 588 // Sets the task that is posted when the context menu is shown. |
594 void set_task(const base::Closure& task) { task_ = task; } | 589 void set_task(const base::Closure& task) { task_ = task; } |
595 | 590 |
596 private: | 591 private: |
597 content::NotificationRegistrar registrar_; | 592 content::NotificationRegistrar registrar_; |
598 base::Closure task_; | 593 base::Closure task_; |
599 | 594 |
600 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuNotificationObserver); | 595 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuNotificationObserver); |
601 }; | 596 }; |
602 | 597 |
603 // Tests context menus by way of opening a context menu for a bookmark, | 598 // Tests context menus by way of opening a context menu for a bookmark, |
604 // then right clicking to get context menu and selecting the first menu item | 599 // then right clicking to get context menu and selecting the first menu item |
605 // (open). | 600 // (open). |
606 class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { | 601 class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { |
607 public: | 602 public: |
608 BookmarkBarViewTest4() | 603 BookmarkBarViewTest4() |
609 : observer_(CreateEventTask(this, &BookmarkBarViewTest4::Step3)) { | 604 : observer_(CreateEventTask(this, &BookmarkBarViewTest4::Step3)) { |
610 } | 605 } |
611 | 606 |
612 protected: | 607 protected: |
613 virtual void DoTestOnMessageLoop() override { | 608 void DoTestOnMessageLoop() override { |
614 // Move the mouse to the first folder on the bookmark bar and press the | 609 // Move the mouse to the first folder on the bookmark bar and press the |
615 // mouse. | 610 // mouse. |
616 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 611 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
617 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 612 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
618 ui_controls::DOWN | ui_controls::UP, | 613 ui_controls::DOWN | ui_controls::UP, |
619 CreateEventTask(this, &BookmarkBarViewTest4::Step2)); | 614 CreateEventTask(this, &BookmarkBarViewTest4::Step2)); |
620 } | 615 } |
621 | 616 |
622 private: | 617 private: |
623 void Step2() { | 618 void Step2() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 } | 651 } |
657 | 652 |
658 BookmarkContextMenuNotificationObserver observer_; | 653 BookmarkContextMenuNotificationObserver observer_; |
659 }; | 654 }; |
660 | 655 |
661 VIEW_TEST(BookmarkBarViewTest4, ContextMenus) | 656 VIEW_TEST(BookmarkBarViewTest4, ContextMenus) |
662 | 657 |
663 // Tests drag and drop within the same menu. | 658 // Tests drag and drop within the same menu. |
664 class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { | 659 class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { |
665 protected: | 660 protected: |
666 virtual void DoTestOnMessageLoop() override { | 661 void DoTestOnMessageLoop() override { |
667 url_dragging_ = | 662 url_dragging_ = |
668 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); | 663 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); |
669 | 664 |
670 // Move the mouse to the first folder on the bookmark bar and press the | 665 // Move the mouse to the first folder on the bookmark bar and press the |
671 // mouse. | 666 // mouse. |
672 views::LabelButton* button = GetBookmarkButton(0); | 667 views::LabelButton* button = GetBookmarkButton(0); |
673 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 668 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
674 ui_controls::DOWN | ui_controls::UP, | 669 ui_controls::DOWN | ui_controls::UP, |
675 CreateEventTask(this, &BookmarkBarViewTest5::Step2)); | 670 CreateEventTask(this, &BookmarkBarViewTest5::Step2)); |
676 } | 671 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 }; | 724 }; |
730 | 725 |
731 #if !defined(OS_WIN) // flaky http://crbug.com/400578 | 726 #if !defined(OS_WIN) // flaky http://crbug.com/400578 |
732 VIEW_TEST(BookmarkBarViewTest5, MAYBE(DND)) | 727 VIEW_TEST(BookmarkBarViewTest5, MAYBE(DND)) |
733 #endif | 728 #endif |
734 | 729 |
735 // Tests holding mouse down on overflow button, dragging such that menu pops up | 730 // Tests holding mouse down on overflow button, dragging such that menu pops up |
736 // then selecting an item. | 731 // then selecting an item. |
737 class BookmarkBarViewTest6 : public BookmarkBarViewEventTestBase { | 732 class BookmarkBarViewTest6 : public BookmarkBarViewEventTestBase { |
738 protected: | 733 protected: |
739 virtual void DoTestOnMessageLoop() override { | 734 void DoTestOnMessageLoop() override { |
740 // Press the mouse button on the overflow button. Don't release it though. | 735 // Press the mouse button on the overflow button. Don't release it though. |
741 views::LabelButton* button = bb_view_->overflow_button(); | 736 views::LabelButton* button = bb_view_->overflow_button(); |
742 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 737 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
743 ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest6::Step2)); | 738 ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest6::Step2)); |
744 } | 739 } |
745 | 740 |
746 private: | 741 private: |
747 void Step2() { | 742 void Step2() { |
748 // Menu should be showing. | 743 // Menu should be showing. |
749 views::MenuItemView* menu = bb_view_->GetMenu(); | 744 views::MenuItemView* menu = bb_view_->GetMenu(); |
(...skipping 16 matching lines...) Expand all Loading... |
766 } | 761 } |
767 | 762 |
768 GURL url_dragging_; | 763 GURL url_dragging_; |
769 }; | 764 }; |
770 | 765 |
771 VIEW_TEST(BookmarkBarViewTest6, OpenMenuOnClickAndHold) | 766 VIEW_TEST(BookmarkBarViewTest6, OpenMenuOnClickAndHold) |
772 | 767 |
773 // Tests drag and drop to different menu. | 768 // Tests drag and drop to different menu. |
774 class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { | 769 class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { |
775 protected: | 770 protected: |
776 virtual void DoTestOnMessageLoop() override { | 771 void DoTestOnMessageLoop() override { |
777 url_dragging_ = | 772 url_dragging_ = |
778 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); | 773 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); |
779 | 774 |
780 // Move the mouse to the first folder on the bookmark bar and press the | 775 // Move the mouse to the first folder on the bookmark bar and press the |
781 // mouse. | 776 // mouse. |
782 views::LabelButton* button = GetBookmarkButton(0); | 777 views::LabelButton* button = GetBookmarkButton(0); |
783 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 778 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
784 ui_controls::DOWN | ui_controls::UP, | 779 ui_controls::DOWN | ui_controls::UP, |
785 CreateEventTask(this, &BookmarkBarViewTest7::Step2)); | 780 CreateEventTask(this, &BookmarkBarViewTest7::Step2)); |
786 } | 781 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 // This test passes locally (on aero and non-aero) but fails on the trybots and | 861 // This test passes locally (on aero and non-aero) but fails on the trybots and |
867 // buildbot. | 862 // buildbot. |
868 // http://crbug.com/154081 | 863 // http://crbug.com/154081 |
869 VIEW_TEST(BookmarkBarViewTest7, MAYBE(DNDToDifferentMenu)) | 864 VIEW_TEST(BookmarkBarViewTest7, MAYBE(DNDToDifferentMenu)) |
870 #endif | 865 #endif |
871 | 866 |
872 // Drags from one menu to next so that original menu closes, then back to | 867 // Drags from one menu to next so that original menu closes, then back to |
873 // original menu. | 868 // original menu. |
874 class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { | 869 class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { |
875 protected: | 870 protected: |
876 virtual void DoTestOnMessageLoop() override { | 871 void DoTestOnMessageLoop() override { |
877 url_dragging_ = | 872 url_dragging_ = |
878 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); | 873 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); |
879 | 874 |
880 // Move the mouse to the first folder on the bookmark bar and press the | 875 // Move the mouse to the first folder on the bookmark bar and press the |
881 // mouse. | 876 // mouse. |
882 views::LabelButton* button = GetBookmarkButton(0); | 877 views::LabelButton* button = GetBookmarkButton(0); |
883 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 878 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
884 ui_controls::DOWN | ui_controls::UP, | 879 ui_controls::DOWN | ui_controls::UP, |
885 CreateEventTask(this, &BookmarkBarViewTest8::Step2)); | 880 CreateEventTask(this, &BookmarkBarViewTest8::Step2)); |
886 } | 881 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 #if !defined(OS_WIN) | 969 #if !defined(OS_WIN) |
975 // This test passes locally (on aero and non-aero) but fails on the trybots and | 970 // This test passes locally (on aero and non-aero) but fails on the trybots and |
976 // buildbot. | 971 // buildbot. |
977 // http://crbug.com/154081 | 972 // http://crbug.com/154081 |
978 VIEW_TEST(BookmarkBarViewTest8, MAYBE(DNDBackToOriginatingMenu)) | 973 VIEW_TEST(BookmarkBarViewTest8, MAYBE(DNDBackToOriginatingMenu)) |
979 #endif | 974 #endif |
980 | 975 |
981 // Moves the mouse over the scroll button and makes sure we get scrolling. | 976 // Moves the mouse over the scroll button and makes sure we get scrolling. |
982 class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { | 977 class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { |
983 protected: | 978 protected: |
984 virtual bool CreateBigMenu() override { return true; } | 979 bool CreateBigMenu() override { return true; } |
985 | 980 |
986 virtual void DoTestOnMessageLoop() override { | 981 void DoTestOnMessageLoop() override { |
987 // Move the mouse to the first folder on the bookmark bar and press the | 982 // Move the mouse to the first folder on the bookmark bar and press the |
988 // mouse. | 983 // mouse. |
989 views::LabelButton* button = GetBookmarkButton(0); | 984 views::LabelButton* button = GetBookmarkButton(0); |
990 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 985 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
991 ui_controls::DOWN | ui_controls::UP, | 986 ui_controls::DOWN | ui_controls::UP, |
992 CreateEventTask(this, &BookmarkBarViewTest9::Step2)); | 987 CreateEventTask(this, &BookmarkBarViewTest9::Step2)); |
993 } | 988 } |
994 | 989 |
995 private: | 990 private: |
996 void Step2() { | 991 void Step2() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 | 1040 |
1046 int start_y_; | 1041 int start_y_; |
1047 views::MenuItemView* first_menu_; | 1042 views::MenuItemView* first_menu_; |
1048 }; | 1043 }; |
1049 | 1044 |
1050 VIEW_TEST(BookmarkBarViewTest9, ScrollButtonScrolls) | 1045 VIEW_TEST(BookmarkBarViewTest9, ScrollButtonScrolls) |
1051 | 1046 |
1052 // Tests up/down/left/enter key messages. | 1047 // Tests up/down/left/enter key messages. |
1053 class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { | 1048 class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { |
1054 protected: | 1049 protected: |
1055 virtual void DoTestOnMessageLoop() override { | 1050 void DoTestOnMessageLoop() override { |
1056 // Move the mouse to the first folder on the bookmark bar and press the | 1051 // Move the mouse to the first folder on the bookmark bar and press the |
1057 // mouse. | 1052 // mouse. |
1058 views::LabelButton* button = GetBookmarkButton(0); | 1053 views::LabelButton* button = GetBookmarkButton(0); |
1059 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1054 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1060 ui_controls::DOWN | ui_controls::UP, | 1055 ui_controls::DOWN | ui_controls::UP, |
1061 CreateEventTask(this, &BookmarkBarViewTest10::Step2)); | 1056 CreateEventTask(this, &BookmarkBarViewTest10::Step2)); |
1062 base::MessageLoop::current()->RunUntilIdle(); | 1057 base::MessageLoop::current()->RunUntilIdle(); |
1063 } | 1058 } |
1064 | 1059 |
1065 private: | 1060 private: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 // context menu, close context menu (via escape), then click else where. This | 1161 // context menu, close context menu (via escape), then click else where. This |
1167 // effectively verifies we maintain mouse capture after the context menu is | 1162 // effectively verifies we maintain mouse capture after the context menu is |
1168 // hidden. | 1163 // hidden. |
1169 class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { | 1164 class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { |
1170 public: | 1165 public: |
1171 BookmarkBarViewTest11() | 1166 BookmarkBarViewTest11() |
1172 : observer_(CreateEventTask(this, &BookmarkBarViewTest11::Step3)) { | 1167 : observer_(CreateEventTask(this, &BookmarkBarViewTest11::Step3)) { |
1173 } | 1168 } |
1174 | 1169 |
1175 protected: | 1170 protected: |
1176 virtual void DoTestOnMessageLoop() override { | 1171 void DoTestOnMessageLoop() override { |
1177 // Move the mouse to the first folder on the bookmark bar and press the | 1172 // Move the mouse to the first folder on the bookmark bar and press the |
1178 // mouse. | 1173 // mouse. |
1179 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1174 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1180 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1175 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1181 ui_controls::DOWN | ui_controls::UP, | 1176 ui_controls::DOWN | ui_controls::UP, |
1182 CreateEventTask(this, &BookmarkBarViewTest11::Step2)); | 1177 CreateEventTask(this, &BookmarkBarViewTest11::Step2)); |
1183 } | 1178 } |
1184 | 1179 |
1185 private: | 1180 private: |
1186 void Step2() { | 1181 void Step2() { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 DISABLED_CloseMenuAfterClosingContextMenu | 1241 DISABLED_CloseMenuAfterClosingContextMenu |
1247 #else | 1242 #else |
1248 #define MAYBE_CloseMenuAfterClosingContextMenu CloseMenuAfterClosingContextMenu | 1243 #define MAYBE_CloseMenuAfterClosingContextMenu CloseMenuAfterClosingContextMenu |
1249 #endif | 1244 #endif |
1250 | 1245 |
1251 VIEW_TEST(BookmarkBarViewTest11, MAYBE_CloseMenuAfterClosingContextMenu) | 1246 VIEW_TEST(BookmarkBarViewTest11, MAYBE_CloseMenuAfterClosingContextMenu) |
1252 | 1247 |
1253 // Tests showing a modal dialog from a context menu. | 1248 // Tests showing a modal dialog from a context menu. |
1254 class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { | 1249 class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { |
1255 protected: | 1250 protected: |
1256 virtual void DoTestOnMessageLoop() override { | 1251 void DoTestOnMessageLoop() override { |
1257 // Open up the other folder. | 1252 // Open up the other folder. |
1258 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1253 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1259 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1254 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1260 ui_controls::DOWN | ui_controls::UP, | 1255 ui_controls::DOWN | ui_controls::UP, |
1261 CreateEventTask(this, &BookmarkBarViewTest12::Step2)); | 1256 CreateEventTask(this, &BookmarkBarViewTest12::Step2)); |
1262 chrome::num_bookmark_urls_before_prompting = 1; | 1257 chrome::num_bookmark_urls_before_prompting = 1; |
1263 } | 1258 } |
1264 | 1259 |
1265 virtual ~BookmarkBarViewTest12() { | 1260 ~BookmarkBarViewTest12() override { |
1266 chrome::num_bookmark_urls_before_prompting = 15; | 1261 chrome::num_bookmark_urls_before_prompting = 15; |
1267 } | 1262 } |
1268 | 1263 |
1269 private: | 1264 private: |
1270 void Step2() { | 1265 void Step2() { |
1271 // Menu should be showing. | 1266 // Menu should be showing. |
1272 views::MenuItemView* menu = bb_view_->GetMenu(); | 1267 views::MenuItemView* menu = bb_view_->GetMenu(); |
1273 ASSERT_TRUE(menu != NULL); | 1268 ASSERT_TRUE(menu != NULL); |
1274 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1269 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1275 | 1270 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 | 1343 |
1349 // Tests clicking on the separator of a context menu (this is for coverage of | 1344 // Tests clicking on the separator of a context menu (this is for coverage of |
1350 // bug 17862). | 1345 // bug 17862). |
1351 class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { | 1346 class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { |
1352 public: | 1347 public: |
1353 BookmarkBarViewTest13() | 1348 BookmarkBarViewTest13() |
1354 : observer_(CreateEventTask(this, &BookmarkBarViewTest13::Step3)) { | 1349 : observer_(CreateEventTask(this, &BookmarkBarViewTest13::Step3)) { |
1355 } | 1350 } |
1356 | 1351 |
1357 protected: | 1352 protected: |
1358 virtual void DoTestOnMessageLoop() override { | 1353 void DoTestOnMessageLoop() override { |
1359 // Move the mouse to the first folder on the bookmark bar and press the | 1354 // Move the mouse to the first folder on the bookmark bar and press the |
1360 // mouse. | 1355 // mouse. |
1361 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1356 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1362 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1357 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1363 ui_controls::DOWN | ui_controls::UP, | 1358 ui_controls::DOWN | ui_controls::UP, |
1364 CreateEventTask(this, &BookmarkBarViewTest13::Step2)); | 1359 CreateEventTask(this, &BookmarkBarViewTest13::Step2)); |
1365 } | 1360 } |
1366 | 1361 |
1367 private: | 1362 private: |
1368 void Step2() { | 1363 void Step2() { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 | 1427 |
1433 // Makes sure right clicking on a folder on the bookmark bar doesn't result in | 1428 // Makes sure right clicking on a folder on the bookmark bar doesn't result in |
1434 // both a context menu and showing the menu. | 1429 // both a context menu and showing the menu. |
1435 class BookmarkBarViewTest14 : public BookmarkBarViewEventTestBase { | 1430 class BookmarkBarViewTest14 : public BookmarkBarViewEventTestBase { |
1436 public: | 1431 public: |
1437 BookmarkBarViewTest14() | 1432 BookmarkBarViewTest14() |
1438 : observer_(CreateEventTask(this, &BookmarkBarViewTest14::Step2)) { | 1433 : observer_(CreateEventTask(this, &BookmarkBarViewTest14::Step2)) { |
1439 } | 1434 } |
1440 | 1435 |
1441 protected: | 1436 protected: |
1442 virtual void DoTestOnMessageLoop() override { | 1437 void DoTestOnMessageLoop() override { |
1443 // Move the mouse to the first folder on the bookmark bar and press the | 1438 // Move the mouse to the first folder on the bookmark bar and press the |
1444 // right mouse button. | 1439 // right mouse button. |
1445 views::LabelButton* button = GetBookmarkButton(0); | 1440 views::LabelButton* button = GetBookmarkButton(0); |
1446 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, | 1441 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, |
1447 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1442 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1448 // Step2 will be invoked by BookmarkContextMenuNotificationObserver. | 1443 // Step2 will be invoked by BookmarkContextMenuNotificationObserver. |
1449 } | 1444 } |
1450 | 1445 |
1451 private: | 1446 private: |
1452 | 1447 |
(...skipping 26 matching lines...) Expand all Loading... |
1479 | 1474 |
1480 // Makes sure deleting from the context menu keeps the bookmark menu showing. | 1475 // Makes sure deleting from the context menu keeps the bookmark menu showing. |
1481 class BookmarkBarViewTest15 : public BookmarkBarViewEventTestBase { | 1476 class BookmarkBarViewTest15 : public BookmarkBarViewEventTestBase { |
1482 public: | 1477 public: |
1483 BookmarkBarViewTest15() | 1478 BookmarkBarViewTest15() |
1484 : deleted_menu_id_(0), | 1479 : deleted_menu_id_(0), |
1485 observer_(CreateEventTask(this, &BookmarkBarViewTest15::Step3)) { | 1480 observer_(CreateEventTask(this, &BookmarkBarViewTest15::Step3)) { |
1486 } | 1481 } |
1487 | 1482 |
1488 protected: | 1483 protected: |
1489 virtual void DoTestOnMessageLoop() override { | 1484 void DoTestOnMessageLoop() override { |
1490 // Show the other bookmarks. | 1485 // Show the other bookmarks. |
1491 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1486 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1492 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1487 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1493 ui_controls::DOWN | ui_controls::UP, | 1488 ui_controls::DOWN | ui_controls::UP, |
1494 CreateEventTask(this, &BookmarkBarViewTest15::Step2)); | 1489 CreateEventTask(this, &BookmarkBarViewTest15::Step2)); |
1495 } | 1490 } |
1496 | 1491 |
1497 private: | 1492 private: |
1498 void Step2() { | 1493 void Step2() { |
1499 // Menu should be showing. | 1494 // Menu should be showing. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 | 1545 |
1551 int deleted_menu_id_; | 1546 int deleted_menu_id_; |
1552 BookmarkContextMenuNotificationObserver observer_; | 1547 BookmarkContextMenuNotificationObserver observer_; |
1553 }; | 1548 }; |
1554 | 1549 |
1555 VIEW_TEST(BookmarkBarViewTest15, MenuStaysVisibleAfterDelete) | 1550 VIEW_TEST(BookmarkBarViewTest15, MenuStaysVisibleAfterDelete) |
1556 | 1551 |
1557 // Tests that we don't crash or get stuck if the parent of a menu is closed. | 1552 // Tests that we don't crash or get stuck if the parent of a menu is closed. |
1558 class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase { | 1553 class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase { |
1559 protected: | 1554 protected: |
1560 virtual void DoTestOnMessageLoop() override { | 1555 void DoTestOnMessageLoop() override { |
1561 // Move the mouse to the first folder on the bookmark bar and press the | 1556 // Move the mouse to the first folder on the bookmark bar and press the |
1562 // mouse. | 1557 // mouse. |
1563 views::LabelButton* button = GetBookmarkButton(0); | 1558 views::LabelButton* button = GetBookmarkButton(0); |
1564 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1559 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1565 ui_controls::DOWN | ui_controls::UP, | 1560 ui_controls::DOWN | ui_controls::UP, |
1566 CreateEventTask(this, &BookmarkBarViewTest16::Step2)); | 1561 CreateEventTask(this, &BookmarkBarViewTest16::Step2)); |
1567 } | 1562 } |
1568 | 1563 |
1569 private: | 1564 private: |
1570 void Step2() { | 1565 void Step2() { |
(...skipping 26 matching lines...) Expand all Loading... |
1597 | 1592 |
1598 // Makes sure right clicking on an item while a context menu is already showing | 1593 // Makes sure right clicking on an item while a context menu is already showing |
1599 // doesn't crash and works. | 1594 // doesn't crash and works. |
1600 class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { | 1595 class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { |
1601 public: | 1596 public: |
1602 BookmarkBarViewTest17() | 1597 BookmarkBarViewTest17() |
1603 : observer_(CreateEventTask(this, &BookmarkBarViewTest17::Step3)) { | 1598 : observer_(CreateEventTask(this, &BookmarkBarViewTest17::Step3)) { |
1604 } | 1599 } |
1605 | 1600 |
1606 protected: | 1601 protected: |
1607 virtual void DoTestOnMessageLoop() override { | 1602 void DoTestOnMessageLoop() override { |
1608 // Move the mouse to the other folder on the bookmark bar and press the | 1603 // Move the mouse to the other folder on the bookmark bar and press the |
1609 // left mouse button. | 1604 // left mouse button. |
1610 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1605 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1611 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1606 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1612 ui_controls::DOWN | ui_controls::UP, | 1607 ui_controls::DOWN | ui_controls::UP, |
1613 CreateEventTask(this, &BookmarkBarViewTest17::Step2)); | 1608 CreateEventTask(this, &BookmarkBarViewTest17::Step2)); |
1614 } | 1609 } |
1615 | 1610 |
1616 private: | 1611 private: |
1617 void Step2() { | 1612 void Step2() { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 #define MAYBE_ContextMenus3 ContextMenus3 | 1681 #define MAYBE_ContextMenus3 ContextMenus3 |
1687 #endif | 1682 #endif |
1688 | 1683 |
1689 VIEW_TEST(BookmarkBarViewTest17, MAYBE_ContextMenus3) | 1684 VIEW_TEST(BookmarkBarViewTest17, MAYBE_ContextMenus3) |
1690 | 1685 |
1691 // Verifies sibling menus works. Clicks on the 'other bookmarks' folder, then | 1686 // Verifies sibling menus works. Clicks on the 'other bookmarks' folder, then |
1692 // moves the mouse over the first item on the bookmark bar and makes sure the | 1687 // moves the mouse over the first item on the bookmark bar and makes sure the |
1693 // menu appears. | 1688 // menu appears. |
1694 class BookmarkBarViewTest18 : public BookmarkBarViewEventTestBase { | 1689 class BookmarkBarViewTest18 : public BookmarkBarViewEventTestBase { |
1695 protected: | 1690 protected: |
1696 virtual void DoTestOnMessageLoop() override { | 1691 void DoTestOnMessageLoop() override { |
1697 // Move the mouse to the other folder on the bookmark bar and press the | 1692 // Move the mouse to the other folder on the bookmark bar and press the |
1698 // left mouse button. | 1693 // left mouse button. |
1699 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1694 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1700 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1695 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1701 ui_controls::DOWN | ui_controls::UP, | 1696 ui_controls::DOWN | ui_controls::UP, |
1702 CreateEventTask(this, &BookmarkBarViewTest18::Step2)); | 1697 CreateEventTask(this, &BookmarkBarViewTest18::Step2)); |
1703 } | 1698 } |
1704 | 1699 |
1705 private: | 1700 private: |
1706 void Step2() { | 1701 void Step2() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 #define MAYBE_BookmarkBarViewTest18_SiblingMenu \ | 1738 #define MAYBE_BookmarkBarViewTest18_SiblingMenu \ |
1744 BookmarkBarViewTest18_SiblingMenu | 1739 BookmarkBarViewTest18_SiblingMenu |
1745 #endif | 1740 #endif |
1746 | 1741 |
1747 VIEW_TEST(BookmarkBarViewTest18, MAYBE_BookmarkBarViewTest18_SiblingMenu) | 1742 VIEW_TEST(BookmarkBarViewTest18, MAYBE_BookmarkBarViewTest18_SiblingMenu) |
1748 | 1743 |
1749 // Verifies mousing over an already open sibling menu doesn't prematurely cancel | 1744 // Verifies mousing over an already open sibling menu doesn't prematurely cancel |
1750 // the menu. | 1745 // the menu. |
1751 class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { | 1746 class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { |
1752 protected: | 1747 protected: |
1753 virtual void DoTestOnMessageLoop() override { | 1748 void DoTestOnMessageLoop() override { |
1754 // Move the mouse to the other folder on the bookmark bar and press the | 1749 // Move the mouse to the other folder on the bookmark bar and press the |
1755 // left mouse button. | 1750 // left mouse button. |
1756 views::LabelButton* button = bb_view_->other_bookmarked_button(); | 1751 views::LabelButton* button = bb_view_->other_bookmarked_button(); |
1757 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1752 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1758 ui_controls::DOWN | ui_controls::UP, | 1753 ui_controls::DOWN | ui_controls::UP, |
1759 CreateEventTask(this, &BookmarkBarViewTest19::Step2)); | 1754 CreateEventTask(this, &BookmarkBarViewTest19::Step2)); |
1760 } | 1755 } |
1761 | 1756 |
1762 private: | 1757 private: |
1763 void Step2() { | 1758 void Step2() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 VIEW_TEST(BookmarkBarViewTest19, BookmarkBarViewTest19_SiblingMenu) | 1816 VIEW_TEST(BookmarkBarViewTest19, BookmarkBarViewTest19_SiblingMenu) |
1822 | 1817 |
1823 // Verify that when clicking a mouse button outside a context menu, | 1818 // Verify that when clicking a mouse button outside a context menu, |
1824 // the context menu is dismissed *and* the underlying view receives | 1819 // the context menu is dismissed *and* the underlying view receives |
1825 // the the mouse event (due to event reposting). | 1820 // the the mouse event (due to event reposting). |
1826 class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase { | 1821 class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase { |
1827 public: | 1822 public: |
1828 BookmarkBarViewTest20() : test_view_(new TestViewForMenuExit) {} | 1823 BookmarkBarViewTest20() : test_view_(new TestViewForMenuExit) {} |
1829 | 1824 |
1830 protected: | 1825 protected: |
1831 virtual void DoTestOnMessageLoop() override { | 1826 void DoTestOnMessageLoop() override { |
1832 // Add |test_view_| next to |bb_view_|. | 1827 // Add |test_view_| next to |bb_view_|. |
1833 views::View* parent = bb_view_->parent(); | 1828 views::View* parent = bb_view_->parent(); |
1834 views::View* container_view = new ContainerViewForMenuExit; | 1829 views::View* container_view = new ContainerViewForMenuExit; |
1835 container_view->AddChildView(bb_view_.get()); | 1830 container_view->AddChildView(bb_view_.get()); |
1836 container_view->AddChildView(test_view_); | 1831 container_view->AddChildView(test_view_); |
1837 parent->AddChildView(container_view); | 1832 parent->AddChildView(container_view); |
1838 parent->Layout(); | 1833 parent->Layout(); |
1839 | 1834 |
1840 ASSERT_EQ(test_view_->press_count(), 0); | 1835 ASSERT_EQ(test_view_->press_count(), 0); |
1841 | 1836 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 ASSERT_EQ(test_view_->press_count(), 2); | 1872 ASSERT_EQ(test_view_->press_count(), 2); |
1878 ASSERT_TRUE(bb_view_->GetMenu() == NULL); | 1873 ASSERT_TRUE(bb_view_->GetMenu() == NULL); |
1879 Done(); | 1874 Done(); |
1880 } | 1875 } |
1881 | 1876 |
1882 class ContainerViewForMenuExit : public views::View { | 1877 class ContainerViewForMenuExit : public views::View { |
1883 public: | 1878 public: |
1884 ContainerViewForMenuExit() { | 1879 ContainerViewForMenuExit() { |
1885 } | 1880 } |
1886 | 1881 |
1887 virtual void Layout() override { | 1882 void Layout() override { |
1888 DCHECK_EQ(2, child_count()); | 1883 DCHECK_EQ(2, child_count()); |
1889 views::View* bb_view = child_at(0); | 1884 views::View* bb_view = child_at(0); |
1890 views::View* test_view = child_at(1); | 1885 views::View* test_view = child_at(1); |
1891 const int width = bb_view->width(); | 1886 const int width = bb_view->width(); |
1892 const int height = bb_view->height(); | 1887 const int height = bb_view->height(); |
1893 bb_view->SetBounds(0,0, width - 22, height); | 1888 bb_view->SetBounds(0,0, width - 22, height); |
1894 test_view->SetBounds(width - 20, 0, 20, height); | 1889 test_view->SetBounds(width - 20, 0, 20, height); |
1895 } | 1890 } |
1896 | 1891 |
1897 private: | 1892 private: |
1898 | 1893 |
1899 DISALLOW_COPY_AND_ASSIGN(ContainerViewForMenuExit); | 1894 DISALLOW_COPY_AND_ASSIGN(ContainerViewForMenuExit); |
1900 }; | 1895 }; |
1901 | 1896 |
1902 class TestViewForMenuExit : public views::View { | 1897 class TestViewForMenuExit : public views::View { |
1903 public: | 1898 public: |
1904 TestViewForMenuExit() : press_count_(0) { | 1899 TestViewForMenuExit() : press_count_(0) { |
1905 } | 1900 } |
1906 virtual bool OnMousePressed(const ui::MouseEvent& event) override { | 1901 bool OnMousePressed(const ui::MouseEvent& event) override { |
1907 ++press_count_; | 1902 ++press_count_; |
1908 return true; | 1903 return true; |
1909 } | 1904 } |
1910 int press_count() const { return press_count_; } | 1905 int press_count() const { return press_count_; } |
1911 | 1906 |
1912 private: | 1907 private: |
1913 int press_count_; | 1908 int press_count_; |
1914 | 1909 |
1915 DISALLOW_COPY_AND_ASSIGN(TestViewForMenuExit); | 1910 DISALLOW_COPY_AND_ASSIGN(TestViewForMenuExit); |
1916 }; | 1911 }; |
(...skipping 14 matching lines...) Expand all Loading... |
1931 // The opened context menu should behave as it is from the folder button. | 1926 // The opened context menu should behave as it is from the folder button. |
1932 class BookmarkBarViewTest21 : public BookmarkBarViewEventTestBase { | 1927 class BookmarkBarViewTest21 : public BookmarkBarViewEventTestBase { |
1933 public: | 1928 public: |
1934 BookmarkBarViewTest21() | 1929 BookmarkBarViewTest21() |
1935 : observer_(CreateEventTask(this, &BookmarkBarViewTest21::Step3)) { | 1930 : observer_(CreateEventTask(this, &BookmarkBarViewTest21::Step3)) { |
1936 } | 1931 } |
1937 | 1932 |
1938 protected: | 1933 protected: |
1939 // Move the mouse to the empty folder on the bookmark bar and press the | 1934 // Move the mouse to the empty folder on the bookmark bar and press the |
1940 // left mouse button. | 1935 // left mouse button. |
1941 virtual void DoTestOnMessageLoop() override { | 1936 void DoTestOnMessageLoop() override { |
1942 views::LabelButton* button = GetBookmarkButton(5); | 1937 views::LabelButton* button = GetBookmarkButton(5); |
1943 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1938 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
1944 ui_controls::DOWN | ui_controls::UP, | 1939 ui_controls::DOWN | ui_controls::UP, |
1945 CreateEventTask(this, &BookmarkBarViewTest21::Step2)); | 1940 CreateEventTask(this, &BookmarkBarViewTest21::Step2)); |
1946 } | 1941 } |
1947 | 1942 |
1948 private: | 1943 private: |
1949 // Confirm that a menu for empty folder shows and right click the menu. | 1944 // Confirm that a menu for empty folder shows and right click the menu. |
1950 void Step2() { | 1945 void Step2() { |
1951 // Menu should be showing. | 1946 // Menu should be showing. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 EXPECT_TRUE(bb_view_->GetContextMenu() == NULL); | 1987 EXPECT_TRUE(bb_view_->GetContextMenu() == NULL); |
1993 EXPECT_TRUE(bb_view_->GetMenu() == NULL); | 1988 EXPECT_TRUE(bb_view_->GetMenu() == NULL); |
1994 | 1989 |
1995 Done(); | 1990 Done(); |
1996 } | 1991 } |
1997 | 1992 |
1998 BookmarkContextMenuNotificationObserver observer_; | 1993 BookmarkContextMenuNotificationObserver observer_; |
1999 }; | 1994 }; |
2000 | 1995 |
2001 VIEW_TEST(BookmarkBarViewTest21, ContextMenusForEmptyFolder) | 1996 VIEW_TEST(BookmarkBarViewTest21, ContextMenusForEmptyFolder) |
OLD | NEW |