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-toolbar>', function() { | 5 suite('<bookmarks-toolbar>', function() { |
| 6 var toolbar; | 6 var toolbar; |
| 7 var store; | 7 var store; |
| 8 var commandManager; | |
| 8 | 9 |
| 9 setup(function() { | 10 setup(function() { |
| 10 store = new bookmarks.TestStore({ | 11 store = new bookmarks.TestStore({ |
| 11 nodes: testTree(createFolder('1', [ | 12 nodes: testTree(createFolder('1', [ |
| 12 createItem('2'), | 13 createItem('2'), |
| 13 createItem('3'), | 14 createItem('3'), |
| 14 ])), | 15 ])), |
| 15 selection: { | 16 selection: { |
| 16 items: new Set(), | 17 items: new Set(), |
| 17 anchor: null, | 18 anchor: null, |
| 18 }, | 19 }, |
| 19 }); | 20 }); |
| 20 bookmarks.Store.instance_ = store; | 21 bookmarks.Store.instance_ = store; |
| 21 | 22 |
| 22 toolbar = document.createElement('bookmarks-toolbar'); | 23 toolbar = document.createElement('bookmarks-toolbar'); |
| 23 replaceBody(toolbar); | 24 replaceBody(toolbar); |
| 25 | |
| 26 commandManager = new TestCommandManager(); | |
|
calamity
2017/05/23 03:42:55
Does this also need to get assigned to bookmarks.C
tsergeant
2017/05/23 04:11:36
CommandManager is a bit weird, because it takes ov
calamity
2017/05/23 05:34:19
Oh yeah, I totally forgot about that subtlety.
| |
| 27 document.body.appendChild(commandManager); | |
| 24 }); | 28 }); |
| 25 | 29 |
| 26 test('selecting multiple items shows toolbar overlay', function() { | 30 test('selecting multiple items shows toolbar overlay', function() { |
| 27 assertFalse(toolbar.showSelectionOverlay); | 31 assertFalse(toolbar.showSelectionOverlay); |
| 28 | 32 |
| 29 store.data.selection.items = new Set(['2']); | 33 store.data.selection.items = new Set(['2']); |
| 30 store.notifyObservers(); | 34 store.notifyObservers(); |
| 31 assertFalse(toolbar.showSelectionOverlay); | 35 assertFalse(toolbar.showSelectionOverlay); |
| 32 | 36 |
| 33 store.data.selection.items = new Set(['2', '3']); | 37 store.data.selection.items = new Set(['2', '3']); |
| 34 store.notifyObservers(); | 38 store.notifyObservers(); |
| 35 assertTrue(toolbar.showSelectionOverlay); | 39 assertTrue(toolbar.showSelectionOverlay); |
| 36 }); | 40 }); |
| 41 | |
| 42 test('clicking overlay delete button triggers a delete command', function() { | |
| 43 store.data.selection.items = new Set(['2', '3']); | |
| 44 store.notifyObservers(); | |
| 45 | |
| 46 Polymer.dom.flush(); | |
| 47 MockInteractions.tap( | |
| 48 toolbar.$$('cr-toolbar-selection-overlay').deleteButton); | |
| 49 | |
| 50 commandManager.assertLastCommand(Command.DELETE, ['2', '3']); | |
| 51 }); | |
| 37 }); | 52 }); |
| OLD | NEW |