| OLD | NEW |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 rootNode = document.createElement('bookmarks-folder-node'); | 65 rootNode = document.createElement('bookmarks-folder-node'); |
| 66 rootNode.itemId = '0'; | 66 rootNode.itemId = '0'; |
| 67 rootNode.depth = -1; | 67 rootNode.depth = -1; |
| 68 replaceBody(rootNode); | 68 replaceBody(rootNode); |
| 69 Polymer.dom.flush(); | 69 Polymer.dom.flush(); |
| 70 }); | 70 }); |
| 71 | 71 |
| 72 test('keyboard selection', function() { | 72 test('keyboard selection', function() { |
| 73 function assertFocused(oldFocus, newFocus) { | 73 function assertFocused(oldFocus, newFocus) { |
| 74 assertEquals( | 74 assertEquals( |
| 75 '', getFolderNode(oldFocus).$.container.getAttribute('tabindex')); | 75 '-1', getFolderNode(oldFocus).$.container.getAttribute('tabindex')); |
| 76 assertEquals( | 76 assertEquals( |
| 77 '0', getFolderNode(newFocus).$.container.getAttribute('tabindex')); | 77 '0', getFolderNode(newFocus).$.container.getAttribute('tabindex')); |
| 78 assertEquals( | 78 assertEquals( |
| 79 getFolderNode(newFocus).$.container, | 79 getFolderNode(newFocus).$.container, |
| 80 getFolderNode(newFocus).root.activeElement); | 80 getFolderNode(newFocus).root.activeElement); |
| 81 } | 81 } |
| 82 | 82 |
| 83 store.data.closedFolders = new Set('2'); | 83 store.data.closedFolders = new Set('2'); |
| 84 store.notifyObservers(); | 84 store.notifyObservers(); |
| 85 | 85 |
| 86 // The selected folder is focus enabled on attach. | 86 // The selected folder is focus enabled on attach. |
| 87 assertEquals( | 87 assertEquals( |
| 88 '0', getFolderNode('1').$.container.getAttribute('tabindex')); | 88 '0', getFolderNode('1').$.container.getAttribute('tabindex')); |
| 89 | 89 |
| 90 // Only the selected folder should be focusable. | 90 // Only the selected folder should be keyboard focusable. |
| 91 assertEquals('', getFolderNode('2').$.container.getAttribute('tabindex')); | 91 assertEquals( |
| 92 '-1', getFolderNode('2').$.container.getAttribute('tabindex')); |
| 92 | 93 |
| 93 // Give keyboard focus to the first item. | 94 // Give keyboard focus to the first item. |
| 94 getFolderNode('1').$.container.focus(); | 95 getFolderNode('1').$.container.focus(); |
| 95 | 96 |
| 96 // Move down into child. | 97 // Move down into child. |
| 97 keydown('1', 'ArrowDown'); | 98 keydown('1', 'ArrowDown'); |
| 98 | 99 |
| 99 assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); | 100 assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); |
| 100 store.data.selectedFolder = '2'; | 101 store.data.selectedFolder = '2'; |
| 101 store.notifyObservers(); | 102 store.notifyObservers(); |
| 102 | 103 |
| 103 assertEquals('', getFolderNode('1').$.container.getAttribute('tabindex')); | 104 assertEquals( |
| 105 '-1', getFolderNode('1').$.container.getAttribute('tabindex')); |
| 104 assertEquals( | 106 assertEquals( |
| 105 '0', getFolderNode('2').$.container.getAttribute('tabindex')); | 107 '0', getFolderNode('2').$.container.getAttribute('tabindex')); |
| 106 assertFocused('1', '2'); | 108 assertFocused('1', '2'); |
| 107 | 109 |
| 108 // Move down past closed folders. | 110 // Move down past closed folders. |
| 109 keydown('2', 'ArrowDown'); | 111 keydown('2', 'ArrowDown'); |
| 110 assertDeepEquals(bookmarks.actions.selectFolder('7'), store.lastAction); | 112 assertDeepEquals(bookmarks.actions.selectFolder('7'), store.lastAction); |
| 111 assertFocused('2', '7'); | 113 assertFocused('2', '7'); |
| 112 | 114 |
| 113 // Move down past end of list. | 115 // Move down past end of list. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 343 |
| 342 keydown(focusedItem, 'ArrowDown', ['ctrl', 'shift']); | 344 keydown(focusedItem, 'ArrowDown', ['ctrl', 'shift']); |
| 343 focusedItem = items[3]; | 345 focusedItem = items[3]; |
| 344 assertDeepEquals( | 346 assertDeepEquals( |
| 345 ['2', '4', '5', '6'], normalizeSet(store.data.selection.items)); | 347 ['2', '4', '5', '6'], normalizeSet(store.data.selection.items)); |
| 346 }); | 348 }); |
| 347 }); | 349 }); |
| 348 | 350 |
| 349 mocha.run(); | 351 mocha.run(); |
| 350 }); | 352 }); |
| OLD | NEW |