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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/menu_controller_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/menu_controller_interactive_uitest.cc
diff --git a/chrome/browser/ui/views/menu_controller_interactive_uitest.cc b/chrome/browser/ui/views/menu_controller_interactive_uitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3d85b8487e255770caf85e188cfbdd0a6de1c5d3
--- /dev/null
+++ b/chrome/browser/ui/views/menu_controller_interactive_uitest.cc
@@ -0,0 +1,67 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/views/menu_test_base.h"
+#include "ui/views/controls/menu/menu_item_view.h"
+#include "ui/views/controls/menu/submenu_view.h"
+
+template<ui::KeyboardCode KEYCODE, int EXPECTED_COMMAND>
+class MenuControllerMnemonicTest : public MenuTestBase {
+ public:
+ MenuControllerMnemonicTest() {
+ }
+
+ virtual ~MenuControllerMnemonicTest() {
+ }
+
+ // MenuTestBase overrides:
+ virtual void BuildMenu(views::MenuItemView* menu) OVERRIDE {
+ ASSERT_NE(ui::VKEY_DIVIDE, '/');
+ menu->AppendMenuItemWithLabel(1, base::ASCIIToUTF16("One&/"));
+ menu->AppendMenuItemWithLabel(2, base::ASCIIToUTF16("Two"));
+ }
+
+ virtual void DoTestWithMenuOpen() {
+ ASSERT_TRUE(menu()->GetSubmenu()->IsShowing());
+ KeyPress(KEYCODE,
+ CreateEventTask(this, &MenuControllerMnemonicTest::Step2));
+ }
+
+ void Step2() {
+ ASSERT_EQ(EXPECTED_COMMAND, last_command());
+ if (EXPECTED_COMMAND == 0) {
+ KeyPress(ui::VKEY_ESCAPE,
+ CreateEventTask(this, &MenuControllerMnemonicTest::Step3));
+ } else {
+ ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
+ Done();
+ }
+ }
+
+ void Step3() {
+ ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
+ Done();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MenuControllerMnemonicTest);
+};
+
+// Pressing the mnemonic for a menu item should execute the command for that
+// menu item.
+typedef MenuControllerMnemonicTest<ui::VKEY_DIVIDE,1>
+ MenuControllerMnemonicTestMnemonicMatch;
+VIEW_TEST(MenuControllerMnemonicTestMnemonicMatch, MnemonicMatch);
+
+// Pressing a key which matches the first letter of the menu item's title
+// should execute the command for that menu item.
+typedef MenuControllerMnemonicTest<ui::VKEY_T,2>
+ MenuControllerMnemonicTestTitleMatch;
+VIEW_TEST(MenuControllerMnemonicTestTitleMatch, TitleMatch);
+
+// Pressing an arbitrary key should not execute any commands.
+typedef MenuControllerMnemonicTest<ui::VKEY_A,0>
+ MenuControllerMnemonicTestNoMatch;
+VIEW_TEST(MenuControllerMnemonicTestNoMatch, NoMatch);
« 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