OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 6 #include "base/callback.h" |
5 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
6 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
7 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/automation/ui_controls.h" | 11 #include "chrome/browser/automation/ui_controls.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
11 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 } | 468 } |
467 }; | 469 }; |
468 | 470 |
469 VIEW_TEST(BookmarkBarViewTest3, Submenus) | 471 VIEW_TEST(BookmarkBarViewTest3, Submenus) |
470 | 472 |
471 // Observer that posts task upon the context menu creation. | 473 // Observer that posts task upon the context menu creation. |
472 // This is necessary for Linux as the context menu has to check | 474 // This is necessary for Linux as the context menu has to check |
473 // the clipboard, which invokes the event loop. | 475 // the clipboard, which invokes the event loop. |
474 class ContextMenuNotificationObserver : public NotificationObserver { | 476 class ContextMenuNotificationObserver : public NotificationObserver { |
475 public: | 477 public: |
476 explicit ContextMenuNotificationObserver(Task* task) : task_(task) { | 478 explicit ContextMenuNotificationObserver(const base::Closure& task) |
| 479 : task_(task) { |
477 registrar_.Add(this, | 480 registrar_.Add(this, |
478 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, | 481 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, |
479 NotificationService::AllSources()); | 482 NotificationService::AllSources()); |
480 } | 483 } |
481 | 484 |
482 virtual void Observe(int type, | 485 virtual void Observe(int type, |
483 const NotificationSource& source, | 486 const NotificationSource& source, |
484 const NotificationDetails& details) { | 487 const NotificationDetails& details) { |
485 MessageLoop::current()->PostTask(FROM_HERE, task_); | 488 MessageLoop::current()->PostTask(FROM_HERE, task_); |
486 } | 489 } |
487 | 490 |
488 // Sets the task that is posted when the context menu is shown. | 491 // Sets the task that is posted when the context menu is shown. |
489 void set_task(Task* task) { task_ = task; } | 492 void set_task(const base::Closure& task) { task_ = task; } |
490 | 493 |
491 private: | 494 private: |
492 NotificationRegistrar registrar_; | 495 NotificationRegistrar registrar_; |
493 Task* task_; | 496 base::Closure task_; |
494 | 497 |
495 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver); | 498 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver); |
496 }; | 499 }; |
497 | 500 |
498 // Tests context menus by way of opening a context menu for a bookmark, | 501 // Tests context menus by way of opening a context menu for a bookmark, |
499 // then right clicking to get context menu and selecting the first menu item | 502 // then right clicking to get context menu and selecting the first menu item |
500 // (open). | 503 // (open). |
501 class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { | 504 class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { |
502 public: | 505 public: |
503 BookmarkBarViewTest4() | 506 BookmarkBarViewTest4() |
(...skipping 17 matching lines...) Expand all Loading... |
521 views::MenuItemView* menu = bb_view_->GetMenu(); | 524 views::MenuItemView* menu = bb_view_->GetMenu(); |
522 ASSERT_TRUE(menu != NULL); | 525 ASSERT_TRUE(menu != NULL); |
523 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 526 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
524 | 527 |
525 views::MenuItemView* child_menu = | 528 views::MenuItemView* child_menu = |
526 menu->GetSubmenu()->GetMenuItemAt(0); | 529 menu->GetSubmenu()->GetMenuItemAt(0); |
527 ASSERT_TRUE(child_menu != NULL); | 530 ASSERT_TRUE(child_menu != NULL); |
528 | 531 |
529 // Right click on the first child to get its context menu. | 532 // Right click on the first child to get its context menu. |
530 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 533 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
531 ui_controls::DOWN | ui_controls::UP, NULL); | 534 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
532 // Step3 will be invoked by ContextMenuNotificationObserver. | 535 // Step3 will be invoked by ContextMenuNotificationObserver. |
533 } | 536 } |
534 | 537 |
535 void Step3() { | 538 void Step3() { |
536 // Make sure the context menu is showing. | 539 // Make sure the context menu is showing. |
537 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 540 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
538 ASSERT_TRUE(menu != NULL); | 541 ASSERT_TRUE(menu != NULL); |
539 ASSERT_TRUE(menu->GetSubmenu()); | 542 ASSERT_TRUE(menu->GetSubmenu()); |
540 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 543 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
541 | 544 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 700 |
698 void Step3() { | 701 void Step3() { |
699 // Drag over other button. | 702 // Drag over other button. |
700 views::TextButton* other_button = | 703 views::TextButton* other_button = |
701 bb_view_->other_bookmarked_button(); | 704 bb_view_->other_bookmarked_button(); |
702 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); | 705 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); |
703 views::View::ConvertPointToScreen(other_button, &loc); | 706 views::View::ConvertPointToScreen(other_button, &loc); |
704 | 707 |
705 // Start a drag. | 708 // Start a drag. |
706 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), | 709 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), |
707 NewRunnableMethod(this, &BookmarkBarViewTest7::Step4)); | 710 base::Bind(&BookmarkBarViewTest7::Step4, this)); |
708 | 711 |
709 // See comment above this method as to why we do this. | 712 // See comment above this method as to why we do this. |
710 ScheduleMouseMoveInBackground(loc.x(), loc.y()); | 713 ScheduleMouseMoveInBackground(loc.x(), loc.y()); |
711 } | 714 } |
712 | 715 |
713 void Step4() { | 716 void Step4() { |
714 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 717 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
715 ASSERT_TRUE(drop_menu != NULL); | 718 ASSERT_TRUE(drop_menu != NULL); |
716 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 719 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
717 | 720 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 | 773 |
771 void Step3() { | 774 void Step3() { |
772 // Drag over other button. | 775 // Drag over other button. |
773 views::TextButton* other_button = | 776 views::TextButton* other_button = |
774 bb_view_->other_bookmarked_button(); | 777 bb_view_->other_bookmarked_button(); |
775 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); | 778 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); |
776 views::View::ConvertPointToScreen(other_button, &loc); | 779 views::View::ConvertPointToScreen(other_button, &loc); |
777 | 780 |
778 // Start a drag. | 781 // Start a drag. |
779 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), | 782 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), |
780 NewRunnableMethod(this, &BookmarkBarViewTest8::Step4)); | 783 base::Bind(&BookmarkBarViewTest8::Step4, this)); |
781 | 784 |
782 // See comment above this method as to why we do this. | 785 // See comment above this method as to why we do this. |
783 ScheduleMouseMoveInBackground(loc.x(), loc.y()); | 786 ScheduleMouseMoveInBackground(loc.x(), loc.y()); |
784 } | 787 } |
785 | 788 |
786 void Step4() { | 789 void Step4() { |
787 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 790 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
788 ASSERT_TRUE(drop_menu != NULL); | 791 ASSERT_TRUE(drop_menu != NULL); |
789 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 792 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
790 | 793 |
791 // Now drag back over first menu. | 794 // Now drag back over first menu. |
792 views::TextButton* button = GetBookmarkButton(0); | 795 views::TextButton* button = GetBookmarkButton(0); |
793 gfx::Point loc(button->width() / 2, button->height() / 2); | 796 gfx::Point loc(button->width() / 2, button->height() / 2); |
794 views::View::ConvertPointToScreen(button, &loc); | 797 views::View::ConvertPointToScreen(button, &loc); |
795 ui_controls::SendMouseMoveNotifyWhenDone(loc.x(), loc.y(), | 798 ui_controls::SendMouseMoveNotifyWhenDone(loc.x(), loc.y(), |
796 NewRunnableMethod(this, &BookmarkBarViewTest8::Step5)); | 799 base::Bind(&BookmarkBarViewTest8::Step5, this)); |
797 } | 800 } |
798 | 801 |
799 void Step5() { | 802 void Step5() { |
800 // Drop on folder F11. | 803 // Drop on folder F11. |
801 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 804 views::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
802 ASSERT_TRUE(drop_menu != NULL); | 805 ASSERT_TRUE(drop_menu != NULL); |
803 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 806 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
804 | 807 |
805 views::MenuItemView* target_menu = | 808 views::MenuItemView* target_menu = |
806 drop_menu->GetSubmenu()->GetMenuItemAt(1); | 809 drop_menu->GetSubmenu()->GetMenuItemAt(1); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 views::View::ConvertPointToScreen(scroll_down_button, &loc); | 863 views::View::ConvertPointToScreen(scroll_down_button, &loc); |
861 | 864 |
862 // On linux, the sending one location isn't enough. | 865 // On linux, the sending one location isn't enough. |
863 ui_controls::SendMouseMove(loc.x() - 1 , loc.y() - 1); | 866 ui_controls::SendMouseMove(loc.x() - 1 , loc.y() - 1); |
864 ui_controls::SendMouseMoveNotifyWhenDone( | 867 ui_controls::SendMouseMoveNotifyWhenDone( |
865 loc.x(), loc.y(), CreateEventTask(this, &BookmarkBarViewTest9::Step3)); | 868 loc.x(), loc.y(), CreateEventTask(this, &BookmarkBarViewTest9::Step3)); |
866 } | 869 } |
867 | 870 |
868 void Step3() { | 871 void Step3() { |
869 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 872 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
870 NewRunnableMethod(this, &BookmarkBarViewTest9::Step4), 200); | 873 base::Bind(&BookmarkBarViewTest9::Step4, this), 200); |
871 } | 874 } |
872 | 875 |
873 void Step4() { | 876 void Step4() { |
874 gfx::Point menu_loc; | 877 gfx::Point menu_loc; |
875 views::View::ConvertPointToScreen(first_menu_, &menu_loc); | 878 views::View::ConvertPointToScreen(first_menu_, &menu_loc); |
876 ASSERT_NE(start_y_, menu_loc.y()); | 879 ASSERT_NE(start_y_, menu_loc.y()); |
877 | 880 |
878 // Hide menu. | 881 // Hide menu. |
879 bb_view_->GetMenu()->GetMenuController()->CancelAll(); | 882 bb_view_->GetMenu()->GetMenuController()->CancelAll(); |
880 | 883 |
881 // On linux, Cancelling menu will call Quit on the message loop, | 884 // On linux, Cancelling menu will call Quit on the message loop, |
882 // which can interfere with Done. We need to run Done in the | 885 // which can interfere with Done. We need to run Done in the |
883 // next execution loop. | 886 // next execution loop. |
884 MessageLoop::current()->PostTask( | 887 MessageLoop::current()->PostTask( |
885 FROM_HERE, | 888 FROM_HERE, |
886 NewRunnableMethod(this, &ViewEventTestBase::Done)); | 889 base::Bind(&ViewEventTestBase::Done, this)); |
887 } | 890 } |
888 | 891 |
889 int start_y_; | 892 int start_y_; |
890 views::MenuItemView* first_menu_; | 893 views::MenuItemView* first_menu_; |
891 }; | 894 }; |
892 | 895 |
893 VIEW_TEST(BookmarkBarViewTest9, MAYBE_ScrollButtonScrolls) | 896 VIEW_TEST(BookmarkBarViewTest9, MAYBE_ScrollButtonScrolls) |
894 | 897 |
895 // Tests up/down/left/enter key messages. | 898 // Tests up/down/left/enter key messages. |
896 class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { | 899 class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 views::MenuItemView* menu = bb_view_->GetMenu(); | 1028 views::MenuItemView* menu = bb_view_->GetMenu(); |
1026 ASSERT_TRUE(menu != NULL); | 1029 ASSERT_TRUE(menu != NULL); |
1027 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1030 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1028 | 1031 |
1029 views::MenuItemView* child_menu = | 1032 views::MenuItemView* child_menu = |
1030 menu->GetSubmenu()->GetMenuItemAt(0); | 1033 menu->GetSubmenu()->GetMenuItemAt(0); |
1031 ASSERT_TRUE(child_menu != NULL); | 1034 ASSERT_TRUE(child_menu != NULL); |
1032 | 1035 |
1033 // Right click on the first child to get its context menu. | 1036 // Right click on the first child to get its context menu. |
1034 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1037 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
1035 ui_controls::DOWN | ui_controls::UP, NULL); | 1038 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1036 // Step3 will be invoked by ContextMenuNotificationObserver. | 1039 // Step3 will be invoked by ContextMenuNotificationObserver. |
1037 } | 1040 } |
1038 | 1041 |
1039 void Step3() { | 1042 void Step3() { |
1040 // Send escape so that the context menu hides. | 1043 // Send escape so that the context menu hides. |
1041 ui_controls::SendKeyPressNotifyWhenDone( | 1044 ui_controls::SendKeyPressNotifyWhenDone( |
1042 NULL, ui::VKEY_ESCAPE, false, false, false, false, | 1045 NULL, ui::VKEY_ESCAPE, false, false, false, false, |
1043 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); | 1046 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); |
1044 } | 1047 } |
1045 | 1048 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 void Step3() { | 1114 void Step3() { |
1112 // Make sure the context menu is showing. | 1115 // Make sure the context menu is showing. |
1113 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1116 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
1114 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); | 1117 ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); |
1115 | 1118 |
1116 // Select the first item in the context menu (open all). | 1119 // Select the first item in the context menu (open all). |
1117 views::MenuItemView* child_menu = | 1120 views::MenuItemView* child_menu = |
1118 menu->GetSubmenu()->GetMenuItemAt(0); | 1121 menu->GetSubmenu()->GetMenuItemAt(0); |
1119 ASSERT_TRUE(child_menu != NULL); | 1122 ASSERT_TRUE(child_menu != NULL); |
1120 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 1123 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
1121 ui_controls::DOWN | ui_controls::UP, NULL); | 1124 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1122 | 1125 |
1123 // Delay until we send tab, otherwise the message box doesn't appear | 1126 // Delay until we send tab, otherwise the message box doesn't appear |
1124 // correctly. | 1127 // correctly. |
1125 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1128 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1126 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); | 1129 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); |
1127 } | 1130 } |
1128 | 1131 |
1129 void Step4() { | 1132 void Step4() { |
1130 // Press tab to give focus to the cancel button. | 1133 // Press tab to give focus to the cancel button. |
1131 ui_controls::SendKeyPress(NULL, ui::VKEY_TAB, false, false, false, false); | 1134 ui_controls::SendKeyPress(NULL, ui::VKEY_TAB, false, false, false, false); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 views::MenuItemView* menu = bb_view_->GetMenu(); | 1183 views::MenuItemView* menu = bb_view_->GetMenu(); |
1181 ASSERT_TRUE(menu != NULL); | 1184 ASSERT_TRUE(menu != NULL); |
1182 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1185 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1183 | 1186 |
1184 views::MenuItemView* child_menu = | 1187 views::MenuItemView* child_menu = |
1185 menu->GetSubmenu()->GetMenuItemAt(0); | 1188 menu->GetSubmenu()->GetMenuItemAt(0); |
1186 ASSERT_TRUE(child_menu != NULL); | 1189 ASSERT_TRUE(child_menu != NULL); |
1187 | 1190 |
1188 // Right click on the first child to get its context menu. | 1191 // Right click on the first child to get its context menu. |
1189 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1192 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
1190 ui_controls::DOWN | ui_controls::UP, NULL); | 1193 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1191 // Step3 will be invoked by ContextMenuNotificationObserver. | 1194 // Step3 will be invoked by ContextMenuNotificationObserver. |
1192 } | 1195 } |
1193 | 1196 |
1194 void Step3() { | 1197 void Step3() { |
1195 // Make sure the context menu is showing. | 1198 // Make sure the context menu is showing. |
1196 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1199 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
1197 ASSERT_TRUE(menu != NULL); | 1200 ASSERT_TRUE(menu != NULL); |
1198 ASSERT_TRUE(menu->GetSubmenu()); | 1201 ASSERT_TRUE(menu->GetSubmenu()); |
1199 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1202 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1200 | 1203 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 : ALLOW_THIS_IN_INITIALIZER_LIST( | 1249 : ALLOW_THIS_IN_INITIALIZER_LIST( |
1247 observer_(CreateEventTask(this, &BookmarkBarViewTest14::Step2))) { | 1250 observer_(CreateEventTask(this, &BookmarkBarViewTest14::Step2))) { |
1248 } | 1251 } |
1249 | 1252 |
1250 protected: | 1253 protected: |
1251 virtual void DoTestOnMessageLoop() { | 1254 virtual void DoTestOnMessageLoop() { |
1252 // Move the mouse to the first folder on the bookmark bar and press the | 1255 // Move the mouse to the first folder on the bookmark bar and press the |
1253 // right mouse button. | 1256 // right mouse button. |
1254 views::TextButton* button = GetBookmarkButton(0); | 1257 views::TextButton* button = GetBookmarkButton(0); |
1255 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, | 1258 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, |
1256 ui_controls::DOWN | ui_controls::UP, NULL); | 1259 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1257 // Step2 will be invoked by ContextMenuNotificationObserver. | 1260 // Step2 will be invoked by ContextMenuNotificationObserver. |
1258 } | 1261 } |
1259 | 1262 |
1260 private: | 1263 private: |
1261 | 1264 |
1262 void Step2() { | 1265 void Step2() { |
1263 // Menu should NOT be showing. | 1266 // Menu should NOT be showing. |
1264 views::MenuItemView* menu = bb_view_->GetMenu(); | 1267 views::MenuItemView* menu = bb_view_->GetMenu(); |
1265 ASSERT_TRUE(menu == NULL); | 1268 ASSERT_TRUE(menu == NULL); |
1266 | 1269 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1308 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1306 | 1309 |
1307 views::MenuItemView* child_menu = | 1310 views::MenuItemView* child_menu = |
1308 menu->GetSubmenu()->GetMenuItemAt(1); | 1311 menu->GetSubmenu()->GetMenuItemAt(1); |
1309 ASSERT_TRUE(child_menu != NULL); | 1312 ASSERT_TRUE(child_menu != NULL); |
1310 | 1313 |
1311 deleted_menu_id_ = child_menu->GetCommand(); | 1314 deleted_menu_id_ = child_menu->GetCommand(); |
1312 | 1315 |
1313 // Right click on the second child to get its context menu. | 1316 // Right click on the second child to get its context menu. |
1314 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1317 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
1315 ui_controls::DOWN | ui_controls::UP, NULL); | 1318 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1316 // Step3 will be invoked by ContextMenuNotificationObserver. | 1319 // Step3 will be invoked by ContextMenuNotificationObserver. |
1317 } | 1320 } |
1318 | 1321 |
1319 void Step3() { | 1322 void Step3() { |
1320 // Make sure the context menu is showing. | 1323 // Make sure the context menu is showing. |
1321 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1324 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
1322 ASSERT_TRUE(menu != NULL); | 1325 ASSERT_TRUE(menu != NULL); |
1323 ASSERT_TRUE(menu->GetSubmenu()); | 1326 ASSERT_TRUE(menu->GetSubmenu()); |
1324 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1327 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1325 | 1328 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 void Step2() { | 1417 void Step2() { |
1415 // Menu should be showing. | 1418 // Menu should be showing. |
1416 views::MenuItemView* menu = bb_view_->GetMenu(); | 1419 views::MenuItemView* menu = bb_view_->GetMenu(); |
1417 ASSERT_TRUE(menu != NULL); | 1420 ASSERT_TRUE(menu != NULL); |
1418 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1421 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1419 | 1422 |
1420 // Right click on the second item to show its context menu. | 1423 // Right click on the second item to show its context menu. |
1421 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(2); | 1424 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(2); |
1422 ASSERT_TRUE(child_menu != NULL); | 1425 ASSERT_TRUE(child_menu != NULL); |
1423 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1426 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
1424 ui_controls::DOWN | ui_controls::UP, NULL); | 1427 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1425 // Step3 will be invoked by ContextMenuNotificationObserver. | 1428 // Step3 will be invoked by ContextMenuNotificationObserver. |
1426 } | 1429 } |
1427 | 1430 |
1428 void Step3() { | 1431 void Step3() { |
1429 // Make sure the context menu is showing. | 1432 // Make sure the context menu is showing. |
1430 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); | 1433 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); |
1431 ASSERT_TRUE(context_menu != NULL); | 1434 ASSERT_TRUE(context_menu != NULL); |
1432 ASSERT_TRUE(context_menu->GetSubmenu()); | 1435 ASSERT_TRUE(context_menu->GetSubmenu()); |
1433 ASSERT_TRUE(context_menu->GetSubmenu()->IsShowing()); | 1436 ASSERT_TRUE(context_menu->GetSubmenu()->IsShowing()); |
1434 | 1437 |
1435 // Right click on the first menu item to trigger its context menu. | 1438 // Right click on the first menu item to trigger its context menu. |
1436 views::MenuItemView* menu = bb_view_->GetMenu(); | 1439 views::MenuItemView* menu = bb_view_->GetMenu(); |
1437 ASSERT_TRUE(menu != NULL); | 1440 ASSERT_TRUE(menu != NULL); |
1438 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1441 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1439 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); | 1442 views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); |
1440 ASSERT_TRUE(child_menu != NULL); | 1443 ASSERT_TRUE(child_menu != NULL); |
1441 | 1444 |
1442 observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4)); | 1445 observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4)); |
1443 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1446 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
1444 ui_controls::DOWN | ui_controls::UP, NULL); | 1447 ui_controls::DOWN | ui_controls::UP, base::Closure()); |
1445 // Step4 will be invoked by ContextMenuNotificationObserver. | 1448 // Step4 will be invoked by ContextMenuNotificationObserver. |
1446 } | 1449 } |
1447 | 1450 |
1448 void Step4() { | 1451 void Step4() { |
1449 // The context menu should still be showing. | 1452 // The context menu should still be showing. |
1450 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); | 1453 views::MenuItemView* context_menu = bb_view_->GetContextMenu(); |
1451 ASSERT_TRUE(context_menu != NULL); | 1454 ASSERT_TRUE(context_menu != NULL); |
1452 | 1455 |
1453 // And the menu should be showing. | 1456 // And the menu should be showing. |
1454 views::MenuItemView* menu = bb_view_->GetMenu(); | 1457 views::MenuItemView* menu = bb_view_->GetMenu(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 ASSERT_TRUE(menu != NULL); | 1576 ASSERT_TRUE(menu != NULL); |
1574 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1577 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1575 | 1578 |
1576 menu->GetMenuController()->CancelAll(); | 1579 menu->GetMenuController()->CancelAll(); |
1577 | 1580 |
1578 Done(); | 1581 Done(); |
1579 } | 1582 } |
1580 }; | 1583 }; |
1581 | 1584 |
1582 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) | 1585 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) |
OLD | NEW |