Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/test/data/webui/md_bookmarks/test_util.js

Issue 2613943003: [MD Bookmarks] Test Util (Closed)
Patch Set: style fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * Generates the following properties for a tree for UI testing:
tsergeant 2017/01/08 23:39:29 This is the sort of comment that's likely to get o
jiaxi 2017/01/09 00:04:11 Done.
16 * - Stores the path to the node inside each node.
17 * - Sets all nodes to not selected and open by default.
18 * @param {BookmarkTreeNode} rootNode
19 */
20 function setupTreeForUITests(rootNode){
21 if (!rootNode.path)
22 rootNode.path = 'rootNode';
23
24 BookmarksStore.generatePaths(rootNode, 0);
25 BookmarksStore.initNodes(rootNode);
26 }
27
28 /**
29 * Creates a folder with given properties.
30 * @param {string} id
31 * @param {Array<BookmarkTreeNode>} children
32 * @param {Object=} config
33 * @return {BookmarkTreeNode}
34 */
35 function createFolder(id, children, config) {
36 var newFolder = {
37 id: id,
38 children: children,
39 title: '',
40 };
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698