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

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

Issue 1625313002: Remove MenuMessagePumpDispatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced typedef with using Created 4 years, 11 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 | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index 4aa14ae237ebf6d3a7375333577df2ced61346f4..1e2149b277132df26d0a58415e01a79f5408279c 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -53,6 +53,10 @@
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/widget/widget.h"
+#if defined(OS_WIN)
+#include "ui/aura/window_tree_host.h"
+#endif
+
using base::ASCIIToUTF16;
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
@@ -2243,3 +2247,90 @@ class BookmarkBarViewTest24 : public BookmarkBarViewEventTestBase {
#endif
VIEW_TEST(BookmarkBarViewTest24, MAYBE_ContextMenusKeyboardEscape)
+#if defined(OS_WIN)
+// Tests that pressing the key KEYCODE closes the menu.
+template <ui::KeyboardCode KEYCODE>
+class BookmarkBarViewTest25 : public BookmarkBarViewEventTestBase {
+ protected:
+ void DoTestOnMessageLoop() override {
+ // Move the mouse to the first folder on the bookmark bar and press the
+ // mouse.
+ views::LabelButton* button = GetBookmarkButton(0);
+ ui_test_utils::MoveMouseToCenterAndPress(
+ button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
+ CreateEventTask(this, &BookmarkBarViewTest25::Step2));
+ base::MessageLoop::current()->RunUntilIdle();
+ }
+
+ private:
+ void Step2() {
+ // Menu should be showing.
+ views::MenuItemView* menu = bb_view_->GetMenu();
+ ASSERT_TRUE(menu != nullptr);
+ ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
+
+ // Send KEYCODE key event, which should close the menu.
+ ASSERT_TRUE(ui_controls::SendKeyPressNotifyWhenDone(
+ window_->GetNativeWindow(), KEYCODE, false, false, false, false,
+ CreateEventTask(this, &BookmarkBarViewTest25::Step3)));
+ }
+
+ void Step3() {
+ // Make sure menu is not showing.
+ views::MenuItemView* menu = bb_view_->GetMenu();
+ ASSERT_TRUE(menu == nullptr);
+
+ Done();
+ }
+};
+
+// Tests that pressing F10 system key closes the menu.
+using BookmarkBarViewTest25F10 = BookmarkBarViewTest25<ui::VKEY_F10>;
+VIEW_TEST(BookmarkBarViewTest25F10, F10ClosesMenu);
+
+// Tests that pressing Alt system key closes the menu.
+using BookmarkBarViewTest25Alt = BookmarkBarViewTest25<ui::VKEY_MENU>;
+VIEW_TEST(BookmarkBarViewTest25Alt, AltClosesMenu);
+
+// Tests that WM_CANCELMODE closes the menu.
+class BookmarkBarViewTest26 : public BookmarkBarViewEventTestBase {
+ protected:
+ void DoTestOnMessageLoop() override {
+ // Move the mouse to the first folder on the bookmark bar and press the
+ // mouse.
+ views::LabelButton* button = GetBookmarkButton(0);
+ ui_test_utils::MoveMouseToCenterAndPress(
+ button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
+ CreateEventTask(this, &BookmarkBarViewTest26::Step2));
+ base::MessageLoop::current()->RunUntilIdle();
+ }
+
+ private:
+ void Step2() {
+ // Menu should be showing.
+ views::MenuItemView* menu = bb_view_->GetMenu();
+ ASSERT_TRUE(menu != nullptr);
+ ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
+
+ // Send WM_CANCELMODE, which should close the menu. The message is sent
+ // synchronously, however, we post a task to make sure that the message is
+ // processed completely before finishing the test.
+ ::SendMessage(
+ GetWidget()->GetNativeView()->GetHost()->GetAcceleratedWidget(),
+ WM_CANCELMODE, 0, 0);
+
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&BookmarkBarViewTest26::Step3, this));
+ }
+
+ void Step3() {
+ // Menu should not be showing anymore.
+ views::MenuItemView* menu = bb_view_->GetMenu();
+ ASSERT_TRUE(menu == nullptr);
+
+ Done();
+ }
+};
+
+VIEW_TEST(BookmarkBarViewTest26, CancelModeClosesMenu);
+#endif
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698