| OLD | NEW |
| 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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 MessageLoop::current()->PostTask( | 968 MessageLoop::current()->PostTask( |
| 969 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); | 969 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step7)); |
| 970 } | 970 } |
| 971 | 971 |
| 972 void Step7() { | 972 void Step7() { |
| 973 Done(); | 973 Done(); |
| 974 } | 974 } |
| 975 }; | 975 }; |
| 976 | 976 |
| 977 VIEW_TEST(BookmarkBarViewTest12, CloseWithModalDialog) | 977 VIEW_TEST(BookmarkBarViewTest12, CloseWithModalDialog) |
| 978 |
| 979 // Tests clicking on the separator of a context menu (this is for coverage of |
| 980 // bug 17862). |
| 981 class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { |
| 982 protected: |
| 983 virtual void DoTestOnMessageLoop() { |
| 984 // Move the mouse to the first folder on the bookmark bar and press the |
| 985 // mouse. |
| 986 views::TextButton* button = bb_view_->other_bookmarked_button(); |
| 987 ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, |
| 988 ui_controls::DOWN | ui_controls::UP, |
| 989 CreateEventTask(this, &BookmarkBarViewTest13::Step2)); |
| 990 } |
| 991 |
| 992 private: |
| 993 void Step2() { |
| 994 // Menu should be showing. |
| 995 views::MenuItemView* menu = bb_view_->GetMenu(); |
| 996 ASSERT_TRUE(menu != NULL); |
| 997 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 998 |
| 999 views::MenuItemView* child_menu = |
| 1000 menu->GetSubmenu()->GetMenuItemAt(0); |
| 1001 ASSERT_TRUE(child_menu != NULL); |
| 1002 |
| 1003 // Right click on the first child to get its context menu. |
| 1004 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, |
| 1005 ui_controls::DOWN | ui_controls::UP, |
| 1006 CreateEventTask(this, &BookmarkBarViewTest13::Step3)); |
| 1007 } |
| 1008 |
| 1009 void Step3() { |
| 1010 // Make sure the context menu is showing. |
| 1011 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1012 ASSERT_TRUE(menu != NULL); |
| 1013 ASSERT_TRUE(menu->GetSubmenu()); |
| 1014 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1015 |
| 1016 // Find the first separator. |
| 1017 views::SubmenuView* submenu = menu->GetSubmenu(); |
| 1018 views::View* separator_view = NULL; |
| 1019 for (int i = 0; i < submenu->GetChildViewCount(); ++i) { |
| 1020 if (submenu->GetChildViewAt(i)->GetID() != |
| 1021 views::MenuItemView::kMenuItemViewID) { |
| 1022 separator_view = submenu->GetChildViewAt(i); |
| 1023 break; |
| 1024 } |
| 1025 } |
| 1026 ASSERT_TRUE(separator_view); |
| 1027 |
| 1028 // Click on the separator. Clicking on the separator shouldn't visually |
| 1029 // change anything. |
| 1030 ui_controls::MoveMouseToCenterAndPress(separator_view, |
| 1031 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 1032 CreateEventTask(this, &BookmarkBarViewTest13::Step4)); |
| 1033 } |
| 1034 |
| 1035 void Step4() { |
| 1036 // The context menu should still be showing. |
| 1037 views::MenuItemView* menu = bb_view_->GetContextMenu(); |
| 1038 ASSERT_TRUE(menu != NULL); |
| 1039 ASSERT_TRUE(menu->GetSubmenu()); |
| 1040 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1041 |
| 1042 // Select the first context menu item. |
| 1043 ui_controls::MoveMouseToCenterAndPress(menu->GetSubmenu()->GetMenuItemAt(0), |
| 1044 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 1045 CreateEventTask(this, &BookmarkBarViewTest13::Step5)); |
| 1046 } |
| 1047 |
| 1048 void Step5() { |
| 1049 DLOG(WARNING) << " DONE"; |
| 1050 Done(); |
| 1051 } |
| 1052 }; |
| 1053 |
| 1054 VIEW_TEST(BookmarkBarViewTest13, ClickOnContextMenuSeparator) |
| OLD | NEW |