| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 rootNode = document.createElement('bookmarks-folder-node'); | 66 rootNode = document.createElement('bookmarks-folder-node'); |
| 67 rootNode.itemId = '0'; | 67 rootNode.itemId = '0'; |
| 68 rootNode.depth = -1; | 68 rootNode.depth = -1; |
| 69 replaceBody(rootNode); | 69 replaceBody(rootNode); |
| 70 Polymer.dom.flush(); | 70 Polymer.dom.flush(); |
| 71 }); | 71 }); |
| 72 | 72 |
| 73 test('keyboard selection', function() { | 73 test('keyboard selection', function() { |
| 74 function assertFocused(oldFocus, newFocus) { | 74 function assertFocused(oldFocus, newFocus) { |
| 75 assertEquals( | 75 assertEquals( |
| 76 '', getFolderNode(oldFocus).$.container.getAttribute('tabindex')); | 76 '-1', getFolderNode(oldFocus).$.container.getAttribute('tabindex')); |
| 77 assertEquals( | 77 assertEquals( |
| 78 '0', getFolderNode(newFocus).$.container.getAttribute('tabindex')); | 78 '0', getFolderNode(newFocus).$.container.getAttribute('tabindex')); |
| 79 assertEquals( | 79 assertEquals( |
| 80 getFolderNode(newFocus).$.container, | 80 getFolderNode(newFocus).$.container, |
| 81 getFolderNode(newFocus).root.activeElement); | 81 getFolderNode(newFocus).root.activeElement); |
| 82 } | 82 } |
| 83 | 83 |
| 84 store.data.closedFolders = new Set('2'); | 84 store.data.closedFolders = new Set('2'); |
| 85 store.notifyObservers(); | 85 store.notifyObservers(); |
| 86 | 86 |
| 87 // The selected folder is focus enabled on attach. | 87 // The selected folder is focus enabled on attach. |
| 88 assertEquals( | 88 assertEquals( |
| 89 '0', getFolderNode('1').$.container.getAttribute('tabindex')); | 89 '0', getFolderNode('1').$.container.getAttribute('tabindex')); |
| 90 | 90 |
| 91 // Only the selected folder should be focusable. | 91 // Only the selected folder should be keyboard focusable. |
| 92 assertEquals('', getFolderNode('2').$.container.getAttribute('tabindex')); | 92 assertEquals( |
| 93 '-1', getFolderNode('2').$.container.getAttribute('tabindex')); |
| 93 | 94 |
| 94 // Give keyboard focus to the first item. | 95 // Give keyboard focus to the first item. |
| 95 getFolderNode('1').$.container.focus(); | 96 getFolderNode('1').$.container.focus(); |
| 96 | 97 |
| 97 // Move down into child. | 98 // Move down into child. |
| 98 keydown('1', 'ArrowDown'); | 99 keydown('1', 'ArrowDown'); |
| 99 | 100 |
| 100 assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); | 101 assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); |
| 101 store.data.selectedFolder = '2'; | 102 store.data.selectedFolder = '2'; |
| 102 store.notifyObservers(); | 103 store.notifyObservers(); |
| 103 | 104 |
| 104 assertEquals('', getFolderNode('1').$.container.getAttribute('tabindex')); | 105 assertEquals( |
| 106 '-1', getFolderNode('1').$.container.getAttribute('tabindex')); |
| 105 assertEquals( | 107 assertEquals( |
| 106 '0', getFolderNode('2').$.container.getAttribute('tabindex')); | 108 '0', getFolderNode('2').$.container.getAttribute('tabindex')); |
| 107 assertFocused('1', '2'); | 109 assertFocused('1', '2'); |
| 108 | 110 |
| 109 // Move down past closed folders. | 111 // Move down past closed folders. |
| 110 keydown('2', 'ArrowDown'); | 112 keydown('2', 'ArrowDown'); |
| 111 assertDeepEquals(bookmarks.actions.selectFolder('7'), store.lastAction); | 113 assertDeepEquals(bookmarks.actions.selectFolder('7'), store.lastAction); |
| 112 assertFocused('2', '7'); | 114 assertFocused('2', '7'); |
| 113 | 115 |
| 114 // Move down past end of list. | 116 // Move down past end of list. |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 var button = items[0].$$('.more-vert-button'); | 391 var button = items[0].$$('.more-vert-button'); |
| 390 button.focus(); | 392 button.focus(); |
| 391 keydown(button, 'Enter'); | 393 keydown(button, 'Enter'); |
| 392 | 394 |
| 393 assertEquals(button, items[0].root.activeElement); | 395 assertEquals(button, items[0].root.activeElement); |
| 394 }); | 396 }); |
| 395 }); | 397 }); |
| 396 | 398 |
| 397 mocha.run(); | 399 mocha.run(); |
| 398 }); | 400 }); |
| OLD | NEW |