Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: chrome/browser/views/bookmark_bar_view_test.cc

Issue 171079: more linux automation porting: SendKeyPressNotifyWhenDone... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/string_util.h" 5 #include "base/string_util.h"
6 #include "chrome/browser/automation/ui_controls.h" 6 #include "chrome/browser/automation/ui_controls.h"
7 #include "chrome/browser/bookmarks/bookmark_model.h" 7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #include "chrome/browser/bookmarks/bookmark_utils.h" 8 #include "chrome/browser/bookmarks/bookmark_utils.h"
9 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/tab_contents/page_navigator.h" 10 #include "chrome/browser/tab_contents/page_navigator.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 ASSERT_TRUE(menu != NULL && menu->GetSubmenu()->IsShowing()); 241 ASSERT_TRUE(menu != NULL && menu->GetSubmenu()->IsShowing());
242 242
243 // Click on 0x0, which should trigger closing menu. 243 // Click on 0x0, which should trigger closing menu.
244 // NOTE: this code assume there is a left margin, which is currently 244 // NOTE: this code assume there is a left margin, which is currently
245 // true. If that changes, this code will need to find another empty space 245 // true. If that changes, this code will need to find another empty space
246 // to press the mouse on. 246 // to press the mouse on.
247 gfx::Point mouse_loc; 247 gfx::Point mouse_loc;
248 views::View::ConvertPointToScreen(bb_view_, &mouse_loc); 248 views::View::ConvertPointToScreen(bb_view_, &mouse_loc);
249 ui_controls::SendMouseMove(0, 0); 249 ui_controls::SendMouseMove(0, 0);
250 ui_controls::SendMouseEventsNotifyWhenDone( 250 ui_controls::SendMouseEventsNotifyWhenDone(
251 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, 251 NULL, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
252 CreateEventTask(this, &BookmarkBarViewTest2::Step3)); 252 CreateEventTask(this, &BookmarkBarViewTest2::Step3));
253 } 253 }
254 254
255 void Step3() { 255 void Step3() {
256 // The menu shouldn't be showing. 256 // The menu shouldn't be showing.
257 views::MenuItemView* menu = bb_view_->GetMenu(); 257 views::MenuItemView* menu = bb_view_->GetMenu();
258 ASSERT_TRUE(menu == NULL || !menu->GetSubmenu()->IsShowing()); 258 ASSERT_TRUE(menu == NULL || !menu->GetSubmenu()->IsShowing());
259 259
260 // Make sure button is no longer pushed. 260 // Make sure button is no longer pushed.
261 views::TextButton* button = bb_view_->GetBookmarkButton(0); 261 views::TextButton* button = bb_view_->GetBookmarkButton(0);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 737
738 private: 738 private:
739 void Step2() { 739 void Step2() {
740 // Menu should be showing. 740 // Menu should be showing.
741 views::MenuItemView* menu = bb_view_->GetMenu(); 741 views::MenuItemView* menu = bb_view_->GetMenu();
742 ASSERT_TRUE(menu != NULL); 742 ASSERT_TRUE(menu != NULL);
743 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 743 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
744 744
745 // Send a down event, which should select the first item. 745 // Send a down event, which should select the first item.
746 ui_controls::SendKeyPressNotifyWhenDone( 746 ui_controls::SendKeyPressNotifyWhenDone(
747 VK_DOWN, false, false, false, 747 NULL, VK_DOWN, false, false, false,
748 CreateEventTask(this, &BookmarkBarViewTest10::Step3)); 748 CreateEventTask(this, &BookmarkBarViewTest10::Step3));
749 } 749 }
750 750
751 void Step3() { 751 void Step3() {
752 // Make sure menu is showing and item is selected. 752 // Make sure menu is showing and item is selected.
753 views::MenuItemView* menu = bb_view_->GetMenu(); 753 views::MenuItemView* menu = bb_view_->GetMenu();
754 ASSERT_TRUE(menu != NULL); 754 ASSERT_TRUE(menu != NULL);
755 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 755 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
756 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); 756 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected());
757 757
758 // Send a key down event, which should select the next item. 758 // Send a key down event, which should select the next item.
759 ui_controls::SendKeyPressNotifyWhenDone( 759 ui_controls::SendKeyPressNotifyWhenDone(
760 VK_DOWN, false, false, false, 760 NULL, VK_DOWN, false, false, false,
761 CreateEventTask(this, &BookmarkBarViewTest10::Step4)); 761 CreateEventTask(this, &BookmarkBarViewTest10::Step4));
762 } 762 }
763 763
764 void Step4() { 764 void Step4() {
765 views::MenuItemView* menu = bb_view_->GetMenu(); 765 views::MenuItemView* menu = bb_view_->GetMenu();
766 ASSERT_TRUE(menu != NULL); 766 ASSERT_TRUE(menu != NULL);
767 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 767 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
768 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); 768 ASSERT_FALSE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected());
769 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected()); 769 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(1)->IsSelected());
770 770
771 // Send a right arrow to force the menu to open. 771 // Send a right arrow to force the menu to open.
772 ui_controls::SendKeyPressNotifyWhenDone( 772 ui_controls::SendKeyPressNotifyWhenDone(
773 VK_RIGHT, false, false, false, 773 NULL, VK_RIGHT, false, false, false,
774 CreateEventTask(this, &BookmarkBarViewTest10::Step5)); 774 CreateEventTask(this, &BookmarkBarViewTest10::Step5));
775 } 775 }
776 776
777 void Step5() { 777 void Step5() {
778 // Make sure the submenu is showing. 778 // Make sure the submenu is showing.
779 views::MenuItemView* menu = bb_view_->GetMenu(); 779 views::MenuItemView* menu = bb_view_->GetMenu();
780 ASSERT_TRUE(menu != NULL); 780 ASSERT_TRUE(menu != NULL);
781 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 781 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
782 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); 782 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1);
783 ASSERT_TRUE(submenu->IsSelected()); 783 ASSERT_TRUE(submenu->IsSelected());
784 ASSERT_TRUE(submenu->GetSubmenu()); 784 ASSERT_TRUE(submenu->GetSubmenu());
785 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing()); 785 ASSERT_TRUE(submenu->GetSubmenu()->IsShowing());
786 786
787 // Send a left arrow to close the submenu. 787 // Send a left arrow to close the submenu.
788 ui_controls::SendKeyPressNotifyWhenDone( 788 ui_controls::SendKeyPressNotifyWhenDone(
789 VK_LEFT, false, false, false, 789 NULL, VK_LEFT, false, false, false,
790 CreateEventTask(this, &BookmarkBarViewTest10::Step6)); 790 CreateEventTask(this, &BookmarkBarViewTest10::Step6));
791 } 791 }
792 792
793 void Step6() { 793 void Step6() {
794 // Make sure the submenu is showing. 794 // Make sure the submenu is showing.
795 views::MenuItemView* menu = bb_view_->GetMenu(); 795 views::MenuItemView* menu = bb_view_->GetMenu();
796 ASSERT_TRUE(menu != NULL); 796 ASSERT_TRUE(menu != NULL);
797 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 797 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
798 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1); 798 views::MenuItemView* submenu = menu->GetSubmenu()->GetMenuItemAt(1);
799 ASSERT_TRUE(submenu->IsSelected()); 799 ASSERT_TRUE(submenu->IsSelected());
800 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing()); 800 ASSERT_TRUE(!submenu->GetSubmenu() || !submenu->GetSubmenu()->IsShowing());
801 801
802 // Send a down arrow to wrap back to f1a 802 // Send a down arrow to wrap back to f1a
803 ui_controls::SendKeyPressNotifyWhenDone( 803 ui_controls::SendKeyPressNotifyWhenDone(
804 VK_DOWN, false, false, false, 804 NULL, VK_DOWN, false, false, false,
805 CreateEventTask(this, &BookmarkBarViewTest10::Step7)); 805 CreateEventTask(this, &BookmarkBarViewTest10::Step7));
806 } 806 }
807 807
808 void Step7() { 808 void Step7() {
809 // Make sure menu is showing and item is selected. 809 // Make sure menu is showing and item is selected.
810 views::MenuItemView* menu = bb_view_->GetMenu(); 810 views::MenuItemView* menu = bb_view_->GetMenu();
811 ASSERT_TRUE(menu != NULL); 811 ASSERT_TRUE(menu != NULL);
812 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); 812 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
813 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected()); 813 ASSERT_TRUE(menu->GetSubmenu()->GetMenuItemAt(0)->IsSelected());
814 814
815 // Send enter, which should select the item. 815 // Send enter, which should select the item.
816 ui_controls::SendKeyPressNotifyWhenDone( 816 ui_controls::SendKeyPressNotifyWhenDone(
817 VK_RETURN, false, false, false, 817 NULL, VK_RETURN, false, false, false,
818 CreateEventTask(this, &BookmarkBarViewTest10::Step8)); 818 CreateEventTask(this, &BookmarkBarViewTest10::Step8));
819 } 819 }
820 820
821 void Step8() { 821 void Step8() {
822 ASSERT_TRUE( 822 ASSERT_TRUE(
823 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == 823 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() ==
824 navigator_.url_); 824 navigator_.url_);
825 Done(); 825 Done();
826 } 826 }
827 }; 827 };
(...skipping 27 matching lines...) Expand all
855 ASSERT_TRUE(child_menu != NULL); 855 ASSERT_TRUE(child_menu != NULL);
856 856
857 // Right click on the first child to get its context menu. 857 // Right click on the first child to get its context menu.
858 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, 858 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT,
859 ui_controls::DOWN | ui_controls::UP, 859 ui_controls::DOWN | ui_controls::UP,
860 CreateEventTask(this, &BookmarkBarViewTest11::Step3)); 860 CreateEventTask(this, &BookmarkBarViewTest11::Step3));
861 } 861 }
862 862
863 void Step3() { 863 void Step3() {
864 // Send escape so that the context menu hides. 864 // Send escape so that the context menu hides.
865 ui_controls::SendKeyPressNotifyWhenDone(VK_ESCAPE, false, false, false, 865 ui_controls::SendKeyPressNotifyWhenDone(
866 NULL, VK_ESCAPE, false, false, false,
866 CreateEventTask(this, &BookmarkBarViewTest11::Step4)); 867 CreateEventTask(this, &BookmarkBarViewTest11::Step4));
867 } 868 }
868 869
869 void Step4() { 870 void Step4() {
870 // Make sure the context menu is no longer showing. 871 // Make sure the context menu is no longer showing.
871 views::MenuItemView* menu = bb_view_->GetContextMenu(); 872 views::MenuItemView* menu = bb_view_->GetContextMenu();
872 ASSERT_TRUE(!menu || !menu->GetSubmenu() || 873 ASSERT_TRUE(!menu || !menu->GetSubmenu() ||
873 !menu->GetSubmenu()->IsShowing()); 874 !menu->GetSubmenu()->IsShowing());
874 875
875 // But the menu should be showing. 876 // But the menu should be showing.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 ui_controls::DOWN | ui_controls::UP, NULL); 943 ui_controls::DOWN | ui_controls::UP, NULL);
943 944
944 // Delay until we send tab, otherwise the message box doesn't appear 945 // Delay until we send tab, otherwise the message box doesn't appear
945 // correctly. 946 // correctly.
946 MessageLoop::current()->PostDelayedTask(FROM_HERE, 947 MessageLoop::current()->PostDelayedTask(FROM_HERE,
947 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000); 948 CreateEventTask(this, &BookmarkBarViewTest12::Step4), 1000);
948 } 949 }
949 950
950 void Step4() { 951 void Step4() {
951 // Press tab to give focus to the cancel button. 952 // Press tab to give focus to the cancel button.
952 ui_controls::SendKeyPressNotifyWhenDone(VK_TAB, false, false, false, 953 ui_controls::SendKeyPress(NULL, VK_TAB, false, false, false);
953 NULL);
954 954
955 // For some reason return isn't processed correctly unless we delay. 955 // For some reason return isn't processed correctly unless we delay.
956 MessageLoop::current()->PostDelayedTask(FROM_HERE, 956 MessageLoop::current()->PostDelayedTask(FROM_HERE,
957 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000); 957 CreateEventTask(this, &BookmarkBarViewTest12::Step5), 1000);
958 } 958 }
959 959
960 void Step5() { 960 void Step5() {
961 // And press enter so that the cancel button is selected. 961 // And press enter so that the cancel button is selected.
962 ui_controls::SendKeyPressNotifyWhenDone(VK_RETURN, false, false, false, 962 ui_controls::SendKeyPressNotifyWhenDone(
963 NULL, VK_RETURN, false, false, false,
963 CreateEventTask(this, &BookmarkBarViewTest12::Step6)); 964 CreateEventTask(this, &BookmarkBarViewTest12::Step6));
964 } 965 }
965 966
966 void Step6() { 967 void Step6() {
967 // Do a delayed task to give the dialog time to exit. 968 // Do a delayed task to give the dialog time to exit.
968 MessageLoop::current()->PostTask( 969 MessageLoop::current()->PostTask(
969 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); 970 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7));
970 } 971 }
971 972
972 void Step7() { 973 void Step7() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 CreateEventTask(this, &BookmarkBarViewTest13::Step5)); 1046 CreateEventTask(this, &BookmarkBarViewTest13::Step5));
1046 } 1047 }
1047 1048
1048 void Step5() { 1049 void Step5() {
1049 DLOG(WARNING) << " DONE"; 1050 DLOG(WARNING) << " DONE";
1050 Done(); 1051 Done();
1051 } 1052 }
1052 }; 1053 };
1053 1054
1054 VIEW_TEST(BookmarkBarViewTest13, ClickOnContextMenuSeparator) 1055 VIEW_TEST(BookmarkBarViewTest13, ClickOnContextMenuSeparator)
OLDNEW
« no previous file with comments | « chrome/browser/browser_focus_uitest.cc ('k') | chrome/test/automated_ui_tests/automated_ui_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698