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

Unified Diff: chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js

Issue 2857893002: [MD Bookmarks] Allow left/right keys to close/open folders in sidebar. (Closed)
Patch Set: address comments Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/md_bookmarks/folder_node.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a4eef40c843b9959bb7415d553e3f30c46872281 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,52 @@ TEST_F('MaterialBookmarksFocusTest', 'All', function() {
keydown('1', 'ArrowUp');
assertDeepEquals(null, store.lastAction);
});
+
+ test('keyboard left/right', function() {
+ store.data.closedFolders = new Set('2');
+ store.notifyObservers();
+
+ // 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);
+
+ // RTL flips left and right.
+ document.body.style.direction = 'rtl';
tsergeant 2017/05/09 04:43:42 Nit: oh boy we'd better reset this after the test
calamity 2017/05/11 04:09:30 Done.
+ keydown('2', 'ArrowLeft');
+ assertDeepEquals(
+ bookmarks.actions.changeFolderOpen('2', true), store.lastAction);
+
+ keydown('2', 'ArrowRight');
+ assertDeepEquals(
+ bookmarks.actions.changeFolderOpen('2', false), store.lastAction);
+ });
});
mocha.run();
« no previous file with comments | « chrome/browser/resources/md_bookmarks/folder_node.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698