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

Unified Diff: chrome/browser/ui/views/menu_controller_interactive_uitest.cc

Issue 1129203003: Skips disabled menu items when selection is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Skips disabled menu items when selection is changed (test) Created 5 years, 7 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/test/base/view_event_test_base.h » ('j') | chrome/test/base/view_event_test_base.h » ('J')
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
index 05c4c2399b2ccb0e79ddbb49df53ef2429e1dc66..aaa45c36fff999761d382ebf2d0d68a05d3c5ce4 100644
--- a/chrome/browser/ui/views/menu_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/menu_controller_interactive_uitest.cc
@@ -89,3 +89,99 @@ typedef MenuControllerMnemonicTest<ui::VKEY_A,0>
#endif
VIEW_TEST(MenuControllerMnemonicTestNoMatch, MAYBE_NoMatch);
+
+template<ui::KeyboardCode KEYCODE, int COUNT, int EXPECTED_COMMAND>
+class MenuControllerSelectionTest : public MenuTestBase {
+ public:
+ MenuControllerSelectionTest() {
+ }
+
+ ~MenuControllerSelectionTest() override {
+ }
+
+ // MenuTestBase overrides:
+ void BuildMenu(views::MenuItemView* menu) override {
+ menu->AppendMenuItemWithLabel(1, base::ASCIIToUTF16("One"));
+ menu->AppendMenuItemWithLabel(2, base::ASCIIToUTF16("Two"));
+ menu->AppendMenuItemWithLabel(3, base::ASCIIToUTF16("Three"));
+ menu->AppendMenuItemWithLabel(4, base::ASCIIToUTF16("Four"));
+ // Disabling the item "Two" gets it skipped when using keyboard to navigate.
+ menu->GetSubmenu()->GetMenuItemAt(1)->SetEnabled(false);
+ }
+
+ void DoTestWithMenuOpen() override {
+ ASSERT_TRUE(menu()->GetSubmenu()->IsShowing());
+ KeyPress(KEYCODE,
+ CreateEventTask(base::Bind(&MenuControllerSelectionTest::Step2,
+ this,
+ COUNT)));
+ }
+
+ void Step2(int count) {
+ if (--count) {
+ KeyPress(KEYCODE,
+ CreateEventTask(base::Bind(&MenuControllerSelectionTest::Step2,
+ this,
+ count)));
+ return;
+ }
+ KeyPress(ui::VKEY_RETURN,
+ CreateEventTask(this, &MenuControllerSelectionTest::Step3));
+ }
+
+ void Step3() {
+ ASSERT_EQ(EXPECTED_COMMAND, last_command());
+ ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
+ Done();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MenuControllerSelectionTest);
+};
+
+#if defined(USE_OZONE)
+// ozone bringup - http://crbug.com/401304
+#define MAYBE_SelectItem DISABLED_SelectItem
+#else
+#define MAYBE_SelectItem SelectItem
+#endif
+
+// Pressing DOWN once will activate the first item.
+typedef MenuControllerSelectionTest<ui::VKEY_DOWN,1,1>
+ MenuControllerSelectionTestMatchDown1;
+VIEW_TEST(MenuControllerSelectionTestMatchDown1, MAYBE_SelectItem);
+
+// Pressing DOWN twice will skip the disabled item and activate the third.
+typedef MenuControllerSelectionTest<ui::VKEY_DOWN,2,3>
+MenuControllerSelectionTestMatchDown2;
+VIEW_TEST(MenuControllerSelectionTestMatchDown2, MAYBE_SelectItem);
+
+// Pressing DOWN three times will activate the forth item.
+typedef MenuControllerSelectionTest<ui::VKEY_DOWN,3,4>
+MenuControllerSelectionTestMatchDown3;
+VIEW_TEST(MenuControllerSelectionTestMatchDown3, MAYBE_SelectItem);
+
+// Pressing DOWN four times will wrap around and activate the first item.
+typedef MenuControllerSelectionTest<ui::VKEY_DOWN,4,1>
+MenuControllerSelectionTestMatchDown4;
+VIEW_TEST(MenuControllerSelectionTestMatchDown4, MAYBE_SelectItem);
+
+// Pressing UP once will activate the first item.
+typedef MenuControllerSelectionTest<ui::VKEY_UP,1,1>
+ MenuControllerSelectionTestMatchUp1;
+VIEW_TEST(MenuControllerSelectionTestMatchUp1, MAYBE_SelectItem);
+
+// Pressing UP twice will wrap around and activate the fourth item.
+typedef MenuControllerSelectionTest<ui::VKEY_UP,2,4>
+ MenuControllerSelectionTestMatchUp2;
+VIEW_TEST(MenuControllerSelectionTestMatchUp2, MAYBE_SelectItem);
+
+// Pressing UP three times will wrap around and activate the third item.
+typedef MenuControllerSelectionTest<ui::VKEY_UP,3,3>
+ MenuControllerSelectionTestMatchUp3;
+VIEW_TEST(MenuControllerSelectionTestMatchUp3, MAYBE_SelectItem);
+
+// Pressing UP four times will skip the disabled item and activate the first.
+typedef MenuControllerSelectionTest<ui::VKEY_UP,4,1>
+ MenuControllerSelectionTestMatchUp4;
+VIEW_TEST(MenuControllerSelectionTestMatchUp4, MAYBE_SelectItem);
« no previous file with comments | « no previous file | chrome/test/base/view_event_test_base.h » ('j') | chrome/test/base/view_event_test_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698