Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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('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.
| |
| 202 createItem('12', {url: 'http://12/'}), | |
| 203 createItem('13', {url: 'http://13/'}), | |
| 204 ])), | |
| 205 selectedFolder: '1', | |
| 206 }); | |
| 207 store.setReducersEnabled(true); | |
| 208 bookmarks.Store.instance_ = store; | |
| 209 | |
| 210 commandManager = document.createElement('bookmarks-command-manager'); | |
| 211 | |
| 212 list = document.createElement('bookmarks-list'); | |
| 213 replaceBody(list); | |
| 214 document.body.appendChild(commandManager); | |
| 215 Polymer.dom.flush(); | |
| 216 | |
| 217 items = list.root.querySelectorAll('bookmarks-item'); | |
| 218 | |
| 219 openedTabs = []; | |
| 220 chrome.tabs.create = function(createConfig) { | |
| 221 openedTabs.push(createConfig); | |
| 222 } | |
| 223 }); | |
| 224 | |
| 225 function assertOpenedTabs(tabs) { | |
| 226 assertDeepEquals(tabs, openedTabs.map(createConfig => createConfig.url)); | |
| 227 } | |
| 228 | |
| 229 function simulateDoubleClick(element, shiftKey) { | |
| 230 customClick(element, {shiftKey: shiftKey}); | |
| 231 customClick(element, {shiftKey: shiftKey, detail: 2}); | |
| 232 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
| |
| 233 } | |
| 234 | |
| 235 test('double click opens folders in bookmark manager', function() { | |
| 236 simulateDoubleClick(items[0]); | |
| 237 assertEquals(store.data.selectedFolder, '11'); | |
| 238 }); | |
| 239 | |
| 240 test('double click opens items in foreground tab', function() { | |
| 241 simulateDoubleClick(items[1]); | |
| 242 assertOpenedTabs(['http://12/']); | |
| 243 }); | |
| 244 | |
| 245 test('shift-double click opens full selection', function() { | |
| 246 // Shift-double click works because the first click event selects the range | |
| 247 // of items, then the second doubleclick event opens that whole selection. | |
| 248 customClick(items[0]); | |
| 249 simulateDoubleClick(items[1], true); | |
| 250 | |
| 251 assertOpenedTabs(['http://111/', 'http://12/']); | |
| 252 }); | |
|
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
| |
| 253 }); | |
| OLD | NEW |