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

Side by Side 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 unified diff | Download patch
OLDNEW
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>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MenuControllerMnemonicTestNoMatch; 82 MenuControllerMnemonicTestNoMatch;
83 83
84 #if defined(USE_OZONE) 84 #if defined(USE_OZONE)
85 // ozone bringup - http://crbug.com/401304 85 // ozone bringup - http://crbug.com/401304
86 #define MAYBE_NoMatch DISABLED_NoMatch 86 #define MAYBE_NoMatch DISABLED_NoMatch
87 #else 87 #else
88 #define MAYBE_NoMatch NoMatch 88 #define MAYBE_NoMatch NoMatch
89 #endif 89 #endif
90 90
91 VIEW_TEST(MenuControllerMnemonicTestNoMatch, MAYBE_NoMatch); 91 VIEW_TEST(MenuControllerMnemonicTestNoMatch, MAYBE_NoMatch);
92
93 template<ui::KeyboardCode KEYCODE, int COUNT, int EXPECTED_COMMAND>
94 class MenuControllerSelectionTest : public MenuTestBase {
95 public:
96 MenuControllerSelectionTest() {
97 }
98
99 ~MenuControllerSelectionTest() override {
100 }
101
102 // MenuTestBase overrides:
103 void BuildMenu(views::MenuItemView* menu) override {
104 menu->AppendMenuItemWithLabel(1, base::ASCIIToUTF16("One"));
105 menu->AppendMenuItemWithLabel(2, base::ASCIIToUTF16("Two"));
106 menu->AppendMenuItemWithLabel(3, base::ASCIIToUTF16("Three"));
107 menu->AppendMenuItemWithLabel(4, base::ASCIIToUTF16("Four"));
108 // Disabling the item "Two" gets it skipped when using keyboard to navigate.
109 menu->GetSubmenu()->GetMenuItemAt(1)->SetEnabled(false);
110 }
111
112 void DoTestWithMenuOpen() override {
113 ASSERT_TRUE(menu()->GetSubmenu()->IsShowing());
114 KeyPress(KEYCODE,
115 CreateEventTask(base::Bind(&MenuControllerSelectionTest::Step2,
116 this,
117 COUNT)));
118 }
119
120 void Step2(int count) {
121 if (--count) {
122 KeyPress(KEYCODE,
123 CreateEventTask(base::Bind(&MenuControllerSelectionTest::Step2,
124 this,
125 count)));
126 return;
127 }
128 KeyPress(ui::VKEY_RETURN,
129 CreateEventTask(this, &MenuControllerSelectionTest::Step3));
130 }
131
132 void Step3() {
133 ASSERT_EQ(EXPECTED_COMMAND, last_command());
134 ASSERT_FALSE(menu()->GetSubmenu()->IsShowing());
135 Done();
136 }
137
138 private:
139 DISALLOW_COPY_AND_ASSIGN(MenuControllerSelectionTest);
140 };
141
142 #if defined(USE_OZONE)
143 // ozone bringup - http://crbug.com/401304
144 #define MAYBE_SelectItem DISABLED_SelectItem
145 #else
146 #define MAYBE_SelectItem SelectItem
147 #endif
148
149 // Pressing DOWN once will activate the first item.
150 typedef MenuControllerSelectionTest<ui::VKEY_DOWN,1,1>
151 MenuControllerSelectionTestMatchDown1;
152 VIEW_TEST(MenuControllerSelectionTestMatchDown1, MAYBE_SelectItem);
153
154 // Pressing DOWN twice will skip the disabled item and activate the third.
155 typedef MenuControllerSelectionTest<ui::VKEY_DOWN,2,3>
156 MenuControllerSelectionTestMatchDown2;
157 VIEW_TEST(MenuControllerSelectionTestMatchDown2, MAYBE_SelectItem);
158
159 // Pressing DOWN three times will activate the forth item.
160 typedef MenuControllerSelectionTest<ui::VKEY_DOWN,3,4>
161 MenuControllerSelectionTestMatchDown3;
162 VIEW_TEST(MenuControllerSelectionTestMatchDown3, MAYBE_SelectItem);
163
164 // Pressing DOWN four times will wrap around and activate the first item.
165 typedef MenuControllerSelectionTest<ui::VKEY_DOWN,4,1>
166 MenuControllerSelectionTestMatchDown4;
167 VIEW_TEST(MenuControllerSelectionTestMatchDown4, MAYBE_SelectItem);
168
169 // Pressing UP once will activate the first item.
170 typedef MenuControllerSelectionTest<ui::VKEY_UP,1,1>
171 MenuControllerSelectionTestMatchUp1;
172 VIEW_TEST(MenuControllerSelectionTestMatchUp1, MAYBE_SelectItem);
173
174 // Pressing UP twice will wrap around and activate the fourth item.
175 typedef MenuControllerSelectionTest<ui::VKEY_UP,2,4>
176 MenuControllerSelectionTestMatchUp2;
177 VIEW_TEST(MenuControllerSelectionTestMatchUp2, MAYBE_SelectItem);
178
179 // Pressing UP three times will wrap around and activate the third item.
180 typedef MenuControllerSelectionTest<ui::VKEY_UP,3,3>
181 MenuControllerSelectionTestMatchUp3;
182 VIEW_TEST(MenuControllerSelectionTestMatchUp3, MAYBE_SelectItem);
183
184 // Pressing UP four times will skip the disabled item and activate the first.
185 typedef MenuControllerSelectionTest<ui::VKEY_UP,4,1>
186 MenuControllerSelectionTestMatchUp4;
187 VIEW_TEST(MenuControllerSelectionTestMatchUp4, MAYBE_SelectItem);
OLDNEW
« 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