summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 20:20:35 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 20:20:35 +0000
commitf9358382509f917e508c7fd910ef2cc49d7671fc (patch)
tree8fbfa13c55651feb08c5d72bd0d3727b0feec9f2 /chrome/browser
parent4dfae51bf8db229251104bc71ae14237a5989e1c (diff)
downloadchromium_src-f9358382509f917e508c7fd910ef2cc49d7671fc.zip
chromium_src-f9358382509f917e508c7fd910ef2cc49d7671fc.tar.gz
chromium_src-f9358382509f917e508c7fd910ef2cc49d7671fc.tar.bz2
Fixes possible crash in bookmark menus. Specifically if you had a menu
showing and brought up the context menu and clicked a separator we would do the wrong thing. We would try to show the first menu again, without cancelling out of the inner loop, which would most likely result in a crash. The right thing to do in this case is not close the context menu (this behavior can be seen in windows as well). BUG=17862 TEST=see bug, but also covered by ui test now. Review URL: http://codereview.chromium.org/160458 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/bookmark_bar_view_test.cc77
1 files changed, 77 insertions, 0 deletions
diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc
index 8313920..b334549 100644
--- a/chrome/browser/views/bookmark_bar_view_test.cc
+++ b/chrome/browser/views/bookmark_bar_view_test.cc
@@ -975,3 +975,80 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
};
VIEW_TEST(BookmarkBarViewTest12, CloseWithModalDialog)
+
+// Tests clicking on the separator of a context menu (this is for coverage of
+// bug 17862).
+class BookmarkBarViewTest13 : 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, &BookmarkBarViewTest13::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, &BookmarkBarViewTest13::Step3));
+ }
+
+ void Step3() {
+ // Make sure the context menu is showing.
+ views::MenuItemView* menu = bb_view_->GetContextMenu();
+ ASSERT_TRUE(menu != NULL);
+ ASSERT_TRUE(menu->GetSubmenu());
+ ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
+
+ // Find the first separator.
+ views::SubmenuView* submenu = menu->GetSubmenu();
+ views::View* separator_view = NULL;
+ for (int i = 0; i < submenu->GetChildViewCount(); ++i) {
+ if (submenu->GetChildViewAt(i)->GetID() !=
+ views::MenuItemView::kMenuItemViewID) {
+ separator_view = submenu->GetChildViewAt(i);
+ break;
+ }
+ }
+ ASSERT_TRUE(separator_view);
+
+ // Click on the separator. Clicking on the separator shouldn't visually
+ // change anything.
+ ui_controls::MoveMouseToCenterAndPress(separator_view,
+ ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
+ CreateEventTask(this, &BookmarkBarViewTest13::Step4));
+ }
+
+ void Step4() {
+ // The context menu should still be showing.
+ views::MenuItemView* menu = bb_view_->GetContextMenu();
+ ASSERT_TRUE(menu != NULL);
+ ASSERT_TRUE(menu->GetSubmenu());
+ ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
+
+ // Select the first context menu item.
+ ui_controls::MoveMouseToCenterAndPress(menu->GetSubmenu()->GetMenuItemAt(0),
+ ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
+ CreateEventTask(this, &BookmarkBarViewTest13::Step5));
+ }
+
+ void Step5() {
+ DLOG(WARNING) << " DONE";
+ Done();
+ }
+};
+
+VIEW_TEST(BookmarkBarViewTest13, ClickOnContextMenuSeparator)