Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / menu_controller_interactive_uitest.cc
bloba49aaa80ed4c57f8560cc83713f96fde7745601b
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.
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"
10 template<ui::KeyboardCode KEYCODE, int EXPECTED_COMMAND>
11 class MenuControllerMnemonicTest : public MenuTestBase {
12 public:
13 MenuControllerMnemonicTest() {
16 virtual ~MenuControllerMnemonicTest() {
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"));
26 void DoTestWithMenuOpen() override {
27 ASSERT_TRUE(menu()->GetSubmenu()->IsShowing());
28 KeyPress(KEYCODE,
29 CreateEventTask(this, &MenuControllerMnemonicTest::Step2));
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();
43 void Step3() {
44 ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
45 Done();
48 private:
49 DISALLOW_COPY_AND_ASSIGN(MenuControllerMnemonicTest);
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;
57 #if defined(USE_OZONE)
58 // ozone bringup - http://crbug.com/401304
59 #define MAYBE_MnemonicMatch DISABLED_MnemonicMatch
60 #else
61 #define MAYBE_MnemonicMatch MnemonicMatch
62 #endif
64 VIEW_TEST(MenuControllerMnemonicTestMnemonicMatch, MAYBE_MnemonicMatch);
66 // Pressing a key which matches the first letter of the menu item's title
67 // should execute the command for that menu item.
68 typedef MenuControllerMnemonicTest<ui::VKEY_T,2>
69 MenuControllerMnemonicTestTitleMatch;
71 #if defined(USE_OZONE)
72 // ozone bringup - http://crbug.com/401304
73 #define MAYBE_TitleMatch DISABLED_TitleMatch
74 #else
75 #define MAYBE_TitleMatch TitleMatch
76 #endif
78 VIEW_TEST(MenuControllerMnemonicTestTitleMatch, MAYBE_TitleMatch);
80 // Pressing an arbitrary key should not execute any commands.
81 typedef MenuControllerMnemonicTest<ui::VKEY_A,0>
82 MenuControllerMnemonicTestNoMatch;
84 #if defined(USE_OZONE)
85 // ozone bringup - http://crbug.com/401304
86 #define MAYBE_NoMatch DISABLED_NoMatch
87 #else
88 #define MAYBE_NoMatch NoMatch
89 #endif
91 VIEW_TEST(MenuControllerMnemonicTestNoMatch, MAYBE_NoMatch);