OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * Replace the current body of the test with a new element. | 6 * Replace the current body of the test with a new element. |
7 * @param {Element} element | 7 * @param {Element} element |
8 */ | 8 */ |
9 function replaceBody(element) { | 9 function replaceBody(element) { |
10 PolymerTest.clearBody(); | 10 PolymerTest.clearBody(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 var node; | 129 var node; |
130 while (nodes.length) { | 130 while (nodes.length) { |
131 node = nodes.pop(); | 131 node = nodes.pop(); |
132 if (node.itemId == id) | 132 if (node.itemId == id) |
133 return node; | 133 return node; |
134 | 134 |
135 node.root.querySelectorAll('bookmarks-folder-node') | 135 node.root.querySelectorAll('bookmarks-folder-node') |
136 .forEach((x) => {nodes.unshift(x)}); | 136 .forEach((x) => {nodes.unshift(x)}); |
137 } | 137 } |
138 } | 138 } |
139 | |
140 /** | |
141 * Creates and returns a CommandManager which tracks what commands are executed. | |
142 * @constructor | |
143 * @extends {bookmarks.CommandManager} | |
144 */ | |
145 function TestCommandManager() { | |
calamity
2017/05/23 03:42:55
Yeah, probably best to have this pulled out a la T
tsergeant
2017/05/23 04:11:36
Done.
| |
146 var commandManager = document.createElement('bookmarks-command-manager'); | |
147 var lastCommand = null; | |
148 var lastCommandIds = null; | |
149 | |
150 var realHandle = commandManager.handle.bind(commandManager); | |
151 commandManager.handle = function(command, itemIds) { | |
152 lastCommand = command; | |
153 lastCommandIds = itemIds; | |
154 realHandle(command, itemIds); | |
155 }; | |
156 | |
157 commandManager.assertLastCommand = function (command, ids) { | |
158 assertEquals(lastCommand, command); | |
159 if (ids) | |
160 assertDeepEquals(normalizeSet(lastCommandIds), ids); | |
161 lastCommand = null; | |
162 lastCommandIds = null; | |
163 }; | |
164 | |
165 return commandManager; | |
166 } | |
OLD | NEW |