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

Unified Diff: chrome/browser/views/bookmark_bar_view_test.cc

Issue 160458: Fixes possible crash in bookmark menus. Specifically if you had a menu... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | views/controls/menu/chrome_menu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/bookmark_bar_view_test.cc
===================================================================
--- chrome/browser/views/bookmark_bar_view_test.cc (revision 22055)
+++ chrome/browser/views/bookmark_bar_view_test.cc (working copy)
@@ -975,3 +975,80 @@
};
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)
« no previous file with comments | « no previous file | views/controls/menu/chrome_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698