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(); |
11 document.body.appendChild(element); | 11 document.body.appendChild(element); |
12 } | 12 } |
13 | 13 |
14 /** | 14 /** |
15 * Convert a tree of bookmark nodes into a normalized lookup table of nodes. | 15 * Convert a tree of bookmark nodes into a normalized lookup table of nodes. |
16 */ | 16 */ |
17 function testTree(root) { | 17 function testTree(root) { |
18 return bookmarks.util.normalizeNodes(root); | 18 return bookmarks.util.normalizeNodes(root); |
19 } | 19 } |
20 | 20 |
21 /** | 21 /** |
22 * Initialize a tree for UI testing. This performs the same initialization as | |
23 * `setUpStore_` in <bookmarks-store>, but without the need for a store element | |
24 * in the test. | |
25 * @param {BookmarkTreeNode} rootNode | |
26 */ | |
27 function setupTreeForUITests(rootNode){ | |
28 if (!rootNode.path) | |
29 rootNode.path = 'rootNode'; | |
30 | |
31 BookmarksStore.generatePaths(rootNode, 0); | |
32 BookmarksStore.initNodes(rootNode); | |
33 } | |
34 | |
35 /** | |
36 * Creates a folder with given properties. | 22 * Creates a folder with given properties. |
37 * @param {string} id | 23 * @param {string} id |
38 * @param {Array<BookmarkTreeNode>} children | 24 * @param {Array<BookmarkTreeNode>} children |
39 * @param {Object=} config | 25 * @param {Object=} config |
40 * @return {BookmarkTreeNode} | 26 * @return {BookmarkTreeNode} |
41 */ | 27 */ |
42 function createFolder(id, children, config) { | 28 function createFolder(id, children, config) { |
43 var newFolder = { | 29 var newFolder = { |
44 id: id, | 30 id: id, |
45 children: children, | 31 children: children, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 92 |
107 if (config) { | 93 if (config) { |
108 for (var key in config) | 94 for (var key in config) |
109 props[key] = config[key]; | 95 props[key] = config[key]; |
110 } | 96 } |
111 | 97 |
112 element.dispatchEvent(new MouseEvent('mousedown', props)); | 98 element.dispatchEvent(new MouseEvent('mousedown', props)); |
113 element.dispatchEvent(new MouseEvent('mouseup', props)); | 99 element.dispatchEvent(new MouseEvent('mouseup', props)); |
114 element.dispatchEvent(new MouseEvent('click', props)); | 100 element.dispatchEvent(new MouseEvent('click', props)); |
115 } | 101 } |
OLD | NEW |