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

Unified Diff: chrome/test/data/webui/md_bookmarks/test_util.js

Issue 2613943003: [MD Bookmarks] Test Util (Closed)
Patch Set: remove closure and comment update 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
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/store_test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..64755a2f3ce1fea25e9bf214a2f6f3a405a74ad3 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);
}
+
+/**
+ * Initialize a tree for UI testing. This performs the same initialization as
+ * `setUpStore_` in <bookmarks-store>, but without the need for a store element
+ * in the test.
+ * @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;
+}
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/store_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698