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..7dbc970708454e7b9e27ee1320a2e17edfd8aadd |
--- /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(command, lastCommand); |
+ if (ids) |
+ assertDeepEquals(ids, normalizeSet(lastCommandIds)); |
+ lastCommand = null; |
+ lastCommandIds = null; |
+ }; |
+ |
+ return commandManager; |
+} |