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 "app/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/automation/ui_controls.h" | 8 #include "chrome/browser/automation/ui_controls.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
13 #include "chrome/browser/tab_contents/page_navigator.h" | 13 #include "chrome/browser/tab_contents/page_navigator.h" |
14 #include "chrome/browser/views/bookmark_bar_view.h" | 14 #include "chrome/browser/views/bookmark_bar_view.h" |
15 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 866 |
867 private: | 867 private: |
868 void Step2() { | 868 void Step2() { |
869 // Menu should be showing. | 869 // Menu should be showing. |
870 views::MenuItemView* menu = bb_view_->GetMenu(); | 870 views::MenuItemView* menu = bb_view_->GetMenu(); |
871 ASSERT_TRUE(menu != NULL); | 871 ASSERT_TRUE(menu != NULL); |
872 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 872 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
873 | 873 |
874 // Send a down event, which should select the first item. | 874 // Send a down event, which should select the first item. |
875 ui_controls::SendKeyPressNotifyWhenDone( | 875 ui_controls::SendKeyPressNotifyWhenDone( |
876 NULL, app::VKEY_DOWN, false, false, false, false, | 876 NULL, base::VKEY_DOWN, false, false, false, false, |
877 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); | 877 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); |
878 } | 878 } |
879 | 879 |
880 void Step3() { | 880 void Step3() { |
881 // Make sure menu is showing and item is selected. | 881 // Make sure menu is showing and item is selected. |
882 views::MenuItemView* menu = bb_view_->GetMenu(); | 882 views::MenuItemView* menu = bb_view_->GetMenu(); |
883 ASSERT_TRUE(menu != NULL); | 883 ASSERT_TRUE(menu != NULL); |
884 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 884 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
885 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 885 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
886 | 886 |
887 // Send a key down event, which should select the next item. | 887 // Send a key down event, which should select the next item. |
888 ui_controls::SendKeyPressNotifyWhenDone( | 888 ui_controls::SendKeyPressNotifyWhenDone( |
889 NULL, app::VKEY_DOWN, false, false, false, false, | 889 NULL, base::VKEY_DOWN, false, false, false, false, |
890 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); | 890 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); |
891 } | 891 } |
892 | 892 |
893 void Step4() { | 893 void Step4() { |
894 views::MenuItemView* menu = bb_view_->GetMenu(); | 894 views::MenuItemView* menu = bb_view_->GetMenu(); |
895 ASSERT_TRUE(menu != NULL); | 895 ASSERT_TRUE(menu != NULL); |
896 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 896 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
897 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 897 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
898 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); | 898 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); |
899 | 899 |
900 // Send a right arrow to force the menu to open. | 900 // Send a right arrow to force the menu to open. |
901 ui_controls::SendKeyPressNotifyWhenDone( | 901 ui_controls::SendKeyPressNotifyWhenDone( |
902 NULL, app::VKEY_RIGHT, false, false, false, false, | 902 NULL, base::VKEY_RIGHT, false, false, false, false, |
903 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); | 903 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); |
904 } | 904 } |
905 | 905 |
906 void Step5() { | 906 void Step5() { |
907 // Make sure the submenu is showing. | 907 // Make sure the submenu is showing. |
908 views::MenuItemView* menu = bb_view_->GetMenu(); | 908 views::MenuItemView* menu = bb_view_->GetMenu(); |
909 ASSERT_TRUE(menu != NULL); | 909 ASSERT_TRUE(menu != NULL); |
910 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 910 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
911 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); | 911 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); |
912 ASSERT_TRUE(submenu->IsSelected()); | 912 ASSERT_TRUE(submenu->IsSelected()); |
913 ASSERT_TRUE(submenu->GetSubmenu()); | 913 ASSERT_TRUE(submenu->GetSubmenu()); |
914 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); | 914 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); |
915 | 915 |
916 // Send a left arrow to close the submenu. | 916 // Send a left arrow to close the submenu. |
917 ui_controls::SendKeyPressNotifyWhenDone( | 917 ui_controls::SendKeyPressNotifyWhenDone( |
918 NULL, app::VKEY_LEFT, false, false, false, false, | 918 NULL, base::VKEY_LEFT, false, false, false, false, |
919 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); | 919 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); |
920 } | 920 } |
921 | 921 |
922 void Step6() { | 922 void Step6() { |
923 // Make sure the submenu is showing. | 923 // Make sure the submenu is showing. |
924 views::MenuItemView* menu = bb_view_->GetMenu(); | 924 views::MenuItemView* menu = bb_view_->GetMenu(); |
925 ASSERT_TRUE(menu != NULL); | 925 ASSERT_TRUE(menu != NULL); |
926 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 926 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
927 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); | 927 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); |
928 ASSERT_TRUE(submenu->IsSelected()); | 928 ASSERT_TRUE(submenu->IsSelected()); |
929 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); | 929 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); |
930 | 930 |
931 // Send a down arrow to wrap back to f1a | 931 // Send a down arrow to wrap back to f1a |
932 ui_controls::SendKeyPressNotifyWhenDone( | 932 ui_controls::SendKeyPressNotifyWhenDone( |
933 NULL, app::VKEY_DOWN, false, false, false, false, | 933 NULL, base::VKEY_DOWN, false, false, false, false, |
934 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); | 934 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); |
935 } | 935 } |
936 | 936 |
937 void Step7() { | 937 void Step7() { |
938 // Make sure menu is showing and item is selected. | 938 // Make sure menu is showing and item is selected. |
939 views::MenuItemView* menu = bb_view_->GetMenu(); | 939 views::MenuItemView* menu = bb_view_->GetMenu(); |
940 ASSERT_TRUE(menu != NULL); | 940 ASSERT_TRUE(menu != NULL); |
941 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 941 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
942 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); | 942 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); |
943 | 943 |
944 // Send enter, which should select the item. | 944 // Send enter, which should select the item. |
945 ui_controls::SendKeyPressNotifyWhenDone( | 945 ui_controls::SendKeyPressNotifyWhenDone( |
946 NULL, app::VKEY_RETURN, false, false, false, false, | 946 NULL, base::VKEY_RETURN, false, false, false, false, |
947 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); | 947 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); |
948 } | 948 } |
949 | 949 |
950 void Step8() { | 950 void Step8() { |
951 ASSERT_TRUE( | 951 ASSERT_TRUE( |
952 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == | 952 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == |
953 navigator_.url_); | 953 navigator_.url_); |
954 Done(); | 954 Done(); |
955 } | 955 } |
956 }; | 956 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 | 991 |
992 // Right click on the first child to get its context menu. | 992 // Right click on the first child to get its context menu. |
993 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, | 993 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
994 ui_controls::DOWN | ui_controls::UP, NULL); | 994 ui_controls::DOWN | ui_controls::UP, NULL); |
995 // Step3 will be invoked by ContextMenuNotificationObserver. | 995 // Step3 will be invoked by ContextMenuNotificationObserver. |
996 } | 996 } |
997 | 997 |
998 void Step3() { | 998 void Step3() { |
999 // Send escape so that the context menu hides. | 999 // Send escape so that the context menu hides. |
1000 ui_controls::SendKeyPressNotifyWhenDone( | 1000 ui_controls::SendKeyPressNotifyWhenDone( |
1001 NULL, app::VKEY_ESCAPE, false, false, false, false, | 1001 NULL, base::VKEY_ESCAPE, false, false, false, false, |
1002 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); | 1002 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); |
1003 } | 1003 } |
1004 | 1004 |
1005 void Step4() { | 1005 void Step4() { |
1006 // Make sure the context menu is no longer showing. | 1006 // Make sure the context menu is no longer showing. |
1007 views::MenuItemView* menu = bb_view_->GetContextMenu(); | 1007 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
1008 ASSERT_TRUE(!menu || !menu->GetSubmenu() || | 1008 ASSERT_TRUE(!menu || !menu->GetSubmenu() || |
1009 !menu->GetSubmenu()->IsShowing()); | 1009 !menu->GetSubmenu()->IsShowing()); |
1010 | 1010 |
1011 // But the menu should be showing. | 1011 // But the menu should be showing. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 ui_controls::DOWN | ui_controls::UP, NULL); | 1080 ui_controls::DOWN | ui_controls::UP, NULL); |
1081 | 1081 |
1082 // Delay until we send tab, otherwise the message box doesn't appear | 1082 // Delay until we send tab, otherwise the message box doesn't appear |
1083 // correctly. | 1083 // correctly. |
1084 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1084 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1085 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); | 1085 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); |
1086 } | 1086 } |
1087 | 1087 |
1088 void Step4() { | 1088 void Step4() { |
1089 // Press tab to give focus to the cancel button. | 1089 // Press tab to give focus to the cancel button. |
1090 ui_controls::SendKeyPress(NULL, app::VKEY_TAB, false, false, false, false); | 1090 ui_controls::SendKeyPress(NULL, base::VKEY_TAB, false, false, false, false); |
1091 | 1091 |
1092 // For some reason return isn't processed correctly unless we delay. | 1092 // For some reason return isn't processed correctly unless we delay. |
1093 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1093 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1094 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); | 1094 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); |
1095 } | 1095 } |
1096 | 1096 |
1097 void Step5() { | 1097 void Step5() { |
1098 // And press enter so that the cancel button is selected. | 1098 // And press enter so that the cancel button is selected. |
1099 ui_controls::SendKeyPressNotifyWhenDone( | 1099 ui_controls::SendKeyPressNotifyWhenDone( |
1100 NULL, app::VKEY_RETURN, false, false, false, false, | 1100 NULL, base::VKEY_RETURN, false, false, false, false, |
1101 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); | 1101 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); |
1102 } | 1102 } |
1103 | 1103 |
1104 void Step6() { | 1104 void Step6() { |
1105 // Do a delayed task to give the dialog time to exit. | 1105 // Do a delayed task to give the dialog time to exit. |
1106 MessageLoop::current()->PostTask( | 1106 MessageLoop::current()->PostTask( |
1107 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); | 1107 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); |
1108 } | 1108 } |
1109 | 1109 |
1110 void Step7() { | 1110 void Step7() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 | 1219 |
1220 private: | 1220 private: |
1221 | 1221 |
1222 void Step2() { | 1222 void Step2() { |
1223 // Menu should NOT be showing. | 1223 // Menu should NOT be showing. |
1224 views::MenuItemView* menu = bb_view_->GetMenu(); | 1224 views::MenuItemView* menu = bb_view_->GetMenu(); |
1225 ASSERT_TRUE(menu == NULL); | 1225 ASSERT_TRUE(menu == NULL); |
1226 | 1226 |
1227 // Send escape so that the context menu hides. | 1227 // Send escape so that the context menu hides. |
1228 ui_controls::SendKeyPressNotifyWhenDone( | 1228 ui_controls::SendKeyPressNotifyWhenDone( |
1229 NULL, app::VKEY_ESCAPE, false, false, false, false, | 1229 NULL, base::VKEY_ESCAPE, false, false, false, false, |
1230 CreateEventTask(this, &BookmarkBarViewTest14::Step3)); | 1230 CreateEventTask(this, &BookmarkBarViewTest14::Step3)); |
1231 } | 1231 } |
1232 | 1232 |
1233 void Step3() { | 1233 void Step3() { |
1234 Done(); | 1234 Done(); |
1235 } | 1235 } |
1236 | 1236 |
1237 ContextMenuNotificationObserver observer_; | 1237 ContextMenuNotificationObserver observer_; |
1238 }; | 1238 }; |
1239 | 1239 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 views::TextButton* button = bb_view_->GetBookmarkButton(0); | 1342 views::TextButton* button = bb_view_->GetBookmarkButton(0); |
1343 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); | 1343 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); |
1344 | 1344 |
1345 // Close the window. | 1345 // Close the window. |
1346 window_->Close(); | 1346 window_->Close(); |
1347 window_ = NULL; | 1347 window_ = NULL; |
1348 } | 1348 } |
1349 }; | 1349 }; |
1350 | 1350 |
1351 VIEW_TEST(BookmarkBarViewTest16, DeleteMenu) | 1351 VIEW_TEST(BookmarkBarViewTest16, DeleteMenu) |
OLD | NEW |