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

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

Issue 2613943003: [MD Bookmarks] Test Util (Closed)
Patch Set: change trees in other tests 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..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;
+}

Powered by Google App Engine
This is Rietveld 408576698