| 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/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/automation/ui_controls.h" | |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 16 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "chrome/test/base/view_event_test_base.h" | 22 #include "chrome/test/base/view_event_test_base.h" |
| 24 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/page_navigator.h" | 24 #include "content/public/browser/page_navigator.h" |
| 26 #include "content/test/test_browser_thread.h" | 25 #include "content/test/test_browser_thread.h" |
| 27 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 28 #include "ui/base/accessibility/accessibility_types.h" | 27 #include "ui/base/accessibility/accessibility_types.h" |
| 29 #include "ui/base/clipboard/clipboard.h" | 28 #include "ui/base/clipboard/clipboard.h" |
| 30 #include "ui/base/keycodes/keyboard_codes.h" | 29 #include "ui/base/keycodes/keyboard_codes.h" |
| 30 #include "ui/ui_controls/ui_controls.h" |
| 31 #include "ui/views/controls/button/menu_button.h" | 31 #include "ui/views/controls/button/menu_button.h" |
| 32 #include "ui/views/controls/button/text_button.h" | 32 #include "ui/views/controls/button/text_button.h" |
| 33 #include "ui/views/controls/menu/menu_controller.h" | 33 #include "ui/views/controls/menu/menu_controller.h" |
| 34 #include "ui/views/controls/menu/menu_item_view.h" | 34 #include "ui/views/controls/menu/menu_item_view.h" |
| 35 #include "ui/views/controls/menu/submenu_view.h" | 35 #include "ui/views/controls/menu/submenu_view.h" |
| 36 #include "ui/views/views_delegate.h" | 36 #include "ui/views/views_delegate.h" |
| 37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 38 | 38 |
| 39 using content::BrowserThread; | 39 using content::BrowserThread; |
| 40 using content::OpenURLParams; | 40 using content::OpenURLParams; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 }; | 296 }; |
| 297 | 297 |
| 298 // Clicks on first menu, makes sure button is depressed. Moves mouse to first | 298 // Clicks on first menu, makes sure button is depressed. Moves mouse to first |
| 299 // child, clicks it and makes sure a navigation occurs. | 299 // child, clicks it and makes sure a navigation occurs. |
| 300 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { | 300 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { |
| 301 protected: | 301 protected: |
| 302 virtual void DoTestOnMessageLoop() { | 302 virtual void DoTestOnMessageLoop() { |
| 303 // Move the mouse to the first folder on the bookmark bar and press the | 303 // Move the mouse to the first folder on the bookmark bar and press the |
| 304 // mouse. | 304 // mouse. |
| 305 views::TextButton* button = GetBookmarkButton(0); | 305 views::TextButton* button = GetBookmarkButton(0); |
| 306 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 306 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 307 ui_controls::DOWN | ui_controls::UP, | 307 ui_controls::DOWN | ui_controls::UP, |
| 308 CreateEventTask(this, &BookmarkBarViewTest1::Step2)); | 308 CreateEventTask(this, &BookmarkBarViewTest1::Step2)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 private: | 311 private: |
| 312 void Step2() { | 312 void Step2() { |
| 313 // Menu should be showing. | 313 // Menu should be showing. |
| 314 views::MenuItemView* menu = bb_view_->GetMenu(); | 314 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 315 ASSERT_TRUE(menu != NULL); | 315 ASSERT_TRUE(menu != NULL); |
| 316 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 316 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 317 | 317 |
| 318 // Button should be depressed. | 318 // Button should be depressed. |
| 319 views::TextButton* button = GetBookmarkButton(0); | 319 views::TextButton* button = GetBookmarkButton(0); |
| 320 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); | 320 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); |
| 321 | 321 |
| 322 // Click on the 2nd menu item (A URL). | 322 // Click on the 2nd menu item (A URL). |
| 323 ASSERT_TRUE(menu->GetSubmenu()); | 323 ASSERT_TRUE(menu->GetSubmenu()); |
| 324 | 324 |
| 325 views::MenuItemView* menu_to_select = | 325 views::MenuItemView* menu_to_select = |
| 326 menu->GetSubmenu()->GetMenuItemAt(0); | 326 menu->GetSubmenu()->GetMenuItemAt(0); |
| 327 ui_controls::MoveMouseToCenterAndPress(menu_to_select, ui_controls::LEFT, | 327 ui_test_utils::MoveMouseToCenterAndPress(menu_to_select, ui_controls::LEFT, |
| 328 ui_controls::DOWN | ui_controls::UP, | 328 ui_controls::DOWN | ui_controls::UP, |
| 329 CreateEventTask(this, &BookmarkBarViewTest1::Step3)); | 329 CreateEventTask(this, &BookmarkBarViewTest1::Step3)); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void Step3() { | 332 void Step3() { |
| 333 // We should have navigated to URL f1a. | 333 // We should have navigated to URL f1a. |
| 334 ASSERT_TRUE(navigator_.url_ == | 334 ASSERT_TRUE(navigator_.url_ == |
| 335 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url()); | 335 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url()); |
| 336 | 336 |
| 337 // Make sure button is no longer pushed. | 337 // Make sure button is no longer pushed. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 349 // since we move to running the process | 349 // since we move to running the process |
| 350 VIEW_TEST(BookmarkBarViewTest1, DISABLED_Basic) | 350 VIEW_TEST(BookmarkBarViewTest1, DISABLED_Basic) |
| 351 | 351 |
| 352 // Brings up menu, clicks on empty space and make sure menu hides. | 352 // Brings up menu, clicks on empty space and make sure menu hides. |
| 353 class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { | 353 class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { |
| 354 protected: | 354 protected: |
| 355 virtual void DoTestOnMessageLoop() { | 355 virtual void DoTestOnMessageLoop() { |
| 356 // Move the mouse to the first folder on the bookmark bar and press the | 356 // Move the mouse to the first folder on the bookmark bar and press the |
| 357 // mouse. | 357 // mouse. |
| 358 views::TextButton* button = GetBookmarkButton(0); | 358 views::TextButton* button = GetBookmarkButton(0); |
| 359 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 359 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 360 ui_controls::DOWN | ui_controls::UP, | 360 ui_controls::DOWN | ui_controls::UP, |
| 361 CreateEventTask(this, &BookmarkBarViewTest2::Step2)); | 361 CreateEventTask(this, &BookmarkBarViewTest2::Step2)); |
| 362 } | 362 } |
| 363 | 363 |
| 364 private: | 364 private: |
| 365 void Step2() { | 365 void Step2() { |
| 366 // Menu should be showing. | 366 // Menu should be showing. |
| 367 views::MenuItemView* menu = bb_view_->GetMenu(); | 367 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 368 ASSERT_TRUE(menu != NULL && menu->GetSubmenu()->IsShowing()); | 368 ASSERT_TRUE(menu != NULL && menu->GetSubmenu()->IsShowing()); |
| 369 | 369 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 399 VIEW_TEST(BookmarkBarViewTest2, DISABLED_HideOnDesktopClick) | 399 VIEW_TEST(BookmarkBarViewTest2, DISABLED_HideOnDesktopClick) |
| 400 | 400 |
| 401 // Brings up menu. Moves over child to make sure submenu appears, moves over | 401 // Brings up menu. Moves over child to make sure submenu appears, moves over |
| 402 // another child and make sure next menu appears. | 402 // another child and make sure next menu appears. |
| 403 class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { | 403 class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { |
| 404 protected: | 404 protected: |
| 405 virtual void DoTestOnMessageLoop() { | 405 virtual void DoTestOnMessageLoop() { |
| 406 // Move the mouse to the first folder on the bookmark bar and press the | 406 // Move the mouse to the first folder on the bookmark bar and press the |
| 407 // mouse. | 407 // mouse. |
| 408 views::MenuButton* button = bb_view_->other_bookmarked_button(); | 408 views::MenuButton* button = bb_view_->other_bookmarked_button(); |
| 409 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 409 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 410 ui_controls::DOWN | ui_controls::UP, | 410 ui_controls::DOWN | ui_controls::UP, |
| 411 CreateEventTask(this, &BookmarkBarViewTest3::Step2)); | 411 CreateEventTask(this, &BookmarkBarViewTest3::Step2)); |
| 412 } | 412 } |
| 413 | 413 |
| 414 private: | 414 private: |
| 415 void Step2() { | 415 void Step2() { |
| 416 // Menu should be showing. | 416 // Menu should be showing. |
| 417 views::MenuItemView* menu = bb_view_->GetMenu(); | 417 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 418 ASSERT_TRUE(menu != NULL); | 418 ASSERT_TRUE(menu != NULL); |
| 419 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 419 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 420 | 420 |
| 421 views::MenuItemView* child_menu = | 421 views::MenuItemView* child_menu = |
| 422 menu->GetSubmenu()->GetMenuItemAt(1); | 422 menu->GetSubmenu()->GetMenuItemAt(1); |
| 423 ASSERT_TRUE(child_menu != NULL); | 423 ASSERT_TRUE(child_menu != NULL); |
| 424 | 424 |
| 425 // Click on second child, which has a submenu. | 425 // Click on second child, which has a submenu. |
| 426 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 426 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 427 ui_controls::DOWN | ui_controls::UP, | 427 ui_controls::DOWN | ui_controls::UP, |
| 428 CreateEventTask(this, &BookmarkBarViewTest3::Step3)); | 428 CreateEventTask(this, &BookmarkBarViewTest3::Step3)); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void Step3() { | 431 void Step3() { |
| 432 // Make sure sub menu is showing. | 432 // Make sure sub menu is showing. |
| 433 views::MenuItemView* menu = bb_view_->GetMenu(); | 433 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 434 ASSERT_TRUE(menu); | 434 ASSERT_TRUE(menu); |
| 435 views::MenuItemView* child_menu = | 435 views::MenuItemView* child_menu = |
| 436 menu->GetSubmenu()->GetMenuItemAt(1); | 436 menu->GetSubmenu()->GetMenuItemAt(1); |
| 437 ASSERT_TRUE(child_menu->GetSubmenu() != NULL); | 437 ASSERT_TRUE(child_menu->GetSubmenu() != NULL); |
| 438 ASSERT_TRUE(child_menu->GetSubmenu()->IsShowing()); | 438 ASSERT_TRUE(child_menu->GetSubmenu()->IsShowing()); |
| 439 | 439 |
| 440 // Click on third child, which has a submenu too. | 440 // Click on third child, which has a submenu too. |
| 441 child_menu = menu->GetSubmenu()->GetMenuItemAt(2); | 441 child_menu = menu->GetSubmenu()->GetMenuItemAt(2); |
| 442 ASSERT_TRUE(child_menu != NULL); | 442 ASSERT_TRUE(child_menu != NULL); |
| 443 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 443 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 444 ui_controls::DOWN | ui_controls::UP, | 444 ui_controls::DOWN | ui_controls::UP, |
| 445 CreateEventTask(this, &BookmarkBarViewTest3::Step4)); | 445 CreateEventTask(this, &BookmarkBarViewTest3::Step4)); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void Step4() { | 448 void Step4() { |
| 449 // Make sure sub menu we first clicked isn't showing. | 449 // Make sure sub menu we first clicked isn't showing. |
| 450 views::MenuItemView* menu = bb_view_->GetMenu(); | 450 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 451 views::MenuItemView* child_menu = | 451 views::MenuItemView* child_menu = |
| 452 menu->GetSubmenu()->GetMenuItemAt(1); | 452 menu->GetSubmenu()->GetMenuItemAt(1); |
| 453 ASSERT_TRUE(child_menu->GetSubmenu() != NULL); | 453 ASSERT_TRUE(child_menu->GetSubmenu() != NULL); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 BookmarkBarViewTest4() | 506 BookmarkBarViewTest4() |
| 507 : ALLOW_THIS_IN_INITIALIZER_LIST( | 507 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 508 observer_(CreateEventTask(this, &BookmarkBarViewTest4::Step3))) { | 508 observer_(CreateEventTask(this, &BookmarkBarViewTest4::Step3))) { |
| 509 } | 509 } |
| 510 | 510 |
| 511 protected: | 511 protected: |
| 512 virtual void DoTestOnMessageLoop() { | 512 virtual void DoTestOnMessageLoop() { |
| 513 // Move the mouse to the first folder on the bookmark bar and press the | 513 // Move the mouse to the first folder on the bookmark bar and press the |
| 514 // mouse. | 514 // mouse. |
| 515 views::TextButton* button = bb_view_->other_bookmarked_button(); | 515 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 516 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 516 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 517 ui_controls::DOWN | ui_controls::UP, | 517 ui_controls::DOWN | ui_controls::UP, |
| 518 CreateEventTask(this, &BookmarkBarViewTest4::Step2)); | 518 CreateEventTask(this, &BookmarkBarViewTest4::Step2)); |
| 519 } | 519 } |
| 520 | 520 |
| 521 private: | 521 private: |
| 522 void Step2() { | 522 void Step2() { |
| 523 // Menu should be showing. | 523 // Menu should be showing. |
| 524 views::MenuItemView* menu = bb_view_->GetMenu(); | 524 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 525 ASSERT_TRUE(menu != NULL); | 525 ASSERT_TRUE(menu != NULL); |
| 526 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 526 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 527 | 527 |
| 528 views::MenuItemView* child_menu = | 528 views::MenuItemView* child_menu = |
| 529 menu->GetSubmenu()->GetMenuItemAt(0); | 529 menu->GetSubmenu()->GetMenuItemAt(0); |
| 530 ASSERT_TRUE(child_menu != NULL); | 530 ASSERT_TRUE(child_menu != NULL); |
| 531 | 531 |
| 532 // Right click on the first child to get its context menu. | 532 // Right click on the first child to get its context menu. |
| 533 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 533 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 534 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 534 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 535 // Step3 will be invoked by ContextMenuNotificationObserver. | 535 // Step3 will be invoked by ContextMenuNotificationObserver. |
| 536 } | 536 } |
| 537 | 537 |
| 538 void Step3() { | 538 void Step3() { |
| 539 // Make sure the context menu is showing. | 539 // Make sure the context menu is showing. |
| 540 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 540 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 541 ASSERT_TRUE(menu != NULL); | 541 ASSERT_TRUE(menu != NULL); |
| 542 ASSERT_TRUE(menu->GetSubmenu()); | 542 ASSERT_TRUE(menu->GetSubmenu()); |
| 543 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 543 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 544 | 544 |
| 545 // Select the first menu item (open). | 545 // Select the first menu item (open). |
| 546 ui_controls::MoveMouseToCenterAndPress(menu->GetSubmenu()->GetMenuItemAt(0), | 546 ui_test_utils::MoveMouseToCenterAndPress( |
| 547 menu->GetSubmenu()->GetMenuItemAt(0), |
| 547 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 548 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 548 CreateEventTask(this, &BookmarkBarViewTest4::Step4)); | 549 CreateEventTask(this, &BookmarkBarViewTest4::Step4)); |
| 549 } | 550 } |
| 550 | 551 |
| 551 void Step4() { | 552 void Step4() { |
| 552 EXPECT_EQ(navigator_.url_, model_->other_node()->GetChild(0)->url()); | 553 EXPECT_EQ(navigator_.url_, model_->other_node()->GetChild(0)->url()); |
| 553 Done(); | 554 Done(); |
| 554 } | 555 } |
| 555 | 556 |
| 556 ContextMenuNotificationObserver observer_; | 557 ContextMenuNotificationObserver observer_; |
| 557 }; | 558 }; |
| 558 | 559 |
| 559 VIEW_TEST(BookmarkBarViewTest4, ContextMenus) | 560 VIEW_TEST(BookmarkBarViewTest4, ContextMenus) |
| 560 | 561 |
| 561 // Tests drag and drop within the same menu. | 562 // Tests drag and drop within the same menu. |
| 562 class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { | 563 class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { |
| 563 protected: | 564 protected: |
| 564 virtual void DoTestOnMessageLoop() { | 565 virtual void DoTestOnMessageLoop() { |
| 565 url_dragging_ = | 566 url_dragging_ = |
| 566 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); | 567 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); |
| 567 | 568 |
| 568 // Move the mouse to the first folder on the bookmark bar and press the | 569 // Move the mouse to the first folder on the bookmark bar and press the |
| 569 // mouse. | 570 // mouse. |
| 570 views::TextButton* button = GetBookmarkButton(0); | 571 views::TextButton* button = GetBookmarkButton(0); |
| 571 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 572 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 572 ui_controls::DOWN | ui_controls::UP, | 573 ui_controls::DOWN | ui_controls::UP, |
| 573 CreateEventTask(this, &BookmarkBarViewTest5::Step2)); | 574 CreateEventTask(this, &BookmarkBarViewTest5::Step2)); |
| 574 } | 575 } |
| 575 | 576 |
| 576 private: | 577 private: |
| 577 void Step2() { | 578 void Step2() { |
| 578 // Menu should be showing. | 579 // Menu should be showing. |
| 579 views::MenuItemView* menu = bb_view_->GetMenu(); | 580 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 580 ASSERT_TRUE(menu != NULL); | 581 ASSERT_TRUE(menu != NULL); |
| 581 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 582 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 582 | 583 |
| 583 views::MenuItemView* child_menu = | 584 views::MenuItemView* child_menu = |
| 584 menu->GetSubmenu()->GetMenuItemAt(0); | 585 menu->GetSubmenu()->GetMenuItemAt(0); |
| 585 ASSERT_TRUE(child_menu != NULL); | 586 ASSERT_TRUE(child_menu != NULL); |
| 586 | 587 |
| 587 // Move mouse to center of menu and press button. | 588 // Move mouse to center of menu and press button. |
| 588 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 589 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 589 ui_controls::DOWN, | 590 ui_controls::DOWN, |
| 590 CreateEventTask(this, &BookmarkBarViewTest5::Step3)); | 591 CreateEventTask(this, &BookmarkBarViewTest5::Step3)); |
| 591 } | 592 } |
| 592 | 593 |
| 593 void Step3() { | 594 void Step3() { |
| 594 views::MenuItemView* target_menu = | 595 views::MenuItemView* target_menu = |
| 595 bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); | 596 bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); |
| 596 gfx::Point loc(1, target_menu->height() - 1); | 597 gfx::Point loc(1, target_menu->height() - 1); |
| 597 views::View::ConvertPointToScreen(target_menu, &loc); | 598 views::View::ConvertPointToScreen(target_menu, &loc); |
| 598 | 599 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 628 | 629 |
| 629 VIEW_TEST(BookmarkBarViewTest5, MAYBE_DND) | 630 VIEW_TEST(BookmarkBarViewTest5, MAYBE_DND) |
| 630 | 631 |
| 631 // Tests holding mouse down on overflow button, dragging such that menu pops up | 632 // Tests holding mouse down on overflow button, dragging such that menu pops up |
| 632 // then selecting an item. | 633 // then selecting an item. |
| 633 class BookmarkBarViewTest6 : public BookmarkBarViewEventTestBase { | 634 class BookmarkBarViewTest6 : public BookmarkBarViewEventTestBase { |
| 634 protected: | 635 protected: |
| 635 virtual void DoTestOnMessageLoop() { | 636 virtual void DoTestOnMessageLoop() { |
| 636 // Press the mouse button on the overflow button. Don't release it though. | 637 // Press the mouse button on the overflow button. Don't release it though. |
| 637 views::TextButton* button = bb_view_->overflow_button(); | 638 views::TextButton* button = bb_view_->overflow_button(); |
| 638 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 639 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 639 ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest6::Step2)); | 640 ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest6::Step2)); |
| 640 } | 641 } |
| 641 | 642 |
| 642 private: | 643 private: |
| 643 void Step2() { | 644 void Step2() { |
| 644 // Menu should be showing. | 645 // Menu should be showing. |
| 645 views::MenuItemView* menu = bb_view_->GetMenu(); | 646 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 646 ASSERT_TRUE(menu != NULL); | 647 ASSERT_TRUE(menu != NULL); |
| 647 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 648 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 648 | 649 |
| 649 views::MenuItemView* child_menu = | 650 views::MenuItemView* child_menu = |
| 650 menu->GetSubmenu()->GetMenuItemAt(0); | 651 menu->GetSubmenu()->GetMenuItemAt(0); |
| 651 ASSERT_TRUE(child_menu != NULL); | 652 ASSERT_TRUE(child_menu != NULL); |
| 652 | 653 |
| 653 // Move mouse to center of menu and release mouse. | 654 // Move mouse to center of menu and release mouse. |
| 654 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 655 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 655 ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest6::Step3)); | 656 ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest6::Step3)); |
| 656 } | 657 } |
| 657 | 658 |
| 658 void Step3() { | 659 void Step3() { |
| 659 ASSERT_TRUE(navigator_.url_ == | 660 ASSERT_TRUE(navigator_.url_ == |
| 660 model_->bookmark_bar_node()->GetChild(4)->url()); | 661 model_->bookmark_bar_node()->GetChild(4)->url()); |
| 661 Done(); | 662 Done(); |
| 662 } | 663 } |
| 663 | 664 |
| 664 GURL url_dragging_; | 665 GURL url_dragging_; |
| 665 }; | 666 }; |
| 666 | 667 |
| 667 VIEW_TEST(BookmarkBarViewTest6, OpenMenuOnClickAndHold) | 668 VIEW_TEST(BookmarkBarViewTest6, OpenMenuOnClickAndHold) |
| 668 | 669 |
| 669 // Tests drag and drop to different menu. | 670 // Tests drag and drop to different menu. |
| 670 class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { | 671 class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { |
| 671 protected: | 672 protected: |
| 672 virtual void DoTestOnMessageLoop() { | 673 virtual void DoTestOnMessageLoop() { |
| 673 url_dragging_ = | 674 url_dragging_ = |
| 674 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); | 675 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); |
| 675 | 676 |
| 676 // Move the mouse to the first folder on the bookmark bar and press the | 677 // Move the mouse to the first folder on the bookmark bar and press the |
| 677 // mouse. | 678 // mouse. |
| 678 views::TextButton* button = GetBookmarkButton(0); | 679 views::TextButton* button = GetBookmarkButton(0); |
| 679 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 680 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 680 ui_controls::DOWN | ui_controls::UP, | 681 ui_controls::DOWN | ui_controls::UP, |
| 681 CreateEventTask(this, &BookmarkBarViewTest7::Step2)); | 682 CreateEventTask(this, &BookmarkBarViewTest7::Step2)); |
| 682 } | 683 } |
| 683 | 684 |
| 684 private: | 685 private: |
| 685 void Step2() { | 686 void Step2() { |
| 686 // Menu should be showing. | 687 // Menu should be showing. |
| 687 views::MenuItemView* menu = bb_view_->GetMenu(); | 688 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 688 ASSERT_TRUE(menu != NULL); | 689 ASSERT_TRUE(menu != NULL); |
| 689 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 690 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 690 | 691 |
| 691 views::MenuItemView* child_menu = | 692 views::MenuItemView* child_menu = |
| 692 menu->GetSubmenu()->GetMenuItemAt(0); | 693 menu->GetSubmenu()->GetMenuItemAt(0); |
| 693 ASSERT_TRUE(child_menu != NULL); | 694 ASSERT_TRUE(child_menu != NULL); |
| 694 | 695 |
| 695 // Move mouse to center of menu and press button. | 696 // Move mouse to center of menu and press button. |
| 696 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 697 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 697 ui_controls::DOWN, | 698 ui_controls::DOWN, |
| 698 CreateEventTask(this, &BookmarkBarViewTest7::Step3)); | 699 CreateEventTask(this, &BookmarkBarViewTest7::Step3)); |
| 699 } | 700 } |
| 700 | 701 |
| 701 void Step3() { | 702 void Step3() { |
| 702 // Drag over other button. | 703 // Drag over other button. |
| 703 views::TextButton* other_button = | 704 views::TextButton* other_button = |
| 704 bb_view_->other_bookmarked_button(); | 705 bb_view_->other_bookmarked_button(); |
| 705 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); | 706 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); |
| 706 views::View::ConvertPointToScreen(other_button, &loc); | 707 views::View::ConvertPointToScreen(other_button, &loc); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 // original menu. | 743 // original menu. |
| 743 class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { | 744 class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { |
| 744 protected: | 745 protected: |
| 745 virtual void DoTestOnMessageLoop() { | 746 virtual void DoTestOnMessageLoop() { |
| 746 url_dragging_ = | 747 url_dragging_ = |
| 747 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); | 748 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url(); |
| 748 | 749 |
| 749 // Move the mouse to the first folder on the bookmark bar and press the | 750 // Move the mouse to the first folder on the bookmark bar and press the |
| 750 // mouse. | 751 // mouse. |
| 751 views::TextButton* button = GetBookmarkButton(0); | 752 views::TextButton* button = GetBookmarkButton(0); |
| 752 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 753 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 753 ui_controls::DOWN | ui_controls::UP, | 754 ui_controls::DOWN | ui_controls::UP, |
| 754 CreateEventTask(this, &BookmarkBarViewTest8::Step2)); | 755 CreateEventTask(this, &BookmarkBarViewTest8::Step2)); |
| 755 } | 756 } |
| 756 | 757 |
| 757 private: | 758 private: |
| 758 void Step2() { | 759 void Step2() { |
| 759 // Menu should be showing. | 760 // Menu should be showing. |
| 760 views::MenuItemView* menu = bb_view_->GetMenu(); | 761 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 761 ASSERT_TRUE(menu != NULL); | 762 ASSERT_TRUE(menu != NULL); |
| 762 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 763 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 763 | 764 |
| 764 views::MenuItemView* child_menu = | 765 views::MenuItemView* child_menu = |
| 765 menu->GetSubmenu()->GetMenuItemAt(0); | 766 menu->GetSubmenu()->GetMenuItemAt(0); |
| 766 ASSERT_TRUE(child_menu != NULL); | 767 ASSERT_TRUE(child_menu != NULL); |
| 767 | 768 |
| 768 // Move mouse to center of menu and press button. | 769 // Move mouse to center of menu and press button. |
| 769 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 770 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 770 ui_controls::DOWN, | 771 ui_controls::DOWN, |
| 771 CreateEventTask(this, &BookmarkBarViewTest8::Step3)); | 772 CreateEventTask(this, &BookmarkBarViewTest8::Step3)); |
| 772 } | 773 } |
| 773 | 774 |
| 774 void Step3() { | 775 void Step3() { |
| 775 // Drag over other button. | 776 // Drag over other button. |
| 776 views::TextButton* other_button = | 777 views::TextButton* other_button = |
| 777 bb_view_->other_bookmarked_button(); | 778 bb_view_->other_bookmarked_button(); |
| 778 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); | 779 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); |
| 779 views::View::ConvertPointToScreen(other_button, &loc); | 780 views::View::ConvertPointToScreen(other_button, &loc); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 800 } | 801 } |
| 801 | 802 |
| 802 void Step5() { | 803 void Step5() { |
| 803 // Drop on folder F11. | 804 // Drop on folder F11. |
| 804 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 805 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
| 805 ASSERT_TRUE(drop_menu != NULL); | 806 ASSERT_TRUE(drop_menu != NULL); |
| 806 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 807 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
| 807 | 808 |
| 808 views::MenuItemView* target_menu = | 809 views::MenuItemView* target_menu = |
| 809 drop_menu->GetSubmenu()->GetMenuItemAt(1); | 810 drop_menu->GetSubmenu()->GetMenuItemAt(1); |
| 810 ui_controls::MoveMouseToCenterAndPress( | 811 ui_test_utils::MoveMouseToCenterAndPress( |
| 811 target_menu, ui_controls::LEFT, ui_controls::UP, | 812 target_menu, ui_controls::LEFT, ui_controls::UP, |
| 812 CreateEventTask(this, &BookmarkBarViewTest8::Step6)); | 813 CreateEventTask(this, &BookmarkBarViewTest8::Step6)); |
| 813 } | 814 } |
| 814 | 815 |
| 815 void Step6() { | 816 void Step6() { |
| 816 // Make sure drop was processed. | 817 // Make sure drop was processed. |
| 817 GURL final_url = model_->bookmark_bar_node()->GetChild(0)->GetChild(0)-> | 818 GURL final_url = model_->bookmark_bar_node()->GetChild(0)->GetChild(0)-> |
| 818 GetChild(1)->url(); | 819 GetChild(1)->url(); |
| 819 ASSERT_TRUE(final_url == url_dragging_); | 820 ASSERT_TRUE(final_url == url_dragging_); |
| 820 Done(); | 821 Done(); |
| 821 } | 822 } |
| 822 | 823 |
| 823 GURL url_dragging_; | 824 GURL url_dragging_; |
| 824 }; | 825 }; |
| 825 | 826 |
| 826 VIEW_TEST(BookmarkBarViewTest8, MAYBE_DNDBackToOriginatingMenu) | 827 VIEW_TEST(BookmarkBarViewTest8, MAYBE_DNDBackToOriginatingMenu) |
| 827 | 828 |
| 828 // Moves the mouse over the scroll button and makes sure we get scrolling. | 829 // Moves the mouse over the scroll button and makes sure we get scrolling. |
| 829 class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { | 830 class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { |
| 830 protected: | 831 protected: |
| 831 virtual bool CreateBigMenu() { return true; } | 832 virtual bool CreateBigMenu() { return true; } |
| 832 | 833 |
| 833 virtual void DoTestOnMessageLoop() { | 834 virtual void DoTestOnMessageLoop() { |
| 834 // Move the mouse to the first folder on the bookmark bar and press the | 835 // Move the mouse to the first folder on the bookmark bar and press the |
| 835 // mouse. | 836 // mouse. |
| 836 views::TextButton* button = GetBookmarkButton(0); | 837 views::TextButton* button = GetBookmarkButton(0); |
| 837 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 838 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 838 ui_controls::DOWN | ui_controls::UP, | 839 ui_controls::DOWN | ui_controls::UP, |
| 839 CreateEventTask(this, &BookmarkBarViewTest9::Step2)); | 840 CreateEventTask(this, &BookmarkBarViewTest9::Step2)); |
| 840 } | 841 } |
| 841 | 842 |
| 842 private: | 843 private: |
| 843 void Step2() { | 844 void Step2() { |
| 844 // Menu should be showing. | 845 // Menu should be showing. |
| 845 views::MenuItemView* menu = bb_view_->GetMenu(); | 846 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 846 ASSERT_TRUE(menu != NULL); | 847 ASSERT_TRUE(menu != NULL); |
| 847 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 848 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 | 896 |
| 896 VIEW_TEST(BookmarkBarViewTest9, MAYBE_ScrollButtonScrolls) | 897 VIEW_TEST(BookmarkBarViewTest9, MAYBE_ScrollButtonScrolls) |
| 897 | 898 |
| 898 // Tests up/down/left/enter key messages. | 899 // Tests up/down/left/enter key messages. |
| 899 class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { | 900 class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { |
| 900 protected: | 901 protected: |
| 901 virtual void DoTestOnMessageLoop() { | 902 virtual void DoTestOnMessageLoop() { |
| 902 // Move the mouse to the first folder on the bookmark bar and press the | 903 // Move the mouse to the first folder on the bookmark bar and press the |
| 903 // mouse. | 904 // mouse. |
| 904 views::TextButton* button = GetBookmarkButton(0); | 905 views::TextButton* button = GetBookmarkButton(0); |
| 905 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 906 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 906 ui_controls::DOWN | ui_controls::UP, | 907 ui_controls::DOWN | ui_controls::UP, |
| 907 CreateEventTask(this, &BookmarkBarViewTest10::Step2)); | 908 CreateEventTask(this, &BookmarkBarViewTest10::Step2)); |
| 908 MessageLoop::current()->RunAllPending(); | 909 MessageLoop::current()->RunAllPending(); |
| 909 } | 910 } |
| 910 | 911 |
| 911 private: | 912 private: |
| 912 void Step2() { | 913 void Step2() { |
| 913 // Menu should be showing. | 914 // Menu should be showing. |
| 914 views::MenuItemView* menu = bb_view_->GetMenu(); | 915 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 915 ASSERT_TRUE(menu != NULL); | 916 ASSERT_TRUE(menu != NULL); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 BookmarkBarViewTest11() | 1011 BookmarkBarViewTest11() |
| 1011 : ALLOW_THIS_IN_INITIALIZER_LIST( | 1012 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 1012 observer_(CreateEventTask(this, &BookmarkBarViewTest11::Step3))) { | 1013 observer_(CreateEventTask(this, &BookmarkBarViewTest11::Step3))) { |
| 1013 } | 1014 } |
| 1014 | 1015 |
| 1015 protected: | 1016 protected: |
| 1016 virtual void DoTestOnMessageLoop() { | 1017 virtual void DoTestOnMessageLoop() { |
| 1017 // Move the mouse to the first folder on the bookmark bar and press the | 1018 // Move the mouse to the first folder on the bookmark bar and press the |
| 1018 // mouse. | 1019 // mouse. |
| 1019 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1020 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1020 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1021 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1021 ui_controls::DOWN | ui_controls::UP, | 1022 ui_controls::DOWN | ui_controls::UP, |
| 1022 CreateEventTask(this, &BookmarkBarViewTest11::Step2)); | 1023 CreateEventTask(this, &BookmarkBarViewTest11::Step2)); |
| 1023 } | 1024 } |
| 1024 | 1025 |
| 1025 private: | 1026 private: |
| 1026 void Step2() { | 1027 void Step2() { |
| 1027 // Menu should be showing. | 1028 // Menu should be showing. |
| 1028 views::MenuItemView* menu = bb_view_->GetMenu(); | 1029 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1029 ASSERT_TRUE(menu != NULL); | 1030 ASSERT_TRUE(menu != NULL); |
| 1030 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1031 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1031 | 1032 |
| 1032 views::MenuItemView* child_menu = | 1033 views::MenuItemView* child_menu = |
| 1033 menu->GetSubmenu()->GetMenuItemAt(0); | 1034 menu->GetSubmenu()->GetMenuItemAt(0); |
| 1034 ASSERT_TRUE(child_menu != NULL); | 1035 ASSERT_TRUE(child_menu != NULL); |
| 1035 | 1036 |
| 1036 // Right click on the first child to get its context menu. | 1037 // Right click on the first child to get its context menu. |
| 1037 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1038 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1038 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1039 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1039 // Step3 will be invoked by ContextMenuNotificationObserver. | 1040 // Step3 will be invoked by ContextMenuNotificationObserver. |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 void Step3() { | 1043 void Step3() { |
| 1043 // Send escape so that the context menu hides. | 1044 // Send escape so that the context menu hides. |
| 1044 ui_controls::SendKeyPressNotifyWhenDone( | 1045 ui_controls::SendKeyPressNotifyWhenDone( |
| 1045 NULL, ui::VKEY_ESCAPE, false, false, false, false, | 1046 NULL, ui::VKEY_ESCAPE, false, false, false, false, |
| 1046 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); | 1047 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); |
| 1047 } | 1048 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1077 }; | 1078 }; |
| 1078 | 1079 |
| 1079 VIEW_TEST(BookmarkBarViewTest11, MAYBE_CloseMenuAfterClosingContextMenu) | 1080 VIEW_TEST(BookmarkBarViewTest11, MAYBE_CloseMenuAfterClosingContextMenu) |
| 1080 | 1081 |
| 1081 // Tests showing a modal dialog from a context menu. | 1082 // Tests showing a modal dialog from a context menu. |
| 1082 class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { | 1083 class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { |
| 1083 protected: | 1084 protected: |
| 1084 virtual void DoTestOnMessageLoop() { | 1085 virtual void DoTestOnMessageLoop() { |
| 1085 // Open up the other folder. | 1086 // Open up the other folder. |
| 1086 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1087 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1087 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1088 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1088 ui_controls::DOWN | ui_controls::UP, | 1089 ui_controls::DOWN | ui_controls::UP, |
| 1089 CreateEventTask(this, &BookmarkBarViewTest12::Step2)); | 1090 CreateEventTask(this, &BookmarkBarViewTest12::Step2)); |
| 1090 bookmark_utils::num_urls_before_prompting = 1; | 1091 bookmark_utils::num_urls_before_prompting = 1; |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 ~BookmarkBarViewTest12() { | 1094 ~BookmarkBarViewTest12() { |
| 1094 bookmark_utils::num_urls_before_prompting = 15; | 1095 bookmark_utils::num_urls_before_prompting = 15; |
| 1095 } | 1096 } |
| 1096 | 1097 |
| 1097 private: | 1098 private: |
| 1098 void Step2() { | 1099 void Step2() { |
| 1099 // Menu should be showing. | 1100 // Menu should be showing. |
| 1100 views::MenuItemView* menu = bb_view_->GetMenu(); | 1101 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1101 ASSERT_TRUE(menu != NULL); | 1102 ASSERT_TRUE(menu != NULL); |
| 1102 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1103 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1103 | 1104 |
| 1104 views::MenuItemView* child_menu = | 1105 views::MenuItemView* child_menu = |
| 1105 menu->GetSubmenu()->GetMenuItemAt(1); | 1106 menu->GetSubmenu()->GetMenuItemAt(1); |
| 1106 ASSERT_TRUE(child_menu != NULL); | 1107 ASSERT_TRUE(child_menu != NULL); |
| 1107 | 1108 |
| 1108 // Right click on the second child (a folder) to get its context menu. | 1109 // Right click on the second child (a folder) to get its context menu. |
| 1109 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1110 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1110 ui_controls::DOWN | ui_controls::UP, | 1111 ui_controls::DOWN | ui_controls::UP, |
| 1111 CreateEventTask(this, &BookmarkBarViewTest12::Step3)); | 1112 CreateEventTask(this, &BookmarkBarViewTest12::Step3)); |
| 1112 } | 1113 } |
| 1113 | 1114 |
| 1114 void Step3() { | 1115 void Step3() { |
| 1115 // Make sure the context menu is showing. | 1116 // Make sure the context menu is showing. |
| 1116 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1117 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1117 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); | 1118 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); |
| 1118 | 1119 |
| 1119 // Select the first item in the context menu (open all). | 1120 // Select the first item in the context menu (open all). |
| 1120 views::MenuItemView* child_menu = | 1121 views::MenuItemView* child_menu = |
| 1121 menu->GetSubmenu()->GetMenuItemAt(0); | 1122 menu->GetSubmenu()->GetMenuItemAt(0); |
| 1122 ASSERT_TRUE(child_menu != NULL); | 1123 ASSERT_TRUE(child_menu != NULL); |
| 1123 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 1124 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 1124 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1125 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1125 | 1126 |
| 1126 // Delay until we send tab, otherwise the message box doesn't appear | 1127 // Delay until we send tab, otherwise the message box doesn't appear |
| 1127 // correctly. | 1128 // correctly. |
| 1128 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1129 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1129 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); | 1130 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); |
| 1130 } | 1131 } |
| 1131 | 1132 |
| 1132 void Step4() { | 1133 void Step4() { |
| 1133 // Press tab to give focus to the cancel button. | 1134 // Press tab to give focus to the cancel button. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 BookmarkBarViewTest13() | 1166 BookmarkBarViewTest13() |
| 1166 : ALLOW_THIS_IN_INITIALIZER_LIST( | 1167 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 1167 observer_(CreateEventTask(this, &BookmarkBarViewTest13::Step3))) { | 1168 observer_(CreateEventTask(this, &BookmarkBarViewTest13::Step3))) { |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1170 protected: | 1171 protected: |
| 1171 virtual void DoTestOnMessageLoop() { | 1172 virtual void DoTestOnMessageLoop() { |
| 1172 // Move the mouse to the first folder on the bookmark bar and press the | 1173 // Move the mouse to the first folder on the bookmark bar and press the |
| 1173 // mouse. | 1174 // mouse. |
| 1174 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1175 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1175 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1176 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1176 ui_controls::DOWN | ui_controls::UP, | 1177 ui_controls::DOWN | ui_controls::UP, |
| 1177 CreateEventTask(this, &BookmarkBarViewTest13::Step2)); | 1178 CreateEventTask(this, &BookmarkBarViewTest13::Step2)); |
| 1178 } | 1179 } |
| 1179 | 1180 |
| 1180 private: | 1181 private: |
| 1181 void Step2() { | 1182 void Step2() { |
| 1182 // Menu should be showing. | 1183 // Menu should be showing. |
| 1183 views::MenuItemView* menu = bb_view_->GetMenu(); | 1184 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1184 ASSERT_TRUE(menu != NULL); | 1185 ASSERT_TRUE(menu != NULL); |
| 1185 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1186 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1186 | 1187 |
| 1187 views::MenuItemView* child_menu = | 1188 views::MenuItemView* child_menu = |
| 1188 menu->GetSubmenu()->GetMenuItemAt(0); | 1189 menu->GetSubmenu()->GetMenuItemAt(0); |
| 1189 ASSERT_TRUE(child_menu != NULL); | 1190 ASSERT_TRUE(child_menu != NULL); |
| 1190 | 1191 |
| 1191 // Right click on the first child to get its context menu. | 1192 // Right click on the first child to get its context menu. |
| 1192 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1193 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1193 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1194 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1194 // Step3 will be invoked by ContextMenuNotificationObserver. | 1195 // Step3 will be invoked by ContextMenuNotificationObserver. |
| 1195 } | 1196 } |
| 1196 | 1197 |
| 1197 void Step3() { | 1198 void Step3() { |
| 1198 // Make sure the context menu is showing. | 1199 // Make sure the context menu is showing. |
| 1199 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1200 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1200 ASSERT_TRUE(menu != NULL); | 1201 ASSERT_TRUE(menu != NULL); |
| 1201 ASSERT_TRUE(menu->GetSubmenu()); | 1202 ASSERT_TRUE(menu->GetSubmenu()); |
| 1202 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1203 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1203 | 1204 |
| 1204 // Find the first separator. | 1205 // Find the first separator. |
| 1205 views::SubmenuView* submenu = menu->GetSubmenu(); | 1206 views::SubmenuView* submenu = menu->GetSubmenu(); |
| 1206 views::View* separator_view = NULL; | 1207 views::View* separator_view = NULL; |
| 1207 for (int i = 0; i < submenu->child_count(); ++i) { | 1208 for (int i = 0; i < submenu->child_count(); ++i) { |
| 1208 if (submenu->child_at(i)->id() != views::MenuItemView::kMenuItemViewID) { | 1209 if (submenu->child_at(i)->id() != views::MenuItemView::kMenuItemViewID) { |
| 1209 separator_view = submenu->child_at(i); | 1210 separator_view = submenu->child_at(i); |
| 1210 break; | 1211 break; |
| 1211 } | 1212 } |
| 1212 } | 1213 } |
| 1213 ASSERT_TRUE(separator_view); | 1214 ASSERT_TRUE(separator_view); |
| 1214 | 1215 |
| 1215 // Click on the separator. Clicking on the separator shouldn't visually | 1216 // Click on the separator. Clicking on the separator shouldn't visually |
| 1216 // change anything. | 1217 // change anything. |
| 1217 ui_controls::MoveMouseToCenterAndPress(separator_view, | 1218 ui_test_utils::MoveMouseToCenterAndPress(separator_view, |
| 1218 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 1219 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 1219 CreateEventTask(this, &BookmarkBarViewTest13::Step4)); | 1220 CreateEventTask(this, &BookmarkBarViewTest13::Step4)); |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 void Step4() { | 1223 void Step4() { |
| 1223 // The context menu should still be showing. | 1224 // The context menu should still be showing. |
| 1224 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1225 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1225 ASSERT_TRUE(menu != NULL); | 1226 ASSERT_TRUE(menu != NULL); |
| 1226 ASSERT_TRUE(menu->GetSubmenu()); | 1227 ASSERT_TRUE(menu->GetSubmenu()); |
| 1227 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1228 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1228 | 1229 |
| 1229 // Select the first context menu item. | 1230 // Select the first context menu item. |
| 1230 ui_controls::MoveMouseToCenterAndPress(menu->GetSubmenu()->GetMenuItemAt(0), | 1231 ui_test_utils::MoveMouseToCenterAndPress( |
| 1231 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 1232 menu->GetSubmenu()->GetMenuItemAt(0), |
| 1233 ui_controls::LEFT, |
| 1234 ui_controls::DOWN | ui_controls::UP, |
| 1232 CreateEventTask(this, &BookmarkBarViewTest13::Step5)); | 1235 CreateEventTask(this, &BookmarkBarViewTest13::Step5)); |
| 1233 } | 1236 } |
| 1234 | 1237 |
| 1235 void Step5() { | 1238 void Step5() { |
| 1236 Done(); | 1239 Done(); |
| 1237 } | 1240 } |
| 1238 | 1241 |
| 1239 ContextMenuNotificationObserver observer_; | 1242 ContextMenuNotificationObserver observer_; |
| 1240 }; | 1243 }; |
| 1241 | 1244 |
| 1242 VIEW_TEST(BookmarkBarViewTest13, ClickOnContextMenuSeparator) | 1245 VIEW_TEST(BookmarkBarViewTest13, ClickOnContextMenuSeparator) |
| 1243 | 1246 |
| 1244 // Makes sure right clicking on a folder on the bookmark bar doesn't result in | 1247 // Makes sure right clicking on a folder on the bookmark bar doesn't result in |
| 1245 // both a context menu and showing the menu. | 1248 // both a context menu and showing the menu. |
| 1246 class BookmarkBarViewTest14 : public BookmarkBarViewEventTestBase { | 1249 class BookmarkBarViewTest14 : public BookmarkBarViewEventTestBase { |
| 1247 public: | 1250 public: |
| 1248 BookmarkBarViewTest14() | 1251 BookmarkBarViewTest14() |
| 1249 : ALLOW_THIS_IN_INITIALIZER_LIST( | 1252 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 1250 observer_(CreateEventTask(this, &BookmarkBarViewTest14::Step2))) { | 1253 observer_(CreateEventTask(this, &BookmarkBarViewTest14::Step2))) { |
| 1251 } | 1254 } |
| 1252 | 1255 |
| 1253 protected: | 1256 protected: |
| 1254 virtual void DoTestOnMessageLoop() { | 1257 virtual void DoTestOnMessageLoop() { |
| 1255 // Move the mouse to the first folder on the bookmark bar and press the | 1258 // Move the mouse to the first folder on the bookmark bar and press the |
| 1256 // right mouse button. | 1259 // right mouse button. |
| 1257 views::TextButton* button = GetBookmarkButton(0); | 1260 views::TextButton* button = GetBookmarkButton(0); |
| 1258 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, | 1261 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, |
| 1259 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1262 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1260 // Step2 will be invoked by ContextMenuNotificationObserver. | 1263 // Step2 will be invoked by ContextMenuNotificationObserver. |
| 1261 } | 1264 } |
| 1262 | 1265 |
| 1263 private: | 1266 private: |
| 1264 | 1267 |
| 1265 void Step2() { | 1268 void Step2() { |
| 1266 // Menu should NOT be showing. | 1269 // Menu should NOT be showing. |
| 1267 views::MenuItemView* menu = bb_view_->GetMenu(); | 1270 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1268 ASSERT_TRUE(menu == NULL); | 1271 ASSERT_TRUE(menu == NULL); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1288 BookmarkBarViewTest15() | 1291 BookmarkBarViewTest15() |
| 1289 : deleted_menu_id_(0), | 1292 : deleted_menu_id_(0), |
| 1290 ALLOW_THIS_IN_INITIALIZER_LIST( | 1293 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 1291 observer_(CreateEventTask(this, &BookmarkBarViewTest15::Step3))) { | 1294 observer_(CreateEventTask(this, &BookmarkBarViewTest15::Step3))) { |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 protected: | 1297 protected: |
| 1295 virtual void DoTestOnMessageLoop() { | 1298 virtual void DoTestOnMessageLoop() { |
| 1296 // Show the other bookmarks. | 1299 // Show the other bookmarks. |
| 1297 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1300 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1298 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1301 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1299 ui_controls::DOWN | ui_controls::UP, | 1302 ui_controls::DOWN | ui_controls::UP, |
| 1300 CreateEventTask(this, &BookmarkBarViewTest15::Step2)); | 1303 CreateEventTask(this, &BookmarkBarViewTest15::Step2)); |
| 1301 } | 1304 } |
| 1302 | 1305 |
| 1303 private: | 1306 private: |
| 1304 void Step2() { | 1307 void Step2() { |
| 1305 // Menu should be showing. | 1308 // Menu should be showing. |
| 1306 views::MenuItemView* menu = bb_view_->GetMenu(); | 1309 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1307 ASSERT_TRUE(menu != NULL); | 1310 ASSERT_TRUE(menu != NULL); |
| 1308 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1311 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1309 | 1312 |
| 1310 views::MenuItemView* child_menu = | 1313 views::MenuItemView* child_menu = |
| 1311 menu->GetSubmenu()->GetMenuItemAt(1); | 1314 menu->GetSubmenu()->GetMenuItemAt(1); |
| 1312 ASSERT_TRUE(child_menu != NULL); | 1315 ASSERT_TRUE(child_menu != NULL); |
| 1313 | 1316 |
| 1314 deleted_menu_id_ = child_menu->GetCommand(); | 1317 deleted_menu_id_ = child_menu->GetCommand(); |
| 1315 | 1318 |
| 1316 // Right click on the second child to get its context menu. | 1319 // Right click on the second child to get its context menu. |
| 1317 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1320 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1318 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1321 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1319 // Step3 will be invoked by ContextMenuNotificationObserver. | 1322 // Step3 will be invoked by ContextMenuNotificationObserver. |
| 1320 } | 1323 } |
| 1321 | 1324 |
| 1322 void Step3() { | 1325 void Step3() { |
| 1323 // Make sure the context menu is showing. | 1326 // Make sure the context menu is showing. |
| 1324 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1327 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1325 ASSERT_TRUE(menu != NULL); | 1328 ASSERT_TRUE(menu != NULL); |
| 1326 ASSERT_TRUE(menu->GetSubmenu()); | 1329 ASSERT_TRUE(menu->GetSubmenu()); |
| 1327 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1330 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1328 | 1331 |
| 1329 views::MenuItemView* delete_menu = | 1332 views::MenuItemView* delete_menu = |
| 1330 menu->GetMenuItemByID(IDC_BOOKMARK_BAR_REMOVE); | 1333 menu->GetMenuItemByID(IDC_BOOKMARK_BAR_REMOVE); |
| 1331 ASSERT_TRUE(delete_menu); | 1334 ASSERT_TRUE(delete_menu); |
| 1332 | 1335 |
| 1333 // Click on the delete button. | 1336 // Click on the delete button. |
| 1334 ui_controls::MoveMouseToCenterAndPress(delete_menu, | 1337 ui_test_utils::MoveMouseToCenterAndPress(delete_menu, |
| 1335 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 1338 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 1336 CreateEventTask(this, &BookmarkBarViewTest15::Step4)); | 1339 CreateEventTask(this, &BookmarkBarViewTest15::Step4)); |
| 1337 } | 1340 } |
| 1338 | 1341 |
| 1339 void Step4() { | 1342 void Step4() { |
| 1340 // The context menu should not be showing. | 1343 // The context menu should not be showing. |
| 1341 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); | 1344 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); |
| 1342 ASSERT_TRUE(context_menu == NULL); | 1345 ASSERT_TRUE(context_menu == NULL); |
| 1343 | 1346 |
| 1344 // But the menu should be showing. | 1347 // But the menu should be showing. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1362 | 1365 |
| 1363 // Tests that we don't crash or get stuck if the parent of a menu is closed. | 1366 // Tests that we don't crash or get stuck if the parent of a menu is closed. |
| 1364 class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase { | 1367 class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase { |
| 1365 protected: | 1368 protected: |
| 1366 virtual void DoTestOnMessageLoop() { | 1369 virtual void DoTestOnMessageLoop() { |
| 1367 InstallViewsDelegate(); | 1370 InstallViewsDelegate(); |
| 1368 | 1371 |
| 1369 // Move the mouse to the first folder on the bookmark bar and press the | 1372 // Move the mouse to the first folder on the bookmark bar and press the |
| 1370 // mouse. | 1373 // mouse. |
| 1371 views::TextButton* button = GetBookmarkButton(0); | 1374 views::TextButton* button = GetBookmarkButton(0); |
| 1372 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1375 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1373 ui_controls::DOWN | ui_controls::UP, | 1376 ui_controls::DOWN | ui_controls::UP, |
| 1374 CreateEventTask(this, &BookmarkBarViewTest16::Step2)); | 1377 CreateEventTask(this, &BookmarkBarViewTest16::Step2)); |
| 1375 } | 1378 } |
| 1376 | 1379 |
| 1377 private: | 1380 private: |
| 1378 void Step2() { | 1381 void Step2() { |
| 1379 // Menu should be showing. | 1382 // Menu should be showing. |
| 1380 views::MenuItemView* menu = bb_view_->GetMenu(); | 1383 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1381 ASSERT_TRUE(menu != NULL); | 1384 ASSERT_TRUE(menu != NULL); |
| 1382 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1385 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1401 BookmarkBarViewTest17() | 1404 BookmarkBarViewTest17() |
| 1402 : ALLOW_THIS_IN_INITIALIZER_LIST( | 1405 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 1403 observer_(CreateEventTask(this, &BookmarkBarViewTest17::Step3))) { | 1406 observer_(CreateEventTask(this, &BookmarkBarViewTest17::Step3))) { |
| 1404 } | 1407 } |
| 1405 | 1408 |
| 1406 protected: | 1409 protected: |
| 1407 virtual void DoTestOnMessageLoop() { | 1410 virtual void DoTestOnMessageLoop() { |
| 1408 // Move the mouse to the other folder on the bookmark bar and press the | 1411 // Move the mouse to the other folder on the bookmark bar and press the |
| 1409 // left mouse button. | 1412 // left mouse button. |
| 1410 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1413 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1411 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1414 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1412 ui_controls::DOWN | ui_controls::UP, | 1415 ui_controls::DOWN | ui_controls::UP, |
| 1413 CreateEventTask(this, &BookmarkBarViewTest17::Step2)); | 1416 CreateEventTask(this, &BookmarkBarViewTest17::Step2)); |
| 1414 } | 1417 } |
| 1415 | 1418 |
| 1416 private: | 1419 private: |
| 1417 void Step2() { | 1420 void Step2() { |
| 1418 // Menu should be showing. | 1421 // Menu should be showing. |
| 1419 views::MenuItemView* menu = bb_view_->GetMenu(); | 1422 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1420 ASSERT_TRUE(menu != NULL); | 1423 ASSERT_TRUE(menu != NULL); |
| 1421 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1424 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1422 | 1425 |
| 1423 // Right click on the second item to show its context menu. | 1426 // Right click on the second item to show its context menu. |
| 1424 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(2); | 1427 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(2); |
| 1425 ASSERT_TRUE(child_menu != NULL); | 1428 ASSERT_TRUE(child_menu != NULL); |
| 1426 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1429 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1427 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1430 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1428 // Step3 will be invoked by ContextMenuNotificationObserver. | 1431 // Step3 will be invoked by ContextMenuNotificationObserver. |
| 1429 } | 1432 } |
| 1430 | 1433 |
| 1431 void Step3() { | 1434 void Step3() { |
| 1432 // Make sure the context menu is showing. | 1435 // Make sure the context menu is showing. |
| 1433 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); | 1436 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); |
| 1434 ASSERT_TRUE(context_menu != NULL); | 1437 ASSERT_TRUE(context_menu != NULL); |
| 1435 ASSERT_TRUE(context_menu->GetSubmenu()); | 1438 ASSERT_TRUE(context_menu->GetSubmenu()); |
| 1436 ASSERT_TRUE(context_menu->GetSubmenu()->IsShowing()); | 1439 ASSERT_TRUE(context_menu->GetSubmenu()->IsShowing()); |
| 1437 | 1440 |
| 1438 // Right click on the first menu item to trigger its context menu. | 1441 // Right click on the first menu item to trigger its context menu. |
| 1439 views::MenuItemView* menu = bb_view_->GetMenu(); | 1442 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1440 ASSERT_TRUE(menu != NULL); | 1443 ASSERT_TRUE(menu != NULL); |
| 1441 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1444 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1442 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); | 1445 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); |
| 1443 ASSERT_TRUE(child_menu != NULL); | 1446 ASSERT_TRUE(child_menu != NULL); |
| 1444 | 1447 |
| 1445 observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4)); | 1448 observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4)); |
| 1446 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1449 ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1447 ui_controls::DOWN | ui_controls::UP, base::Closure()); | 1450 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
| 1448 // Step4 will be invoked by ContextMenuNotificationObserver. | 1451 // Step4 will be invoked by ContextMenuNotificationObserver. |
| 1449 } | 1452 } |
| 1450 | 1453 |
| 1451 void Step4() { | 1454 void Step4() { |
| 1452 // The context menu should still be showing. | 1455 // The context menu should still be showing. |
| 1453 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); | 1456 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); |
| 1454 ASSERT_TRUE(context_menu != NULL); | 1457 ASSERT_TRUE(context_menu != NULL); |
| 1455 | 1458 |
| 1456 // And the menu should be showing. | 1459 // And the menu should be showing. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1477 | 1480 |
| 1478 // Verifies sibling menus works. Clicks on the 'other bookmarks' folder, then | 1481 // Verifies sibling menus works. Clicks on the 'other bookmarks' folder, then |
| 1479 // moves the mouse over the first item on the bookmark bar and makes sure the | 1482 // moves the mouse over the first item on the bookmark bar and makes sure the |
| 1480 // menu appears. | 1483 // menu appears. |
| 1481 class BookmarkBarViewTest18 : public BookmarkBarViewEventTestBase { | 1484 class BookmarkBarViewTest18 : public BookmarkBarViewEventTestBase { |
| 1482 protected: | 1485 protected: |
| 1483 virtual void DoTestOnMessageLoop() { | 1486 virtual void DoTestOnMessageLoop() { |
| 1484 // Move the mouse to the other folder on the bookmark bar and press the | 1487 // Move the mouse to the other folder on the bookmark bar and press the |
| 1485 // left mouse button. | 1488 // left mouse button. |
| 1486 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1489 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1487 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1490 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1488 ui_controls::DOWN | ui_controls::UP, | 1491 ui_controls::DOWN | ui_controls::UP, |
| 1489 CreateEventTask(this, &BookmarkBarViewTest18::Step2)); | 1492 CreateEventTask(this, &BookmarkBarViewTest18::Step2)); |
| 1490 } | 1493 } |
| 1491 | 1494 |
| 1492 private: | 1495 private: |
| 1493 void Step2() { | 1496 void Step2() { |
| 1494 // Menu should be showing. | 1497 // Menu should be showing. |
| 1495 views::MenuItemView* menu = bb_view_->GetMenu(); | 1498 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1496 ASSERT_TRUE(menu != NULL); | 1499 ASSERT_TRUE(menu != NULL); |
| 1497 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1500 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1520 VIEW_TEST(BookmarkBarViewTest18, SiblingMenu) | 1523 VIEW_TEST(BookmarkBarViewTest18, SiblingMenu) |
| 1521 | 1524 |
| 1522 // Verifies mousing over an already open sibling menu doesn't prematurely cancel | 1525 // Verifies mousing over an already open sibling menu doesn't prematurely cancel |
| 1523 // the menu. | 1526 // the menu. |
| 1524 class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { | 1527 class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { |
| 1525 protected: | 1528 protected: |
| 1526 virtual void DoTestOnMessageLoop() { | 1529 virtual void DoTestOnMessageLoop() { |
| 1527 // Move the mouse to the other folder on the bookmark bar and press the | 1530 // Move the mouse to the other folder on the bookmark bar and press the |
| 1528 // left mouse button. | 1531 // left mouse button. |
| 1529 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1532 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1530 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, | 1533 ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 1531 ui_controls::DOWN | ui_controls::UP, | 1534 ui_controls::DOWN | ui_controls::UP, |
| 1532 CreateEventTask(this, &BookmarkBarViewTest19::Step2)); | 1535 CreateEventTask(this, &BookmarkBarViewTest19::Step2)); |
| 1533 } | 1536 } |
| 1534 | 1537 |
| 1535 private: | 1538 private: |
| 1536 void Step2() { | 1539 void Step2() { |
| 1537 // Menu should be showing. | 1540 // Menu should be showing. |
| 1538 views::MenuItemView* menu = bb_view_->GetMenu(); | 1541 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1539 ASSERT_TRUE(menu != NULL); | 1542 ASSERT_TRUE(menu != NULL); |
| 1540 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1543 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1541 | 1544 |
| 1542 // Click on the first folder. | 1545 // Click on the first folder. |
| 1543 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); | 1546 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); |
| 1544 ASSERT_TRUE(child_menu != NULL); | 1547 ASSERT_TRUE(child_menu != NULL); |
| 1545 ui_controls::MoveMouseToCenterAndPress( | 1548 ui_test_utils::MoveMouseToCenterAndPress( |
| 1546 child_menu, ui_controls::LEFT, | 1549 child_menu, ui_controls::LEFT, |
| 1547 ui_controls::DOWN | ui_controls::UP, | 1550 ui_controls::DOWN | ui_controls::UP, |
| 1548 CreateEventTask(this, &BookmarkBarViewTest19::Step3)); | 1551 CreateEventTask(this, &BookmarkBarViewTest19::Step3)); |
| 1549 } | 1552 } |
| 1550 | 1553 |
| 1551 void Step3() { | 1554 void Step3() { |
| 1552 // Make sure the menu is showing. | 1555 // Make sure the menu is showing. |
| 1553 views::MenuItemView* menu = bb_view_->GetMenu(); | 1556 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1554 ASSERT_TRUE(menu != NULL); | 1557 ASSERT_TRUE(menu != NULL); |
| 1555 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1558 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1556 | 1559 |
| 1557 // Move the mouse back to the other bookmark button. | 1560 // Move the mouse back to the other bookmark button. |
| 1558 views::TextButton* button = bb_view_->other_bookmarked_button(); | 1561 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 1559 gfx::Point button_center(button->width() / 2, button->height() / 2); | 1562 gfx::Point button_center(button->width() / 2, button->height() / 2); |
| 1560 views::View::ConvertPointToScreen(button, &button_center); | 1563 views::View::ConvertPointToScreen(button, &button_center); |
| 1561 ui_controls::SendMouseMoveNotifyWhenDone( | 1564 ui_controls::SendMouseMoveNotifyWhenDone( |
| 1562 button_center.x() + 1, button_center.y() + 1, | 1565 button_center.x() + 1, button_center.y() + 1, |
| 1563 CreateEventTask(this, &BookmarkBarViewTest19::Step4)); | 1566 CreateEventTask(this, &BookmarkBarViewTest19::Step4)); |
| 1564 } | 1567 } |
| 1565 | 1568 |
| 1566 void Step4() { | 1569 void Step4() { |
| 1567 // Menu should be showing. | 1570 // Menu should be showing. |
| 1568 views::MenuItemView* menu = bb_view_->GetMenu(); | 1571 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1569 ASSERT_TRUE(menu != NULL); | 1572 ASSERT_TRUE(menu != NULL); |
| 1570 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1573 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1571 | 1574 |
| 1572 // Click on the first folder. | 1575 // Click on the first folder. |
| 1573 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); | 1576 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); |
| 1574 ASSERT_TRUE(child_menu != NULL); | 1577 ASSERT_TRUE(child_menu != NULL); |
| 1575 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 1578 ui_test_utils::MoveMouseToCenterAndPress( |
| 1579 child_menu, |
| 1580 ui_controls::LEFT, |
| 1576 ui_controls::DOWN | ui_controls::UP, | 1581 ui_controls::DOWN | ui_controls::UP, |
| 1577 CreateEventTask(this, &BookmarkBarViewTest19::Step5)); | 1582 CreateEventTask(this, &BookmarkBarViewTest19::Step5)); |
| 1578 } | 1583 } |
| 1579 | 1584 |
| 1580 void Step5() { | 1585 void Step5() { |
| 1581 // Make sure the menu is showing. | 1586 // Make sure the menu is showing. |
| 1582 views::MenuItemView* menu = bb_view_->GetMenu(); | 1587 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 1583 ASSERT_TRUE(menu != NULL); | 1588 ASSERT_TRUE(menu != NULL); |
| 1584 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1589 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1585 | 1590 |
| 1586 menu->GetMenuController()->CancelAll(); | 1591 menu->GetMenuController()->CancelAll(); |
| 1587 | 1592 |
| 1588 Done(); | 1593 Done(); |
| 1589 } | 1594 } |
| 1590 }; | 1595 }; |
| 1591 | 1596 |
| 1592 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) | 1597 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) |
| OLD | NEW |