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..62442f1e89db6eeab2d512f0dd7ade29c384d470 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); |
} |
+ |
+/** |
+ * 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.
|
+ * - 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.
|
+ * - Sets all nodes to not selected and open by default. |
+ * @param {BookmarkTreeNode} rootNode |
+ */ |
+function setUpTreeForUITests(rootNode){ |
calamity
2017/01/06 04:44:37
setupTreeForUITests.
jiaxi
2017/01/06 04:50:27
Done.
|
+ if (!rootNode.path) |
+ rootNode.path = 'rootNode'; |
calamity
2017/01/06 04:44:37
Newline after here.
jiaxi
2017/01/06 04:50:26
Done.
|
+ 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: '', |
+ }; |
+ newFolder.id = id; |
calamity
2017/01/06 04:44:37
Delete.
jiaxi
2017/01/06 04:50:26
Done.
|
+ 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; |
+} |