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

Side by Side 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: Added test for cancel mode 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "ui/aura/window.h" 46 #include "ui/aura/window.h"
47 #include "ui/base/clipboard/clipboard.h" 47 #include "ui/base/clipboard/clipboard.h"
48 #include "ui/base/test/ui_controls.h" 48 #include "ui/base/test/ui_controls.h"
49 #include "ui/events/keycodes/keyboard_codes.h" 49 #include "ui/events/keycodes/keyboard_codes.h"
50 #include "ui/views/controls/button/menu_button.h" 50 #include "ui/views/controls/button/menu_button.h"
51 #include "ui/views/controls/menu/menu_controller.h" 51 #include "ui/views/controls/menu/menu_controller.h"
52 #include "ui/views/controls/menu/menu_item_view.h" 52 #include "ui/views/controls/menu/menu_item_view.h"
53 #include "ui/views/controls/menu/submenu_view.h" 53 #include "ui/views/controls/menu/submenu_view.h"
54 #include "ui/views/widget/widget.h" 54 #include "ui/views/widget/widget.h"
55 55
56 #if defined(OS_WIN)
57 #include "ui/aura/window_tree_host.h"
58 #endif
59
56 using base::ASCIIToUTF16; 60 using base::ASCIIToUTF16;
57 using bookmarks::BookmarkModel; 61 using bookmarks::BookmarkModel;
58 using bookmarks::BookmarkNode; 62 using bookmarks::BookmarkNode;
59 using content::BrowserThread; 63 using content::BrowserThread;
60 using content::OpenURLParams; 64 using content::OpenURLParams;
61 using content::PageNavigator; 65 using content::PageNavigator;
62 using content::WebContents; 66 using content::WebContents;
63 67
64 namespace { 68 namespace {
65 69
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 }; 2240 };
2237 2241
2238 #if defined(USE_OZONE) 2242 #if defined(USE_OZONE)
2239 // ozone bringup - http://crbug.com/401304 2243 // ozone bringup - http://crbug.com/401304
2240 #define MAYBE_ContextMenusKeyboardEscape DISABLED_ContextMenusKeyboardEscape 2244 #define MAYBE_ContextMenusKeyboardEscape DISABLED_ContextMenusKeyboardEscape
2241 #else 2245 #else
2242 #define MAYBE_ContextMenusKeyboardEscape ContextMenusKeyboardEscape 2246 #define MAYBE_ContextMenusKeyboardEscape ContextMenusKeyboardEscape
2243 #endif 2247 #endif
2244 VIEW_TEST(BookmarkBarViewTest24, MAYBE_ContextMenusKeyboardEscape) 2248 VIEW_TEST(BookmarkBarViewTest24, MAYBE_ContextMenusKeyboardEscape)
2245 2249
2250 #if defined(OS_WIN)
2251 // Tests that pressing the key KEYCODE closes the menu.
2252 template <ui::KeyboardCode KEYCODE>
2253 class BookmarkBarViewTest25 : public BookmarkBarViewEventTestBase {
2254 protected:
2255 void DoTestOnMessageLoop() override {
2256 // Move the mouse to the first folder on the bookmark bar and press the
2257 // mouse.
2258 views::LabelButton* button = GetBookmarkButton(0);
2259 ui_test_utils::MoveMouseToCenterAndPress(
2260 button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
2261 CreateEventTask(this, &BookmarkBarViewTest25::Step2));
2262 base::MessageLoop::current()->RunUntilIdle();
2263 }
2264
2265 private:
2266 void Step2() {
2267 // Menu should be showing.
2268 views::MenuItemView* menu = bb_view_->GetMenu();
2269 ASSERT_TRUE(menu != nullptr);
2270 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
2271
2272 // Send KEYCODE key event, which should close the menu.
2273 ASSERT_TRUE(ui_controls::SendKeyPressNotifyWhenDone(
2274 window_->GetNativeWindow(), KEYCODE, false, false, false, false,
2275 CreateEventTask(this, &BookmarkBarViewTest25::Step3)));
2276 }
2277
2278 void Step3() {
2279 // Make sure menu is not showing.
2280 views::MenuItemView* menu = bb_view_->GetMenu();
2281 ASSERT_TRUE(menu == nullptr);
2282
2283 Done();
2284 }
2285 };
2286
2287 // Tests that pressing F10 system key closes the menu.
2288 typedef BookmarkBarViewTest25<ui::VKEY_F10> BookmarkBarViewTest25F10;
sky 2016/01/27 17:53:41 nit: using
2289 VIEW_TEST(BookmarkBarViewTest25F10, F10ClosesMenu);
2290
2291 // Tests that pressing Alt system key closes the menu.
2292 typedef BookmarkBarViewTest25<ui::VKEY_MENU> BookmarkBarViewTest25Alt;
sky 2016/01/27 17:53:41 nit: using.
2293 VIEW_TEST(BookmarkBarViewTest25Alt, AltClosesMenu);
2294
2295 // Tests that WM_CANCELMODE closes the menu.
2296 class BookmarkBarViewTest26 : public BookmarkBarViewEventTestBase {
2297 protected:
2298 void DoTestOnMessageLoop() override {
2299 // Move the mouse to the first folder on the bookmark bar and press the
2300 // mouse.
2301 views::LabelButton* button = GetBookmarkButton(0);
2302 ui_test_utils::MoveMouseToCenterAndPress(
2303 button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
2304 CreateEventTask(this, &BookmarkBarViewTest26::Step2));
2305 base::MessageLoop::current()->RunUntilIdle();
2306 }
2307
2308 private:
2309 void Step2() {
2310 // Menu should be showing.
2311 views::MenuItemView* menu = bb_view_->GetMenu();
2312 ASSERT_TRUE(menu != nullptr);
2313 ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
2314
2315 // Send WM_CANCELMODE, which should close the menu. The message is sent
2316 // synchronously, however, we post a task to make sure that the message is
2317 // processed completely before finishing the test.
2318 ::SendMessage(
2319 GetWidget()->GetNativeView()->GetHost()->GetAcceleratedWidget(),
2320 WM_CANCELMODE, 0, 0);
2321
2322 base::MessageLoop::current()->PostTask(
2323 FROM_HERE, base::Bind(&BookmarkBarViewTest26::Step3, this));
2324 }
2325
2326 void Step3() {
2327 // Menu should not be showing anymore.
2328 views::MenuItemView* menu = bb_view_->GetMenu();
2329 ASSERT_TRUE(menu == nullptr);
2330
2331 Done();
2332 }
2333 };
2334
2335 VIEW_TEST(BookmarkBarViewTest26, CancelModeClosesMenu);
2336 #endif
OLDNEW
« 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