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