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

Side by Side Diff: chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js

Issue 2929053004: MD Bookmarks: Make shortcuts for select all/deselect all global (Closed)
Patch Set: Fix test flub Created 3 years, 6 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
« no previous file with comments | « chrome/browser/resources/md_bookmarks/list.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 /** 5 /**
6 * @fileoverview Tests for MD Bookmarks which are run as interactive ui tests. 6 * @fileoverview Tests for MD Bookmarks which are run as interactive ui tests.
7 * Should be used for tests which care about focus. 7 * Should be used for tests which care about focus.
8 */ 8 */
9 9
10 var ROOT_PATH = '../../../../../'; 10 var ROOT_PATH = '../../../../../';
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 keydown('2', 'Delete'); 195 keydown('2', 'Delete');
196 196
197 commandManager.assertLastCommand(Command.DELETE, ['2']); 197 commandManager.assertLastCommand(Command.DELETE, ['2']);
198 }); 198 });
199 }); 199 });
200 200
201 suite('<bookmarks-list>', function() { 201 suite('<bookmarks-list>', function() {
202 var list; 202 var list;
203 var store; 203 var store;
204 var items; 204 var items;
205 var commandManager;
205 var multiKey = cr.isMac ? 'meta' : 'ctrl'; 206 var multiKey = cr.isMac ? 'meta' : 'ctrl';
206 207
207 function keydown(item, key, modifiers) { 208 function keydown(item, key, modifiers) {
208 MockInteractions.keyDownOn(item, '', modifiers, key); 209 MockInteractions.keyDownOn(item, '', modifiers, key);
209 } 210 }
210 211
211 setup(function() { 212 setup(function() {
212 store = new bookmarks.TestStore({ 213 store = new bookmarks.TestStore({
213 nodes: testTree(createFolder( 214 nodes: testTree(createFolder(
214 '1', 215 '1',
(...skipping 10 matching lines...) Expand all
225 store.setReducersEnabled(true); 226 store.setReducersEnabled(true);
226 store.replaceSingleton(); 227 store.replaceSingleton();
227 228
228 list = document.createElement('bookmarks-list'); 229 list = document.createElement('bookmarks-list');
229 list.style.height = '100%'; 230 list.style.height = '100%';
230 list.style.width = '100%'; 231 list.style.width = '100%';
231 list.style.position = 'absolute'; 232 list.style.position = 'absolute';
232 replaceBody(list); 233 replaceBody(list);
233 Polymer.dom.flush(); 234 Polymer.dom.flush();
234 items = list.root.querySelectorAll('bookmarks-item'); 235 items = list.root.querySelectorAll('bookmarks-item');
236
237 commandManager = new TestCommandManager();
238 document.body.appendChild(commandManager);
235 }); 239 });
236 240
237 test('simple keyboard selection', function() { 241 test('simple keyboard selection', function() {
238 var focusedItem = items[0]; 242 var focusedItem = items[0];
239 assertEquals('0', focusedItem.getAttribute('tabindex')); 243 assertEquals('0', focusedItem.getAttribute('tabindex'));
240 assertEquals( 244 assertEquals(
241 '0', focusedItem.$$('.more-vert-button').getAttribute('tabindex')); 245 '0', focusedItem.$$('.more-vert-button').getAttribute('tabindex'));
242 focusedItem.focus(); 246 focusedItem.focus();
243 247
244 keydown(focusedItem, 'ArrowDown'); 248 keydown(focusedItem, 'ArrowDown');
(...skipping 24 matching lines...) Expand all
269 assertDeepEquals(['2'], normalizeSet(store.data.selection.items)); 273 assertDeepEquals(['2'], normalizeSet(store.data.selection.items));
270 274
271 // Moving past the start of the list is a no-op. 275 // Moving past the start of the list is a no-op.
272 keydown(focusedItem, 'ArrowUp'); 276 keydown(focusedItem, 'ArrowUp');
273 assertEquals('0', focusedItem.getAttribute('tabindex')); 277 assertEquals('0', focusedItem.getAttribute('tabindex'));
274 assertDeepEquals(['2'], normalizeSet(store.data.selection.items)); 278 assertDeepEquals(['2'], normalizeSet(store.data.selection.items));
275 279
276 keydown(focusedItem, 'Escape'); 280 keydown(focusedItem, 'Escape');
277 assertDeepEquals([], normalizeSet(store.data.selection.items)); 281 assertDeepEquals([], normalizeSet(store.data.selection.items));
278 282
279 keydown(focusedItem, 'a', 'ctrl'); 283 keydown(focusedItem, 'a', multiKey);
280 assertDeepEquals( 284 assertDeepEquals(
281 ['2', '3', '4', '5', '6', '7'], 285 ['2', '3', '4', '5', '6', '7'],
282 normalizeSet(store.data.selection.items)); 286 normalizeSet(store.data.selection.items));
283 }); 287 });
284 288
285 test('shift selection', function() { 289 test('shift selection', function() {
286 var focusedItem = items[0]; 290 var focusedItem = items[0];
287 focusedItem.focus(); 291 focusedItem.focus();
288 292
289 keydown(focusedItem, 'ArrowDown', 'shift'); 293 keydown(focusedItem, 'ArrowDown', 'shift');
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 assertDeepEquals( 363 assertDeepEquals(
360 ['2', '4', '5'], normalizeSet(store.data.selection.items)); 364 ['2', '4', '5'], normalizeSet(store.data.selection.items));
361 365
362 keydown(focusedItem, 'ArrowDown', ['ctrl', 'shift']); 366 keydown(focusedItem, 'ArrowDown', ['ctrl', 'shift']);
363 focusedItem = items[3]; 367 focusedItem = items[3];
364 assertDeepEquals( 368 assertDeepEquals(
365 ['2', '4', '5', '6'], normalizeSet(store.data.selection.items)); 369 ['2', '4', '5', '6'], normalizeSet(store.data.selection.items));
366 }); 370 });
367 371
368 test('keyboard commands are passed to command manager', function() { 372 test('keyboard commands are passed to command manager', function() {
369 var commandManager = new TestCommandManager();
370 document.body.appendChild(commandManager);
371 chrome.bookmarkManagerPrivate.removeTrees = function() {} 373 chrome.bookmarkManagerPrivate.removeTrees = function() {}
372 374
373 store.data.selection.items = new Set(['2', '3']); 375 store.data.selection.items = new Set(['2', '3']);
374 store.notifyObservers(); 376 store.notifyObservers();
375 377
376 var focusedItem = items[4]; 378 var focusedItem = items[4];
377 focusedItem.focus(); 379 focusedItem.focus();
378 380
379 keydown(focusedItem, 'Delete'); 381 keydown(focusedItem, 'Delete');
380 // Commands should take affect on the selection, even if something else is 382 // Commands should take affect on the selection, even if something else is
381 // focused. 383 // focused.
382 commandManager.assertLastCommand(Command.DELETE, ['2', '3']); 384 commandManager.assertLastCommand(Command.DELETE, ['2', '3']);
383 }); 385 });
384 386
385 test('iron-list does not steal focus on enter', function() { 387 test('iron-list does not steal focus on enter', function() {
386 // Iron-list attempts to focus the whole <bookmarks-item> when pressing 388 // Iron-list attempts to focus the whole <bookmarks-item> when pressing
387 // enter on the menu button. This checks that we block this behavior 389 // enter on the menu button. This checks that we block this behavior
388 // during keydown on <bookmarks-list>. 390 // during keydown on <bookmarks-list>.
389 var commandManager = new TestCommandManager();
390 document.body.appendChild(commandManager);
391
392 var button = items[0].$$('.more-vert-button'); 391 var button = items[0].$$('.more-vert-button');
393 button.focus(); 392 button.focus();
394 keydown(button, 'Enter'); 393 keydown(button, 'Enter');
395 394
396 assertEquals(button, items[0].root.activeElement); 395 assertEquals(button, items[0].root.activeElement);
397 }); 396 });
398 }); 397 });
399 398
400 mocha.run(); 399 mocha.run();
401 }); 400 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/list.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698