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 "app/keyboard_codes.h" | |
6 #include "base/string_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
7 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/automation/ui_controls.h" | 8 #include "chrome/browser/automation/ui_controls.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
11 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/tab_contents/page_navigator.h" | 13 #include "chrome/browser/tab_contents/page_navigator.h" |
15 #include "chrome/browser/ui/views/bookmark_bar_view.h" | 14 #include "chrome/browser/ui/views/bookmark_bar_view.h" |
16 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/testing_profile.h" | 17 #include "chrome/test/testing_profile.h" |
19 #include "chrome/test/interactive_ui/view_event_test_base.h" | 18 #include "chrome/test/interactive_ui/view_event_test_base.h" |
20 #include "chrome/test/ui_test_utils.h" | 19 #include "chrome/test/ui_test_utils.h" |
21 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
22 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/keycodes/keyboard_codes.h" |
23 #include "views/controls/button/menu_button.h" | 23 #include "views/controls/button/menu_button.h" |
24 #include "views/controls/button/text_button.h" | 24 #include "views/controls/button/text_button.h" |
25 #include "views/controls/menu/menu_controller.h" | 25 #include "views/controls/menu/menu_controller.h" |
26 #include "views/controls/menu/menu_item_view.h" | 26 #include "views/controls/menu/menu_item_view.h" |
27 #include "views/controls/menu/submenu_view.h" | 27 #include "views/controls/menu/submenu_view.h" |
28 #include "views/views_delegate.h" | 28 #include "views/views_delegate.h" |
29 #include "views/window/window.h" | 29 #include "views/window/window.h" |
30 | 30 |
31 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
32 // See http://crbug.com/40040 for details. | 32 // See http://crbug.com/40040 for details. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 875 |
876 private: | 876 private: |
877 void Step2() { | 877 void Step2() { |
878 // Menu should be showing. | 878 // Menu should be showing. |
879 views::MenuItemView* menu = bb_view_->GetMenu(); | 879 views::MenuItemView* menu = bb_view_->GetMenu(); |
880 ASSERT_TRUE(menu != NULL); | 880 ASSERT_TRUE(menu != NULL); |
881 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 881 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
882 | 882 |
883 // Send a down event, which should select the first item. | 883 // Send a down event, which should select the first item. |
884 ui_controls::SendKeyPressNotifyWhenDone( | 884 ui_controls::SendKeyPressNotifyWhenDone( |
885 NULL, app::VKEY_DOWN, false, false, false, false, | 885 NULL, ui::VKEY_DOWN, false, false, false, false, |
886 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); | 886 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); |
887 } | 887 } |
888 | 888 |
889 void Step3() { | 889 void Step3() { |
890 // Make sure menu is showing and item is selected. | 890 // Make sure menu is showing and item is selected. |
891 views::MenuItemView* menu = bb_view_->GetMenu(); | 891 views::MenuItemView* menu = bb_view_->GetMenu(); |
892 ASSERT_TRUE(menu != NULL); | 892 ASSERT_TRUE(menu != NULL); |
893 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 893 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
894 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 894 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
895 | 895 |
896 // Send a key down event, which should select the next item. | 896 // Send a key down event, which should select the next item. |
897 ui_controls::SendKeyPressNotifyWhenDone( | 897 ui_controls::SendKeyPressNotifyWhenDone( |
898 NULL, app::VKEY_DOWN, false, false, false, false, | 898 NULL, ui::VKEY_DOWN, false, false, false, false, |
899 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); | 899 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); |
900 } | 900 } |
901 | 901 |
902 void Step4() { | 902 void Step4() { |
903 views::MenuItemView* menu = bb_view_->GetMenu(); | 903 views::MenuItemView* menu = bb_view_->GetMenu(); |
904 ASSERT_TRUE(menu != NULL); | 904 ASSERT_TRUE(menu != NULL); |
905 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 905 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
906 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 906 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
907 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); | 907 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); |
908 | 908 |
909 // Send a right arrow to force the menu to open. | 909 // Send a right arrow to force the menu to open. |
910 ui_controls::SendKeyPressNotifyWhenDone( | 910 ui_controls::SendKeyPressNotifyWhenDone( |
911 NULL, app::VKEY_RIGHT, false, false, false, false, | 911 NULL, ui::VKEY_RIGHT, false, false, false, false, |
912 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); | 912 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); |
913 } | 913 } |
914 | 914 |
915 void Step5() { | 915 void Step5() { |
916 // Make sure the submenu is showing. | 916 // Make sure the submenu is showing. |
917 views::MenuItemView* menu = bb_view_->GetMenu(); | 917 views::MenuItemView* menu = bb_view_->GetMenu(); |
918 ASSERT_TRUE(menu != NULL); | 918 ASSERT_TRUE(menu != NULL); |
919 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 919 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
920 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); | 920 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); |
921 ASSERT_TRUE(submenu->IsSelected()); | 921 ASSERT_TRUE(submenu->IsSelected()); |
922 ASSERT_TRUE(submenu->GetSubmenu()); | 922 ASSERT_TRUE(submenu->GetSubmenu()); |
923 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); | 923 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); |
924 | 924 |
925 // Send a left arrow to close the submenu. | 925 // Send a left arrow to close the submenu. |
926 ui_controls::SendKeyPressNotifyWhenDone( | 926 ui_controls::SendKeyPressNotifyWhenDone( |
927 NULL, app::VKEY_LEFT, false, false, false, false, | 927 NULL, ui::VKEY_LEFT, false, false, false, false, |
928 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); | 928 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); |
929 } | 929 } |
930 | 930 |
931 void Step6() { | 931 void Step6() { |
932 // Make sure the submenu is showing. | 932 // Make sure the submenu is showing. |
933 views::MenuItemView* menu = bb_view_->GetMenu(); | 933 views::MenuItemView* menu = bb_view_->GetMenu(); |
934 ASSERT_TRUE(menu != NULL); | 934 ASSERT_TRUE(menu != NULL); |
935 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 935 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
936 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); | 936 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); |
937 ASSERT_TRUE(submenu->IsSelected()); | 937 ASSERT_TRUE(submenu->IsSelected()); |
938 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); | 938 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); |
939 | 939 |
940 // Send a down arrow to wrap back to f1a | 940 // Send a down arrow to wrap back to f1a |
941 ui_controls::SendKeyPressNotifyWhenDone( | 941 ui_controls::SendKeyPressNotifyWhenDone( |
942 NULL, app::VKEY_DOWN, false, false, false, false, | 942 NULL, ui::VKEY_DOWN, false, false, false, false, |
943 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); | 943 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); |
944 } | 944 } |
945 | 945 |
946 void Step7() { | 946 void Step7() { |
947 // Make sure menu is showing and item is selected. | 947 // Make sure menu is showing and item is selected. |
948 views::MenuItemView* menu = bb_view_->GetMenu(); | 948 views::MenuItemView* menu = bb_view_->GetMenu(); |
949 ASSERT_TRUE(menu != NULL); | 949 ASSERT_TRUE(menu != NULL); |
950 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 950 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
951 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 951 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
952 | 952 |
953 // Send enter, which should select the item. | 953 // Send enter, which should select the item. |
954 ui_controls::SendKeyPressNotifyWhenDone( | 954 ui_controls::SendKeyPressNotifyWhenDone( |
955 NULL, app::VKEY_RETURN, false, false, false, false, | 955 NULL, ui::VKEY_RETURN, false, false, false, false, |
956 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); | 956 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); |
957 } | 957 } |
958 | 958 |
959 void Step8() { | 959 void Step8() { |
960 ASSERT_TRUE( | 960 ASSERT_TRUE( |
961 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == | 961 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == |
962 navigator_.url_); | 962 navigator_.url_); |
963 Done(); | 963 Done(); |
964 } | 964 } |
965 }; | 965 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1000 |
1001 // Right click on the first child to get its context menu. | 1001 // Right click on the first child to get its context menu. |
1002 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 1002 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
1003 ui_controls::DOWN | ui_controls::UP, NULL); | 1003 ui_controls::DOWN | ui_controls::UP, NULL); |
1004 // Step3 will be invoked by ContextMenuNotificationObserver. | 1004 // Step3 will be invoked by ContextMenuNotificationObserver. |
1005 } | 1005 } |
1006 | 1006 |
1007 void Step3() { | 1007 void Step3() { |
1008 // Send escape so that the context menu hides. | 1008 // Send escape so that the context menu hides. |
1009 ui_controls::SendKeyPressNotifyWhenDone( | 1009 ui_controls::SendKeyPressNotifyWhenDone( |
1010 NULL, app::VKEY_ESCAPE, false, false, false, false, | 1010 NULL, ui::VKEY_ESCAPE, false, false, false, false, |
1011 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); | 1011 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); |
1012 } | 1012 } |
1013 | 1013 |
1014 void Step4() { | 1014 void Step4() { |
1015 // Make sure the context menu is no longer showing. | 1015 // Make sure the context menu is no longer showing. |
1016 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1016 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
1017 ASSERT_TRUE(!menu || !menu->GetSubmenu() || | 1017 ASSERT_TRUE(!menu || !menu->GetSubmenu() || |
1018 !menu->GetSubmenu()->IsShowing()); | 1018 !menu->GetSubmenu()->IsShowing()); |
1019 | 1019 |
1020 // But the menu should be showing. | 1020 // But the menu should be showing. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 ui_controls::DOWN | ui_controls::UP, NULL); | 1089 ui_controls::DOWN | ui_controls::UP, NULL); |
1090 | 1090 |
1091 // Delay until we send tab, otherwise the message box doesn't appear | 1091 // Delay until we send tab, otherwise the message box doesn't appear |
1092 // correctly. | 1092 // correctly. |
1093 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1093 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1094 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); | 1094 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); |
1095 } | 1095 } |
1096 | 1096 |
1097 void Step4() { | 1097 void Step4() { |
1098 // Press tab to give focus to the cancel button. | 1098 // Press tab to give focus to the cancel button. |
1099 ui_controls::SendKeyPress(NULL, app::VKEY_TAB, false, false, false, false); | 1099 ui_controls::SendKeyPress(NULL, ui::VKEY_TAB, false, false, false, false); |
1100 | 1100 |
1101 // For some reason return isn't processed correctly unless we delay. | 1101 // For some reason return isn't processed correctly unless we delay. |
1102 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1102 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1103 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); | 1103 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); |
1104 } | 1104 } |
1105 | 1105 |
1106 void Step5() { | 1106 void Step5() { |
1107 // And press enter so that the cancel button is selected. | 1107 // And press enter so that the cancel button is selected. |
1108 ui_controls::SendKeyPressNotifyWhenDone( | 1108 ui_controls::SendKeyPressNotifyWhenDone( |
1109 NULL, app::VKEY_RETURN, false, false, false, false, | 1109 NULL, ui::VKEY_RETURN, false, false, false, false, |
1110 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); | 1110 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); |
1111 } | 1111 } |
1112 | 1112 |
1113 void Step6() { | 1113 void Step6() { |
1114 // Do a delayed task to give the dialog time to exit. | 1114 // Do a delayed task to give the dialog time to exit. |
1115 MessageLoop::current()->PostTask( | 1115 MessageLoop::current()->PostTask( |
1116 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); | 1116 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); |
1117 } | 1117 } |
1118 | 1118 |
1119 void Step7() { | 1119 void Step7() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 | 1228 |
1229 private: | 1229 private: |
1230 | 1230 |
1231 void Step2() { | 1231 void Step2() { |
1232 // Menu should NOT be showing. | 1232 // Menu should NOT be showing. |
1233 views::MenuItemView* menu = bb_view_->GetMenu(); | 1233 views::MenuItemView* menu = bb_view_->GetMenu(); |
1234 ASSERT_TRUE(menu == NULL); | 1234 ASSERT_TRUE(menu == NULL); |
1235 | 1235 |
1236 // Send escape so that the context menu hides. | 1236 // Send escape so that the context menu hides. |
1237 ui_controls::SendKeyPressNotifyWhenDone( | 1237 ui_controls::SendKeyPressNotifyWhenDone( |
1238 NULL, app::VKEY_ESCAPE, false, false, false, false, | 1238 NULL, ui::VKEY_ESCAPE, false, false, false, false, |
1239 CreateEventTask(this, &BookmarkBarViewTest14::Step3)); | 1239 CreateEventTask(this, &BookmarkBarViewTest14::Step3)); |
1240 } | 1240 } |
1241 | 1241 |
1242 void Step3() { | 1242 void Step3() { |
1243 Done(); | 1243 Done(); |
1244 } | 1244 } |
1245 | 1245 |
1246 ContextMenuNotificationObserver observer_; | 1246 ContextMenuNotificationObserver observer_; |
1247 }; | 1247 }; |
1248 | 1248 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); | 1352 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); |
1353 | 1353 |
1354 // Close the window. | 1354 // Close the window. |
1355 window_->Close(); | 1355 window_->Close(); |
1356 window_ = NULL; | 1356 window_ = NULL; |
1357 } | 1357 } |
1358 }; | 1358 }; |
1359 | 1359 |
1360 // Disabled, http://crbug.com/64303. | 1360 // Disabled, http://crbug.com/64303. |
1361 VIEW_TEST(BookmarkBarViewTest16, DISABLED_DeleteMenu) | 1361 VIEW_TEST(BookmarkBarViewTest16, DISABLED_DeleteMenu) |
OLD | NEW |