| 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;
|
| +}
|
|
|