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

Side by Side Diff: chrome/browser/ui/views/menu_controller_interactive_uitest.cc

Issue 168033003: Pass in correct parameter to MenuController::SelectByChar() on Linux Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix BookmarkBarViewTest10.KeyEvents Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/menu_controller_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/ui/views/menu_test_base.h"
7 #include "ui/views/controls/menu/menu_item_view.h"
8 #include "ui/views/controls/menu/submenu_view.h"
9
10 template<ui::KeyboardCode KEYCODE, int EXPECTED_COMMAND>
11 class MenuControllerMnemonicTest : public MenuTestBase {
12 public:
13 MenuControllerMnemonicTest() {
14 }
15
16 virtual ~MenuControllerMnemonicTest() {
17 }
18
19 // MenuTestBase overrides:
20 virtual void BuildMenu(views::MenuItemView* menu) OVERRIDE {
21 ASSERT_NE(ui::VKEY_DIVIDE, '/');
22 menu->AppendMenuItemWithLabel(1, base::ASCIIToUTF16("One&/"));
23 menu->AppendMenuItemWithLabel(2, base::ASCIIToUTF16("Two"));
24 }
25
26 virtual void DoTestWithMenuOpen() {
27 ASSERT_TRUE(menu()->GetSubmenu()->IsShowing());
28 KeyPress(KEYCODE,
29 CreateEventTask(this, &MenuControllerMnemonicTest::Step2));
30 }
31
32 void Step2() {
33 ASSERT_EQ(EXPECTED_COMMAND, last_command());
34 if (EXPECTED_COMMAND == 0) {
35 KeyPress(ui::VKEY_ESCAPE,
36 CreateEventTask(this, &MenuControllerMnemonicTest::Step3));
37 } else {
38 ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
39 Done();
40 }
41 }
42
43 void Step3() {
44 ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
45 Done();
46 }
47
48 private:
49 DISALLOW_COPY_AND_ASSIGN(MenuControllerMnemonicTest);
50 };
51
52 // Pressing the mnemonic for a menu item should execute the command for that
53 // menu item.
54 typedef MenuControllerMnemonicTest<ui::VKEY_DIVIDE,1>
55 MenuControllerMnemonicTestMnemonicMatch;
56 VIEW_TEST(MenuControllerMnemonicTestMnemonicMatch, MnemonicMatch);
57
58 // Pressing a key which matches the first letter of the menu item's title
59 // should execute the command for that menu item.
60 typedef MenuControllerMnemonicTest<ui::VKEY_T,2>
61 MenuControllerMnemonicTestTitleMatch;
62 VIEW_TEST(MenuControllerMnemonicTestTitleMatch, TitleMatch);
63
64 // Pressing an arbitrary key should not execute any commands.
65 typedef MenuControllerMnemonicTest<ui::VKEY_A,0>
66 MenuControllerMnemonicTestNoMatch;
67 VIEW_TEST(MenuControllerMnemonicTestNoMatch, NoMatch);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/menu_controller_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698