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

Side by Side Diff: chrome/test/data/webui/md_bookmarks/command_manager_test.js

Issue 2940233003: MD Bookmarks: Lazily render dropdown menus (Closed)
Patch Set: Rebase Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 suite('<bookmarks-command-manager>', function() { 5 suite('<bookmarks-command-manager>', function() {
6 var commandManager; 6 var commandManager;
7 var store; 7 var store;
8 var lastCommand; 8 var lastCommand;
9 var lastCommandIds; 9 var lastCommandIds;
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 [ 43 [
44 createFolder('21', []), 44 createFolder('21', []),
45 ])) 45 ]))
46 }); 46 });
47 store.replaceSingleton(); 47 store.replaceSingleton();
48 48
49 commandManager = new TestCommandManager(); 49 commandManager = new TestCommandManager();
50 replaceBody(commandManager); 50 replaceBody(commandManager);
51 document.body.appendChild( 51 document.body.appendChild(
52 document.createElement('bookmarks-toast-manager')); 52 document.createElement('bookmarks-toast-manager'));
53
54 Polymer.dom.flush();
55 }); 53 });
56 54
57 test('can only copy single URL items', function() { 55 test('can only copy single URL items', function() {
58 assertFalse(commandManager.canExecute(Command.COPY, new Set(['11']))); 56 assertFalse(commandManager.canExecute(Command.COPY, new Set(['11'])));
59 assertFalse(commandManager.canExecute(Command.COPY, new Set(['11', '13']))); 57 assertFalse(commandManager.canExecute(Command.COPY, new Set(['11', '13'])));
60 assertTrue(commandManager.canExecute(Command.COPY, new Set(['13']))); 58 assertTrue(commandManager.canExecute(Command.COPY, new Set(['13'])));
61 }); 59 });
62 60
63 test('context menu hides invalid commands', function() { 61 test('context menu hides invalid commands', function() {
64 store.data.selection.items = new Set(['11', '13']); 62 store.data.selection.items = new Set(['11', '13']);
65 store.notifyObservers(); 63 store.notifyObservers();
66 64
67 commandManager.openCommandMenuAtPosition(0, 0); 65 commandManager.openCommandMenuAtPosition(0, 0);
66 Polymer.dom.flush();
67
68 var commandHidden = {}; 68 var commandHidden = {};
69 commandManager.root.querySelectorAll('.dropdown-item').forEach(element => { 69 commandManager.root.querySelectorAll('.dropdown-item').forEach(element => {
70 commandHidden[element.getAttribute('command')] = element.hidden; 70 commandHidden[element.getAttribute('command')] = element.hidden;
71 }); 71 });
72 72
73 // With a folder and an item selected, the only available context menu item 73 // With a folder and an item selected, the only available context menu item
74 // is 'Delete'. 74 // is 'Delete'.
75 assertTrue(commandHidden['edit']); 75 assertTrue(commandHidden['edit']);
76 assertTrue(commandHidden['copy']); 76 assertTrue(commandHidden['copy']);
77 assertFalse(commandHidden['delete']); 77 assertFalse(commandHidden['delete']);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 commandManager.assertLastCommand(Command.OPEN_NEW_WINDOW); 181 commandManager.assertLastCommand(Command.OPEN_NEW_WINDOW);
182 }); 182 });
183 183
184 test('cannot execute "Open in New Tab" on folders with no items', function() { 184 test('cannot execute "Open in New Tab" on folders with no items', function() {
185 var items = new Set(['2']); 185 var items = new Set(['2']);
186 assertFalse(commandManager.canExecute(Command.OPEN_NEW_TAB, items)); 186 assertFalse(commandManager.canExecute(Command.OPEN_NEW_TAB, items));
187 187
188 store.data.selection.items = items; 188 store.data.selection.items = items;
189 189
190 commandManager.openCommandMenuAtPosition(0, 0); 190 commandManager.openCommandMenuAtPosition(0, 0);
191 Polymer.dom.flush();
192
191 var commandItem = {}; 193 var commandItem = {};
192 commandManager.root.querySelectorAll('.dropdown-item').forEach(element => { 194 commandManager.root.querySelectorAll('.dropdown-item').forEach(element => {
193 commandItem[element.getAttribute('command')] = element; 195 commandItem[element.getAttribute('command')] = element;
194 }); 196 });
195 197
196 assertTrue(commandItem[Command.OPEN_NEW_TAB].disabled); 198 assertTrue(commandItem[Command.OPEN_NEW_TAB].disabled);
197 assertFalse(commandItem[Command.OPEN_NEW_TAB].hidden); 199 assertFalse(commandItem[Command.OPEN_NEW_TAB].hidden);
198 200
199 assertTrue(commandItem[Command.OPEN_NEW_WINDOW].disabled); 201 assertTrue(commandItem[Command.OPEN_NEW_WINDOW].disabled);
200 assertFalse(commandItem[Command.OPEN_NEW_WINDOW].hidden); 202 assertFalse(commandItem[Command.OPEN_NEW_WINDOW].hidden);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 assertOpenedTabs(['http://111/', 'http://12/']); 308 assertOpenedTabs(['http://111/', 'http://12/']);
307 }); 309 });
308 310
309 test('control-double click opens full selection', function() { 311 test('control-double click opens full selection', function() {
310 customClick(items[0]); 312 customClick(items[0]);
311 simulateDoubleClick(items[2], {ctrlKey: true}); 313 simulateDoubleClick(items[2], {ctrlKey: true});
312 314
313 assertOpenedTabs(['http://111/', 'http://13/']); 315 assertOpenedTabs(['http://111/', 'http://13/']);
314 }); 316 });
315 }); 317 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/toolbar.js ('k') | chrome/test/data/webui/md_bookmarks/toolbar_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698