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

Side by Side 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 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 assertTrue(commandItem[Command.OPEN_NEW_TAB].disabled); 179 assertTrue(commandItem[Command.OPEN_NEW_TAB].disabled);
180 assertFalse(commandItem[Command.OPEN_NEW_TAB].hidden); 180 assertFalse(commandItem[Command.OPEN_NEW_TAB].hidden);
181 181
182 assertTrue(commandItem[Command.OPEN_NEW_WINDOW].disabled); 182 assertTrue(commandItem[Command.OPEN_NEW_WINDOW].disabled);
183 assertFalse(commandItem[Command.OPEN_NEW_WINDOW].hidden); 183 assertFalse(commandItem[Command.OPEN_NEW_WINDOW].hidden);
184 184
185 assertTrue(commandItem[Command.OPEN_INCOGNITO].disabled); 185 assertTrue(commandItem[Command.OPEN_INCOGNITO].disabled);
186 assertFalse(commandItem[Command.OPEN_INCOGNITO].hidden); 186 assertFalse(commandItem[Command.OPEN_INCOGNITO].hidden);
187 }); 187 });
188 }); 188 });
189
190 suite('<bookmarks-item> CommandManager integration', function() {
191 var list;
192 var items;
193 var commandManager;
194 var openedTabs;
195
196 setup(function() {
197 store = new bookmarks.TestStore({
198 nodes: testTree(createFolder(
199 '1',
200 [
201 createFolder(
202 '11',
203 [
204 createItem('111', {url: 'http://111/'}),
205 ]),
206 createItem('12', {url: 'http://12/'}),
207 createItem('13', {url: 'http://13/'}),
208 ])),
209 selectedFolder: '1',
210 });
211 store.setReducersEnabled(true);
212 bookmarks.Store.instance_ = store;
213
214 commandManager = document.createElement('bookmarks-command-manager');
215
216 list = document.createElement('bookmarks-list');
217 replaceBody(list);
218 document.body.appendChild(commandManager);
219 Polymer.dom.flush();
220
221 items = list.root.querySelectorAll('bookmarks-item');
222
223 openedTabs = [];
224 chrome.tabs.create = function(createConfig) {
225 openedTabs.push(createConfig);
226 }
227 });
228
229 function assertOpenedTabs(tabs) {
230 assertDeepEquals(tabs, openedTabs.map(createConfig => createConfig.url));
231 }
232
233 function simulateDoubleClick(element, config) {
234 config = config || {};
235 customClick(element, config);
236 config.detail = 2;
237 customClick(element, config);
238 }
239
240 test('double click opens folders in bookmark manager', function() {
241 simulateDoubleClick(items[0]);
242 assertEquals(store.data.selectedFolder, '11');
243 });
244
245 test('double click opens items in foreground tab', function() {
246 simulateDoubleClick(items[1]);
247 assertOpenedTabs(['http://12/']);
248 });
249
250 test('shift-double click opens full selection', function() {
251 // Shift-double click works because the first click event selects the range
252 // of items, then the second doubleclick event opens that whole selection.
253 customClick(items[0]);
254 simulateDoubleClick(items[1], {shiftKey: true});
255
256 assertOpenedTabs(['http://111/', 'http://12/']);
257 });
258
259 test('control-double click opens full selection', function() {
260 customClick(items[0]);
261 simulateDoubleClick(items[2], {ctrlKey: true});
262
263 assertOpenedTabs(['http://111/', 'http://13/']);
264 });
265 });
OLDNEW
« 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