OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Creates and returns a CommandManager which tracks what commands are executed. |
| 7 * @constructor |
| 8 * @extends {bookmarks.CommandManager} |
| 9 */ |
| 10 function TestCommandManager() { |
| 11 var commandManager = document.createElement('bookmarks-command-manager'); |
| 12 var lastCommand = null; |
| 13 var lastCommandIds = null; |
| 14 |
| 15 var realHandle = commandManager.handle.bind(commandManager); |
| 16 commandManager.handle = function(command, itemIds) { |
| 17 lastCommand = command; |
| 18 lastCommandIds = itemIds; |
| 19 realHandle(command, itemIds); |
| 20 }; |
| 21 |
| 22 commandManager.assertLastCommand = function (command, ids) { |
| 23 assertEquals(command, lastCommand); |
| 24 if (ids) |
| 25 assertDeepEquals(ids, normalizeSet(lastCommandIds)); |
| 26 lastCommand = null; |
| 27 lastCommandIds = null; |
| 28 }; |
| 29 |
| 30 return commandManager; |
| 31 } |
OLD | NEW |