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

Side by Side Diff: chrome/test/data/extensions/api_test/bookmarks/test.js

Issue 174633: Add browser tests for extensions tab API. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // bookmarks api test 1 // bookmarks api test
2 // browser_tests.exe --gtest_filter=ExtensionApiTest.Bookmarks 2 // browser_tests.exe --gtest_filter=ExtensionApiTest.Bookmarks
3 3
4 var expected = [ 4 var expected = [
5 {"children": [ 5 {"children": [
6 {"children": [], "id": "1", "parentId": "0", "index": 0, "title":"Bookmarks bar"}, 6 {"children": [], "id": "1", "parentId": "0", "index": 0, "title":"Bookmarks bar"},
7 {"children": [], "id": "2", "parentId": "0", "index": 1, "title":"Other book marks"} 7 {"children": [], "id": "2", "parentId": "0", "index": 1, "title":"Other book marks"}
8 ], 8 ],
9 "id": "0", "title": "" 9 "id": "0", "title": ""
10 } 10 }
11 ]; 11 ];
12 12
13 var testCallback = chrome.test.testCallback;
14
13 function compareNode(left, right) { 15 function compareNode(left, right) {
14 //console.log(JSON.stringify(left)); 16 //console.log(JSON.stringify(left));
15 //console.log(JSON.stringify(right)); 17 //console.log(JSON.stringify(right));
16 // TODO(erikkay): do some comparison of dateAdded 18 // TODO(erikkay): do some comparison of dateAdded
17 if (left.id != right.id) 19 if (left.id != right.id)
18 return "id mismatch: " + left.id + " != " + right.id; 20 return "id mismatch: " + left.id + " != " + right.id;
19 if (left.title != right.title) 21 if (left.title != right.title)
20 return "title mismatch: " + left.title + " != " + right.title; 22 return "title mismatch: " + left.title + " != " + right.title;
21 if (left.url != right.url) 23 if (left.url != right.url)
22 return "url mismatch: " + left.url + " != " + right.url; 24 return "url mismatch: " + left.url + " != " + right.url;
(...skipping 22 matching lines...) Expand all
45 } 47 }
46 result = compareTrees(left[i].children, right[i].children); 48 result = compareTrees(left[i].children, right[i].children);
47 if (result !== true) 49 if (result !== true)
48 return result; 50 return result;
49 } 51 }
50 return true; 52 return true;
51 } 53 }
52 54
53 chrome.test.runTests([ 55 chrome.test.runTests([
54 function getTree() { 56 function getTree() {
55 chrome.bookmarks.getTree(chrome.test.testFunction(function(results) { 57 chrome.bookmarks.getTree(testCallback(true, function(results) {
56 chrome.test.assertTrue(compareTrees(results, expected), 58 chrome.test.assertTrue(compareTrees(results, expected),
57 "getTree() result != expected"); 59 "getTree() result != expected");
58 expected = results; 60 expected = results;
59 })); 61 }));
60 }, 62 },
61 63
62 function get() { 64 function get() {
63 chrome.bookmarks.get("1", chrome.test.testFunction(function(results) { 65 chrome.bookmarks.get("1", testCallback(true, function(results) {
64 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0])); 66 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]));
65 })); 67 }));
66 }, 68 },
67 69
68 function getArray() { 70 function getArray() {
69 chrome.bookmarks.get(["1", "2"], 71 chrome.bookmarks.get(["1", "2"], testCallback(true, function(results) {
70 chrome.test.testFunction(function(results) {
71 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]), 72 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]),
72 "get() result != expected"); 73 "get() result != expected");
73 chrome.test.assertTrue(compareNode(results[1], expected[0].children[1]), 74 chrome.test.assertTrue(compareNode(results[1], expected[0].children[1]),
74 "get() result != expected"); 75 "get() result != expected");
75 })); 76 }));
76 }, 77 },
77 78
78 function getChildren() { 79 function getChildren() {
79 chrome.bookmarks.getChildren("0", 80 chrome.bookmarks.getChildren("0", testCallback(true, function(results) {
80 chrome.test.testFunction(function(results) {
81 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]), 81 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]),
82 "getChildren() result != expected"); 82 "getChildren() result != expected");
83 chrome.test.assertTrue(compareNode(results[1], expected[0].children[1]), 83 chrome.test.assertTrue(compareNode(results[1], expected[0].children[1]),
84 "getChildren() result != expected"); 84 "getChildren() result != expected");
85 })); 85 }));
86 }, 86 },
87 87
88 function create() { 88 function create() {
89 var node = {parentId: "1", title:"google", url:"http://www.google.com/"}; 89 var node = {parentId: "1", title:"google", url:"http://www.google.com/"};
90 chrome.bookmarks.create(node, chrome.test.testFunction(function(results) { 90 chrome.bookmarks.create(node, testCallback(true, function(results) {
91 node.id = results.id; // since we couldn't know this going in 91 node.id = results.id; // since we couldn't know this going in
92 node.index = 0; 92 node.index = 0;
93 chrome.test.assertTrue(compareNode(node, results), 93 chrome.test.assertTrue(compareNode(node, results),
94 "created node != source"); 94 "created node != source");
95 })); 95 }));
96 }, 96 },
97 ]); 97 ]);
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extension_apitest.js ('k') | chrome/test/data/extensions/api_test/override1/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698