diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-13 23:09:49 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-13 23:09:49 +0000 |
commit | c67b85c499e7b85007d32bac2ee9b01493825e44 (patch) | |
tree | 60a19176aad767036f9cc91a8e9cb0898c66e5b3 /chrome/browser | |
parent | 7a64bcecf1febf468f3eaa39695a11e72d24b5dc (diff) | |
download | chromium_src-c67b85c499e7b85007d32bac2ee9b01493825e44.zip chromium_src-c67b85c499e7b85007d32bac2ee9b01493825e44.tar.gz chromium_src-c67b85c499e7b85007d32bac2ee9b01493825e44.tar.bz2 |
Three menu bugs:
. If a context menu was shown from a menu, then hidden we did not keep
mouse capture and bad things happened (menu wouldn't go away when
clicking else where, crash ...).
. We only update menu sizes on first show of a menu. That way if a
context menu doesn't have icons things don't shift around.
. If nothing was selected in the menu pressing the context menu
showed the context menu for the root. It doesn't make sense for the
root menu to have a context menu.
BUG=4364
TEST=see bug
Review URL: http://codereview.chromium.org/10706
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/bookmark_bar_view_test.cc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc index c97bf3b..94d9a9c 100644 --- a/chrome/browser/views/bookmark_bar_view_test.cc +++ b/chrome/browser/views/bookmark_bar_view_test.cc @@ -824,3 +824,71 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { }; VIEW_TEST(BookmarkBarViewTest10, KeyEvents) + +// Make sure the menu closes with the following sequence: show menu, show +// context menu, close context menu (via escape), then click else where. This +// effectively verifies we maintain mouse capture after the context menu is +// hidden. +class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { + protected: + virtual void DoTestOnMessageLoop() { + // Move the mouse to the first folder on the bookmark bar and press the + // mouse. + views::TextButton* button = bb_view_->other_bookmarked_button(); + ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_controls::DOWN | ui_controls::UP, + CreateEventTask(this, &BookmarkBarViewTest11::Step2)); + } + + private: + void Step2() { + // Menu should be showing. + views::MenuItemView* menu = bb_view_->GetMenu(); + ASSERT_TRUE(menu != NULL); + ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); + + views::MenuItemView* child_menu = + menu->GetSubmenu()->GetMenuItemAt(0); + ASSERT_TRUE(child_menu != NULL); + + // Right click on the first child to get its context menu. + ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_controls::DOWN | ui_controls::UP, + CreateEventTask(this, &BookmarkBarViewTest11::Step3)); + } + + void Step3() { + // Send escape so that the context menu hides. + ui_controls::SendKeyPressNotifyWhenDone(VK_ESCAPE, false, false, false, + CreateEventTask(this, &BookmarkBarViewTest11::Step4)); + } + + void Step4() { + // Make sure the context menu is no longer showing. + views::MenuItemView* menu = bb_view_->GetContextMenu(); + ASSERT_TRUE(!menu || !menu->GetSubmenu() || + !menu->GetSubmenu()->IsShowing()); + + // But the menu should be showing. + menu = bb_view_->GetMenu(); + ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); + + // Now click on empty space. + gfx::Point mouse_loc; + views::View::ConvertPointToScreen(bb_view_, &mouse_loc); + ui_controls::SendMouseMove(mouse_loc.x(), mouse_loc.y()); + ui_controls::SendMouseEventsNotifyWhenDone( + ui_controls::LEFT, ui_controls::UP | ui_controls::DOWN, + CreateEventTask(this, &BookmarkBarViewTest11::Step5)); + } + + void Step5() { + // Make sure the menu is not showing. + views::MenuItemView* menu = bb_view_->GetMenu(); + ASSERT_TRUE(!menu || !menu->GetSubmenu() || + !menu->GetSubmenu()->IsShowing()); + Done(); + } +}; + +VIEW_TEST(BookmarkBarViewTest11, CloseMenuAfterClosingContextMenu) |