Chromium Code Reviews| Index: chrome/test/data/webui/md_bookmarks/test_command_manager.js |
| diff --git a/chrome/test/data/webui/md_bookmarks/test_command_manager.js b/chrome/test/data/webui/md_bookmarks/test_command_manager.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ea10a2a30b46f6bd47a0f5918314b606287973bc |
| --- /dev/null |
| +++ b/chrome/test/data/webui/md_bookmarks/test_command_manager.js |
| @@ -0,0 +1,31 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * Creates and returns a CommandManager which tracks what commands are executed. |
| + * @constructor |
| + * @extends {bookmarks.CommandManager} |
| + */ |
| +function TestCommandManager() { |
| + var commandManager = document.createElement('bookmarks-command-manager'); |
| + var lastCommand = null; |
| + var lastCommandIds = null; |
| + |
| + var realHandle = commandManager.handle.bind(commandManager); |
| + commandManager.handle = function(command, itemIds) { |
| + lastCommand = command; |
| + lastCommandIds = itemIds; |
| + realHandle(command, itemIds); |
| + }; |
| + |
| + commandManager.assertLastCommand = function (command, ids) { |
| + assertEquals(lastCommand, command); |
| + if (ids) |
| + assertDeepEquals(normalizeSet(lastCommandIds), ids); |
|
calamity
2017/05/23 05:46:03
nit: Flip the assert args here and above.
tsergeant
2017/05/23 06:50:42
Done.
|
| + lastCommand = null; |
| + lastCommandIds = null; |
| + }; |
| + |
| + return commandManager; |
| +} |