Chromium Code Reviews| 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 | |
| 14 /** | |
| 15 * Generateis the following properties for a tree for UI testing: | |
|
calamity
2017/01/06 04:44:37
nit: Generates
jiaxi
2017/01/06 04:50:27
Done.
| |
| 16 * - Store the path to a node inside the node. | |
|
calamity
2017/01/06 04:44:37
Stores the path to the node inside each node.
jiaxi
2017/01/06 04:50:26
Done.
| |
| 17 * - Sets all nodes to not selected and open by default. | |
| 18 * @param {BookmarkTreeNode} rootNode | |
| 19 */ | |
| 20 function setUpTreeForUITests(rootNode){ | |
|
calamity
2017/01/06 04:44:37
setupTreeForUITests.
jiaxi
2017/01/06 04:50:27
Done.
| |
| 21 if (!rootNode.path) | |
| 22 rootNode.path = 'rootNode'; | |
|
calamity
2017/01/06 04:44:37
Newline after here.
jiaxi
2017/01/06 04:50:26
Done.
| |
| 23 BookmarksStore.generatePaths(rootNode, 0); | |
| 24 BookmarksStore.initNodes(rootNode); | |
| 25 } | |
| 26 | |
| 27 /** | |
| 28 * Creates a folder with given properties. | |
| 29 * @param {string} id | |
| 30 * @param {Array<BookmarkTreeNode>} children | |
| 31 * @param {Object=} config | |
| 32 * @return {BookmarkTreeNode} | |
| 33 */ | |
| 34 function createFolder(id, children, config) { | |
| 35 var newFolder = { | |
| 36 id: id, | |
| 37 children: children, | |
| 38 title: '', | |
| 39 }; | |
| 40 newFolder.id = id; | |
|
calamity
2017/01/06 04:44:37
Delete.
jiaxi
2017/01/06 04:50:26
Done.
| |
| 41 if (config) { | |
| 42 for (var key in config) | |
| 43 newFolder[key] = config[key]; | |
| 44 } | |
| 45 if (children.length) { | |
| 46 for (var i = 0; i < children.length; i++) { | |
| 47 children[i].index = i; | |
| 48 children[i].parentId = newFolder.id; | |
| 49 } | |
| 50 } | |
| 51 return newFolder; | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * Creates a bookmark with given properties. | |
| 56 * @param {string} id | |
| 57 * @param {Object=} config | |
| 58 * @return {BookmarkTreeNode} | |
| 59 */ | |
| 60 function createItem(id, config) { | |
| 61 var newItem = { | |
| 62 id: id, | |
| 63 title: '', | |
| 64 url: 'http://www.google.com/', | |
| 65 }; | |
| 66 if (config) { | |
| 67 for (var key in config) | |
| 68 newItem[key] = config[key]; | |
| 69 } | |
| 70 return newItem; | |
| 71 } | |
| OLD | NEW |