OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/browser/automation/ui_controls.h" | 7 #include "chrome/browser/automation/ui_controls.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/bookmarks/bookmark_utils.h" | 9 #include "chrome/browser/bookmarks/bookmark_utils.h" |
10 #include "chrome/browser/pref_service.h" | 10 #include "chrome/browser/pref_service.h" |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 | 853 |
854 private: | 854 private: |
855 void Step2() { | 855 void Step2() { |
856 // Menu should be showing. | 856 // Menu should be showing. |
857 views::MenuItemView* menu = bb_view_->GetMenu(); | 857 views::MenuItemView* menu = bb_view_->GetMenu(); |
858 ASSERT_TRUE(menu != NULL); | 858 ASSERT_TRUE(menu != NULL); |
859 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 859 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
860 | 860 |
861 // Send a down event, which should select the first item. | 861 // Send a down event, which should select the first item. |
862 ui_controls::SendKeyPressNotifyWhenDone( | 862 ui_controls::SendKeyPressNotifyWhenDone( |
863 NULL, base::VKEY_DOWN, false, false, false, | 863 NULL, base::VKEY_DOWN, false, false, false, false, |
864 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); | 864 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); |
865 } | 865 } |
866 | 866 |
867 void Step3() { | 867 void Step3() { |
868 // Make sure menu is showing and item is selected. | 868 // Make sure menu is showing and item is selected. |
869 views::MenuItemView* menu = bb_view_->GetMenu(); | 869 views::MenuItemView* menu = bb_view_->GetMenu(); |
870 ASSERT_TRUE(menu != NULL); | 870 ASSERT_TRUE(menu != NULL); |
871 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 871 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
872 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 872 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
873 | 873 |
874 // Send a key down event, which should select the next item. | 874 // Send a key down event, which should select the next item. |
875 ui_controls::SendKeyPressNotifyWhenDone( | 875 ui_controls::SendKeyPressNotifyWhenDone( |
876 NULL, base::VKEY_DOWN, false, false, false, | 876 NULL, base::VKEY_DOWN, false, false, false, false, |
877 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); | 877 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); |
878 } | 878 } |
879 | 879 |
880 void Step4() { | 880 void Step4() { |
881 views::MenuItemView* menu = bb_view_->GetMenu(); | 881 views::MenuItemView* menu = bb_view_->GetMenu(); |
882 ASSERT_TRUE(menu != NULL); | 882 ASSERT_TRUE(menu != NULL); |
883 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 883 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
884 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 884 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
885 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); | 885 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); |
886 | 886 |
887 // Send a right arrow to force the menu to open. | 887 // Send a right arrow to force the menu to open. |
888 ui_controls::SendKeyPressNotifyWhenDone( | 888 ui_controls::SendKeyPressNotifyWhenDone( |
889 NULL, base::VKEY_RIGHT, false, false, false, | 889 NULL, base::VKEY_RIGHT, false, false, false, false, |
890 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); | 890 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); |
891 } | 891 } |
892 | 892 |
893 void Step5() { | 893 void Step5() { |
894 // Make sure the submenu is showing. | 894 // Make sure the submenu is showing. |
895 views::MenuItemView* menu = bb_view_->GetMenu(); | 895 views::MenuItemView* menu = bb_view_->GetMenu(); |
896 ASSERT_TRUE(menu != NULL); | 896 ASSERT_TRUE(menu != NULL); |
897 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 897 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
898 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); | 898 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); |
899 ASSERT_TRUE(submenu->IsSelected()); | 899 ASSERT_TRUE(submenu->IsSelected()); |
900 ASSERT_TRUE(submenu->GetSubmenu()); | 900 ASSERT_TRUE(submenu->GetSubmenu()); |
901 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); | 901 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); |
902 | 902 |
903 // Send a left arrow to close the submenu. | 903 // Send a left arrow to close the submenu. |
904 ui_controls::SendKeyPressNotifyWhenDone( | 904 ui_controls::SendKeyPressNotifyWhenDone( |
905 NULL, base::VKEY_LEFT, false, false, false, | 905 NULL, base::VKEY_LEFT, false, false, false, false, |
906 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); | 906 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); |
907 } | 907 } |
908 | 908 |
909 void Step6() { | 909 void Step6() { |
910 // Make sure the submenu is showing. | 910 // Make sure the submenu is showing. |
911 views::MenuItemView* menu = bb_view_->GetMenu(); | 911 views::MenuItemView* menu = bb_view_->GetMenu(); |
912 ASSERT_TRUE(menu != NULL); | 912 ASSERT_TRUE(menu != NULL); |
913 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 913 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
914 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); | 914 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); |
915 ASSERT_TRUE(submenu->IsSelected()); | 915 ASSERT_TRUE(submenu->IsSelected()); |
916 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); | 916 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); |
917 | 917 |
918 // Send a down arrow to wrap back to f1a | 918 // Send a down arrow to wrap back to f1a |
919 ui_controls::SendKeyPressNotifyWhenDone( | 919 ui_controls::SendKeyPressNotifyWhenDone( |
920 NULL, base::VKEY_DOWN, false, false, false, | 920 NULL, base::VKEY_DOWN, false, false, false, false, |
921 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); | 921 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); |
922 } | 922 } |
923 | 923 |
924 void Step7() { | 924 void Step7() { |
925 // Make sure menu is showing and item is selected. | 925 // Make sure menu is showing and item is selected. |
926 views::MenuItemView* menu = bb_view_->GetMenu(); | 926 views::MenuItemView* menu = bb_view_->GetMenu(); |
927 ASSERT_TRUE(menu != NULL); | 927 ASSERT_TRUE(menu != NULL); |
928 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 928 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
929 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 929 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
930 | 930 |
931 // Send enter, which should select the item. | 931 // Send enter, which should select the item. |
932 ui_controls::SendKeyPressNotifyWhenDone( | 932 ui_controls::SendKeyPressNotifyWhenDone( |
933 NULL, base::VKEY_RETURN, false, false, false, | 933 NULL, base::VKEY_RETURN, false, false, false, false, |
934 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); | 934 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); |
935 } | 935 } |
936 | 936 |
937 void Step8() { | 937 void Step8() { |
938 ASSERT_TRUE( | 938 ASSERT_TRUE( |
939 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == | 939 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == |
940 navigator_.url_); | 940 navigator_.url_); |
941 Done(); | 941 Done(); |
942 } | 942 } |
943 }; | 943 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 | 978 |
979 // Right click on the first child to get its context menu. | 979 // Right click on the first child to get its context menu. |
980 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 980 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
981 ui_controls::DOWN | ui_controls::UP, NULL); | 981 ui_controls::DOWN | ui_controls::UP, NULL); |
982 // Step3 will be invoked by ContextMenuNotificationObserver. | 982 // Step3 will be invoked by ContextMenuNotificationObserver. |
983 } | 983 } |
984 | 984 |
985 void Step3() { | 985 void Step3() { |
986 // Send escape so that the context menu hides. | 986 // Send escape so that the context menu hides. |
987 ui_controls::SendKeyPressNotifyWhenDone( | 987 ui_controls::SendKeyPressNotifyWhenDone( |
988 NULL, base::VKEY_ESCAPE, false, false, false, | 988 NULL, base::VKEY_ESCAPE, false, false, false, false, |
989 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); | 989 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); |
990 } | 990 } |
991 | 991 |
992 void Step4() { | 992 void Step4() { |
993 // Make sure the context menu is no longer showing. | 993 // Make sure the context menu is no longer showing. |
994 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 994 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
995 ASSERT_TRUE(!menu || !menu->GetSubmenu() || | 995 ASSERT_TRUE(!menu || !menu->GetSubmenu() || |
996 !menu->GetSubmenu()->IsShowing()); | 996 !menu->GetSubmenu()->IsShowing()); |
997 | 997 |
998 // But the menu should be showing. | 998 // But the menu should be showing. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 ui_controls::DOWN | ui_controls::UP, NULL); | 1067 ui_controls::DOWN | ui_controls::UP, NULL); |
1068 | 1068 |
1069 // Delay until we send tab, otherwise the message box doesn't appear | 1069 // Delay until we send tab, otherwise the message box doesn't appear |
1070 // correctly. | 1070 // correctly. |
1071 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1071 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1072 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); | 1072 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); |
1073 } | 1073 } |
1074 | 1074 |
1075 void Step4() { | 1075 void Step4() { |
1076 // Press tab to give focus to the cancel button. | 1076 // Press tab to give focus to the cancel button. |
1077 ui_controls::SendKeyPress(NULL, base::VKEY_TAB, false, false, false); | 1077 ui_controls::SendKeyPress(NULL, base::VKEY_TAB, false, false, false, false); |
1078 | 1078 |
1079 // For some reason return isn't processed correctly unless we delay. | 1079 // For some reason return isn't processed correctly unless we delay. |
1080 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1080 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1081 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); | 1081 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); |
1082 } | 1082 } |
1083 | 1083 |
1084 void Step5() { | 1084 void Step5() { |
1085 // And press enter so that the cancel button is selected. | 1085 // And press enter so that the cancel button is selected. |
1086 ui_controls::SendKeyPressNotifyWhenDone( | 1086 ui_controls::SendKeyPressNotifyWhenDone( |
1087 NULL, base::VKEY_RETURN, false, false, false, | 1087 NULL, base::VKEY_RETURN, false, false, false, false, |
1088 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); | 1088 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); |
1089 } | 1089 } |
1090 | 1090 |
1091 void Step6() { | 1091 void Step6() { |
1092 // Do a delayed task to give the dialog time to exit. | 1092 // Do a delayed task to give the dialog time to exit. |
1093 MessageLoop::current()->PostTask( | 1093 MessageLoop::current()->PostTask( |
1094 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); | 1094 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); |
1095 } | 1095 } |
1096 | 1096 |
1097 void Step7() { | 1097 void Step7() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 | 1206 |
1207 private: | 1207 private: |
1208 | 1208 |
1209 void Step2() { | 1209 void Step2() { |
1210 // Menu should NOT be showing. | 1210 // Menu should NOT be showing. |
1211 views::MenuItemView* menu = bb_view_->GetMenu(); | 1211 views::MenuItemView* menu = bb_view_->GetMenu(); |
1212 ASSERT_TRUE(menu == NULL); | 1212 ASSERT_TRUE(menu == NULL); |
1213 | 1213 |
1214 // Send escape so that the context menu hides. | 1214 // Send escape so that the context menu hides. |
1215 ui_controls::SendKeyPressNotifyWhenDone( | 1215 ui_controls::SendKeyPressNotifyWhenDone( |
1216 NULL, base::VKEY_ESCAPE, false, false, false, | 1216 NULL, base::VKEY_ESCAPE, false, false, false, false, |
1217 CreateEventTask(this, &BookmarkBarViewTest14::Step3)); | 1217 CreateEventTask(this, &BookmarkBarViewTest14::Step3)); |
1218 } | 1218 } |
1219 | 1219 |
1220 void Step3() { | 1220 void Step3() { |
1221 Done(); | 1221 Done(); |
1222 } | 1222 } |
1223 | 1223 |
1224 ContextMenuNotificationObserver observer_; | 1224 ContextMenuNotificationObserver observer_; |
1225 }; | 1225 }; |
1226 | 1226 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 views::TextButton* button = bb_view_->GetBookmarkButton(0); | 1329 views::TextButton* button = bb_view_->GetBookmarkButton(0); |
1330 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); | 1330 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); |
1331 | 1331 |
1332 // Close the window. | 1332 // Close the window. |
1333 window_->Close(); | 1333 window_->Close(); |
1334 window_ = NULL; | 1334 window_ = NULL; |
1335 } | 1335 } |
1336 }; | 1336 }; |
1337 | 1337 |
1338 VIEW_TEST(BookmarkBarViewTest16, DeleteMenu) | 1338 VIEW_TEST(BookmarkBarViewTest16, DeleteMenu) |
OLD | NEW |