| 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 /** | 5 /** |
| 6 * Creates and returns a CommandManager which tracks what commands are executed. | 6 * Creates and returns a CommandManager which tracks what commands are executed. |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {bookmarks.CommandManager} | 8 * @extends {bookmarks.CommandManager} |
| 9 */ | 9 */ |
| 10 function TestCommandManager() { | 10 function TestCommandManager() { |
| 11 var commandManager = document.createElement('bookmarks-command-manager'); | 11 var commandManager = document.createElement('bookmarks-command-manager'); |
| 12 var lastCommand = null; | 12 var lastCommand = null; |
| 13 var lastCommandIds = null; | 13 var lastCommandIds = null; |
| 14 | 14 |
| 15 var realHandle = commandManager.handle.bind(commandManager); | 15 var realHandle = commandManager.handle.bind(commandManager); |
| 16 commandManager.handle = function(command, itemIds) { | 16 commandManager.handle = function(command, itemIds) { |
| 17 lastCommand = command; | 17 lastCommand = command; |
| 18 lastCommandIds = itemIds; | 18 lastCommandIds = itemIds; |
| 19 realHandle(command, itemIds); | 19 realHandle(command, itemIds); |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 commandManager.assertLastCommand = function (command, ids) { | 22 /** |
| 23 * @param {Command} command |
| 24 * @param {!Array<string>} ids |
| 25 */ |
| 26 commandManager.assertLastCommand = function(command, ids) { |
| 23 assertEquals(command, lastCommand); | 27 assertEquals(command, lastCommand); |
| 24 if (ids) | 28 if (ids) |
| 25 assertDeepEquals(ids, normalizeSet(lastCommandIds)); | 29 assertDeepEquals(ids, normalizeSet(lastCommandIds)); |
| 26 lastCommand = null; | 30 lastCommand = null; |
| 27 lastCommandIds = null; | 31 lastCommandIds = null; |
| 28 }; | 32 }; |
| 29 | 33 |
| 34 /** @param {!Array<string>} ids */ |
| 35 commandManager.assertMenuOpenForIds = function(ids) { |
| 36 assertDeepEquals(ids, normalizeSet(commandManager.menuIds_)); |
| 37 }; |
| 38 |
| 30 return commandManager; | 39 return commandManager; |
| 31 } | 40 } |
| OLD | NEW |