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

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

Issue 2872163002: MD Bookmarks: Add 'Open' command, to open in either the BMM or in new tabs (Closed)
Patch Set: Rebase 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
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..d103eafa7ca76082ba8f01812bf5b21491f676fe 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,80 @@ 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/'}),
+ ]),
+ 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, config) {
+ config = config || {};
+ customClick(element, config);
+ config.detail = 2;
+ customClick(element, config);
+ }
+
+ 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], {shiftKey: true});
+
+ assertOpenedTabs(['http://111/', 'http://12/']);
+ });
+
+ test('control-double click opens full selection', function() {
+ customClick(items[0]);
+ simulateDoubleClick(items[2], {ctrlKey: true});
+
+ assertOpenedTabs(['http://111/', 'http://13/']);
+ });
+});
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/actions_test.js ('k') | chrome/test/data/webui/md_bookmarks/item_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698