Index: chrome/test/data/webui/md_bookmarks/command_manager_test.js |
diff --git a/chrome/test/data/webui/md_bookmarks/command_manager_test.js b/chrome/test/data/webui/md_bookmarks/command_manager_test.js |
index 14b6d28203d7f0f0c18cf5733f94c425882cb120..79007db15c6e9a30e2f4f20a2276afbed10769f3 100644 |
--- a/chrome/test/data/webui/md_bookmarks/command_manager_test.js |
+++ b/chrome/test/data/webui/md_bookmarks/command_manager_test.js |
@@ -186,3 +186,68 @@ suite('<bookmarks-command-manager>', function() { |
assertFalse(commandItem[Command.OPEN_INCOGNITO].hidden); |
}); |
}); |
+ |
+suite('<bookmarks-item> CommandManager integration', function() { |
+ var list; |
+ var items; |
+ var commandManager; |
+ var openedTabs; |
+ |
+ setup(function() { |
+ store = new bookmarks.TestStore({ |
+ nodes: testTree(createFolder( |
+ '1', |
+ [ |
+ createFolder('11', [createItem('111', {url: 'http://111/'})]), |
calamity
2017/05/17 05:09:23
nit: Add trailing comma to array.
tsergeant
2017/05/17 07:04:38
Done.
|
+ createItem('12', {url: 'http://12/'}), |
+ createItem('13', {url: 'http://13/'}), |
+ ])), |
+ selectedFolder: '1', |
+ }); |
+ store.setReducersEnabled(true); |
+ bookmarks.Store.instance_ = store; |
+ |
+ commandManager = document.createElement('bookmarks-command-manager'); |
+ |
+ list = document.createElement('bookmarks-list'); |
+ replaceBody(list); |
+ document.body.appendChild(commandManager); |
+ Polymer.dom.flush(); |
+ |
+ items = list.root.querySelectorAll('bookmarks-item'); |
+ |
+ openedTabs = []; |
+ chrome.tabs.create = function(createConfig) { |
+ openedTabs.push(createConfig); |
+ } |
+ }); |
+ |
+ function assertOpenedTabs(tabs) { |
+ assertDeepEquals(tabs, openedTabs.map(createConfig => createConfig.url)); |
+ } |
+ |
+ function simulateDoubleClick(element, shiftKey) { |
+ customClick(element, {shiftKey: shiftKey}); |
+ customClick(element, {shiftKey: shiftKey, detail: 2}); |
+ customClick(element, {shiftKey: shiftKey, detail: 2}, 'dblclick'); |
calamity
2017/05/17 05:09:23
How come there are 3 clicks in a double click?
tsergeant
2017/05/17 07:04:38
This was firing slightly too many events. I've mod
|
+ } |
+ |
+ test('double click opens folders in bookmark manager', function() { |
+ simulateDoubleClick(items[0]); |
+ assertEquals(store.data.selectedFolder, '11'); |
+ }); |
+ |
+ test('double click opens items in foreground tab', function() { |
+ simulateDoubleClick(items[1]); |
+ assertOpenedTabs(['http://12/']); |
+ }); |
+ |
+ test('shift-double click opens full selection', function() { |
+ // Shift-double click works because the first click event selects the range |
+ // of items, then the second doubleclick event opens that whole selection. |
+ customClick(items[0]); |
+ simulateDoubleClick(items[1], true); |
+ |
+ assertOpenedTabs(['http://111/', 'http://12/']); |
+ }); |
calamity
2017/05/17 05:09:23
Also add a case for ctrl-click, which needs to kee
tsergeant
2017/05/17 07:04:38
Done
|
+}); |