| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/ui/views/menu_test_base.h" | 6 #include "chrome/browser/ui/views/menu_test_base.h" |
| 7 #include "ui/views/controls/menu/menu_item_view.h" | 7 #include "ui/views/controls/menu/menu_item_view.h" |
| 8 #include "ui/views/controls/menu/submenu_view.h" | 8 #include "ui/views/controls/menu/submenu_view.h" |
| 9 | 9 |
| 10 template<ui::KeyboardCode KEYCODE, int EXPECTED_COMMAND> | 10 template<ui::KeyboardCode KEYCODE, int EXPECTED_COMMAND> |
| 11 class MenuControllerMnemonicTest : public MenuTestBase { | 11 class MenuControllerMnemonicTest : public MenuTestBase { |
| 12 public: | 12 public: |
| 13 MenuControllerMnemonicTest() { | 13 MenuControllerMnemonicTest() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 virtual ~MenuControllerMnemonicTest() { | 16 ~MenuControllerMnemonicTest() override {} |
| 17 } | |
| 18 | 17 |
| 19 // MenuTestBase overrides: | 18 // MenuTestBase overrides: |
| 20 virtual void BuildMenu(views::MenuItemView* menu) override { | 19 void BuildMenu(views::MenuItemView* menu) override { |
| 21 ASSERT_NE(ui::VKEY_DIVIDE, '/'); | 20 ASSERT_NE(ui::VKEY_DIVIDE, '/'); |
| 22 menu->AppendMenuItemWithLabel(1, base::ASCIIToUTF16("One&/")); | 21 menu->AppendMenuItemWithLabel(1, base::ASCIIToUTF16("One&/")); |
| 23 menu->AppendMenuItemWithLabel(2, base::ASCIIToUTF16("Two")); | 22 menu->AppendMenuItemWithLabel(2, base::ASCIIToUTF16("Two")); |
| 24 } | 23 } |
| 25 | 24 |
| 26 virtual void DoTestWithMenuOpen() { | 25 void DoTestWithMenuOpen() override { |
| 27 ASSERT_TRUE(menu()->GetSubmenu()->IsShowing()); | 26 ASSERT_TRUE(menu()->GetSubmenu()->IsShowing()); |
| 28 KeyPress(KEYCODE, | 27 KeyPress(KEYCODE, |
| 29 CreateEventTask(this, &MenuControllerMnemonicTest::Step2)); | 28 CreateEventTask(this, &MenuControllerMnemonicTest::Step2)); |
| 30 } | 29 } |
| 31 | 30 |
| 32 void Step2() { | 31 void Step2() { |
| 33 ASSERT_EQ(EXPECTED_COMMAND, last_command()); | 32 ASSERT_EQ(EXPECTED_COMMAND, last_command()); |
| 34 if (EXPECTED_COMMAND == 0) { | 33 if (EXPECTED_COMMAND == 0) { |
| 35 KeyPress(ui::VKEY_ESCAPE, | 34 KeyPress(ui::VKEY_ESCAPE, |
| 36 CreateEventTask(this, &MenuControllerMnemonicTest::Step3)); | 35 CreateEventTask(this, &MenuControllerMnemonicTest::Step3)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 // Pressing a key which matches the first letter of the menu item's title | 57 // Pressing a key which matches the first letter of the menu item's title |
| 59 // should execute the command for that menu item. | 58 // should execute the command for that menu item. |
| 60 typedef MenuControllerMnemonicTest<ui::VKEY_T, 2> | 59 typedef MenuControllerMnemonicTest<ui::VKEY_T, 2> |
| 61 MenuControllerMnemonicTestTitleMatch; | 60 MenuControllerMnemonicTestTitleMatch; |
| 62 VIEW_TEST(MenuControllerMnemonicTestTitleMatch, TitleMatch); | 61 VIEW_TEST(MenuControllerMnemonicTestTitleMatch, TitleMatch); |
| 63 | 62 |
| 64 // Pressing an arbitrary key should not execute any commands. | 63 // Pressing an arbitrary key should not execute any commands. |
| 65 typedef MenuControllerMnemonicTest<ui::VKEY_A, 0> | 64 typedef MenuControllerMnemonicTest<ui::VKEY_A, 0> |
| 66 MenuControllerMnemonicTestNoMatch; | 65 MenuControllerMnemonicTestNoMatch; |
| 67 VIEW_TEST(MenuControllerMnemonicTestNoMatch, NoMatch); | 66 VIEW_TEST(MenuControllerMnemonicTestNoMatch, NoMatch); |
| OLD | NEW |