Index: chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js |
diff --git a/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js b/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js |
index e70c1568ce8542c300cfebb9590cc80541f7b530..5a47986634e50eb287bb28b3d13727b60fc07093 100644 |
--- a/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js |
+++ b/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js |
@@ -97,6 +97,12 @@ TEST_F('MaterialBookmarksFocusTest', 'All', function() { |
keydown('1', 'ArrowDown'); |
assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); |
+ store.data.selectedFolder = '2'; |
+ store.notifyObservers(); |
+ |
+ assertEquals('', getFolderNode('1').$.container.getAttribute('tabindex')); |
+ assertEquals( |
+ '0', getFolderNode('2').$.container.getAttribute('tabindex')); |
assertFocused('1', '2'); |
// Move down past closed folders. |
@@ -124,6 +130,54 @@ TEST_F('MaterialBookmarksFocusTest', 'All', function() { |
keydown('1', 'ArrowUp'); |
assertDeepEquals(null, store.lastAction); |
}); |
+ |
+ test('keyboard left/right', function() { |
+ function keydown(id, key) { |
tsergeant
2017/05/05 01:31:07
There's already a keydown function above (line 41)
calamity
2017/05/09 03:45:35
Done. Forgot to clean this up after rebase.
|
+ var container = getFolderNode(id).$.container; |
+ MockInteractions.keyDownOn(container, '', [], key); |
+ } |
+ |
+ store.data.closedFolders = new Set('2'); |
+ store.notifyObservers(); |
+ |
+ // The selected folder is focus enabled on attach. |
tsergeant
2017/05/05 01:31:07
Is there a particular reason to repeat these two a
calamity
2017/05/09 03:45:35
Done.
|
+ assertEquals( |
+ '0', getFolderNode('1').$.container.getAttribute('tabindex')); |
+ |
+ // Only the selected folder should be focusable. |
+ assertEquals('', getFolderNode('2').$.container.getAttribute('tabindex')); |
+ |
+ // Give keyboard focus to the first item. |
+ getFolderNode('1').$.container.focus(); |
+ |
+ // Pressing right descends into first child. |
+ keydown('1', 'ArrowRight'); |
+ assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); |
+ |
+ // Pressing right on a closed folder opens that folder |
+ keydown('2', 'ArrowRight'); |
+ assertDeepEquals( |
+ bookmarks.actions.changeFolderOpen('2', true), store.lastAction); |
+ |
+ // Pressing right again descends into first child. |
+ keydown('2', 'ArrowRight'); |
+ assertDeepEquals(bookmarks.actions.selectFolder('3'), store.lastAction); |
+ |
+ // Pressing right on a folder with no children does nothing. |
+ store.resetLastAction(); |
+ keydown('3', 'ArrowRight'); |
+ assertDeepEquals(null, store.lastAction); |
+ |
+ // Pressing left on a folder with no children ascends to parent. |
+ keydown('3', 'ArrowDown'); |
+ keydown('4', 'ArrowLeft'); |
+ assertDeepEquals(bookmarks.actions.selectFolder('2'), store.lastAction); |
+ |
+ // Pressing left again closes the parent. |
+ keydown('2', 'ArrowLeft'); |
+ assertDeepEquals( |
+ bookmarks.actions.changeFolderOpen('2', false), store.lastAction); |
+ }); |
}); |
mocha.run(); |