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

Unified 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 side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698