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; |
| 9 |
| 10 suiteSetup(function() { |
| 11 chrome.bookmarkManagerPrivate.removeTrees = function() {}; |
| 12 }); |
8 | 13 |
9 setup(function() { | 14 setup(function() { |
10 store = new bookmarks.TestStore({ | 15 store = new bookmarks.TestStore({ |
11 nodes: testTree(createFolder('1', [ | 16 nodes: testTree(createFolder('1', [ |
12 createItem('2'), | 17 createItem('2'), |
13 createItem('3'), | 18 createItem('3'), |
14 ])), | 19 ])), |
15 selection: { | 20 selection: { |
16 items: new Set(), | 21 items: new Set(), |
17 anchor: null, | 22 anchor: null, |
18 }, | 23 }, |
19 }); | 24 }); |
20 bookmarks.Store.instance_ = store; | 25 bookmarks.Store.instance_ = store; |
21 | 26 |
22 toolbar = document.createElement('bookmarks-toolbar'); | 27 toolbar = document.createElement('bookmarks-toolbar'); |
23 replaceBody(toolbar); | 28 replaceBody(toolbar); |
| 29 |
| 30 commandManager = new TestCommandManager(); |
| 31 document.body.appendChild(commandManager); |
24 }); | 32 }); |
25 | 33 |
26 test('selecting multiple items shows toolbar overlay', function() { | 34 test('selecting multiple items shows toolbar overlay', function() { |
27 assertFalse(toolbar.showSelectionOverlay); | 35 assertFalse(toolbar.showSelectionOverlay); |
28 | 36 |
29 store.data.selection.items = new Set(['2']); | 37 store.data.selection.items = new Set(['2']); |
30 store.notifyObservers(); | 38 store.notifyObservers(); |
31 assertFalse(toolbar.showSelectionOverlay); | 39 assertFalse(toolbar.showSelectionOverlay); |
32 | 40 |
33 store.data.selection.items = new Set(['2', '3']); | 41 store.data.selection.items = new Set(['2', '3']); |
34 store.notifyObservers(); | 42 store.notifyObservers(); |
35 assertTrue(toolbar.showSelectionOverlay); | 43 assertTrue(toolbar.showSelectionOverlay); |
36 }); | 44 }); |
| 45 |
| 46 test('clicking overlay delete button triggers a delete command', function() { |
| 47 store.data.selection.items = new Set(['2', '3']); |
| 48 store.notifyObservers(); |
| 49 |
| 50 Polymer.dom.flush(); |
| 51 MockInteractions.tap( |
| 52 toolbar.$$('cr-toolbar-selection-overlay').deleteButton); |
| 53 |
| 54 commandManager.assertLastCommand(Command.DELETE, ['2', '3']); |
| 55 }); |
37 }); | 56 }); |
OLD | NEW |