Index: chrome/test/data/webui/md_bookmarks/test_util.js |
diff --git a/chrome/test/data/webui/md_bookmarks/test_util.js b/chrome/test/data/webui/md_bookmarks/test_util.js |
index 84c1a6bb185c370fa4494ea8f59f2e62df472543..7d76b3120cf0704540612400115ee7e66ac59f68 100644 |
--- a/chrome/test/data/webui/md_bookmarks/test_util.js |
+++ b/chrome/test/data/webui/md_bookmarks/test_util.js |
@@ -10,3 +10,62 @@ function replaceBody(element) { |
PolymerTest.clearBody(); |
document.body.appendChild(element); |
} |
+ |
+/** |
+ * 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.
|
+ * - Stores the path to the node inside each node. |
+ * - Sets all nodes to not selected and open by default. |
+ * @param {BookmarkTreeNode} rootNode |
+ */ |
+function setupTreeForUITests(rootNode){ |
+ if (!rootNode.path) |
+ rootNode.path = 'rootNode'; |
+ |
+ BookmarksStore.generatePaths(rootNode, 0); |
+ BookmarksStore.initNodes(rootNode); |
+} |
+ |
+/** |
+ * Creates a folder with given properties. |
+ * @param {string} id |
+ * @param {Array<BookmarkTreeNode>} children |
+ * @param {Object=} config |
+ * @return {BookmarkTreeNode} |
+ */ |
+function createFolder(id, children, config) { |
+ var newFolder = { |
+ id: id, |
+ children: children, |
+ title: '', |
+ }; |
+ if (config) { |
+ for (var key in config) |
+ newFolder[key] = config[key]; |
+ } |
+ if (children.length) { |
+ for (var i = 0; i < children.length; i++) { |
+ children[i].index = i; |
+ children[i].parentId = newFolder.id; |
+ } |
+ } |
+ return newFolder; |
+} |
+ |
+/** |
+ * Creates a bookmark with given properties. |
+ * @param {string} id |
+ * @param {Object=} config |
+ * @return {BookmarkTreeNode} |
+ */ |
+function createItem(id, config) { |
+ var newItem = { |
+ id: id, |
+ title: '', |
+ url: 'http://www.google.com/', |
+ }; |
+ if (config) { |
+ for (var key in config) |
+ newItem[key] = config[key]; |
+ } |
+ return newItem; |
+} |