Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / views / menu_controller_interactive_uitest.cc
blob573c3f7791a1d6719304c95d12de5e0c79ab0c93
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 ~MenuControllerMnemonicTest() override {
19 // MenuTestBase overrides:
20 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) || defined(OS_WIN)
58 // ozone bringup - http://crbug.com/401304
59 // flaky on windows - http://crbug.com/523255
60 #define MAYBE_MnemonicMatch DISABLED_MnemonicMatch
61 #else
62 #define MAYBE_MnemonicMatch MnemonicMatch
63 #endif
65 VIEW_TEST(MenuControllerMnemonicTestMnemonicMatch, MAYBE_MnemonicMatch);
67 // Pressing a key which matches the first letter of the menu item's title
68 // should execute the command for that menu item.
69 typedef MenuControllerMnemonicTest<ui::VKEY_T,2>
70 MenuControllerMnemonicTestTitleMatch;
72 #if defined(USE_OZONE) || defined(OS_WIN)
73 // ozone bringup - http://crbug.com/401304
74 // flaky on windows - http://crbug.com/523255
75 #define MAYBE_TitleMatch DISABLED_TitleMatch
76 #else
77 #define MAYBE_TitleMatch TitleMatch
78 #endif
80 VIEW_TEST(MenuControllerMnemonicTestTitleMatch, MAYBE_TitleMatch);
82 // Pressing an arbitrary key should not execute any commands.
83 typedef MenuControllerMnemonicTest<ui::VKEY_A,0>
84 MenuControllerMnemonicTestNoMatch;
86 #if defined(USE_OZONE)
87 // ozone bringup - http://crbug.com/401304
88 #define MAYBE_NoMatch DISABLED_NoMatch
89 #else
90 #define MAYBE_NoMatch NoMatch
91 #endif
93 VIEW_TEST(MenuControllerMnemonicTestNoMatch, MAYBE_NoMatch);