| OLD | NEW |
| 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 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 result = compareTrees(left[i].children, right[i].children); | 46 result = compareTrees(left[i].children, right[i].children); |
| 47 if (result !== true) | 47 if (result !== true) |
| 48 return result; | 48 return result; |
| 49 } | 49 } |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 var tests = [ | 53 var tests = [ |
| 54 function getTree() { | 54 function getTree() { |
| 55 chrome.bookmarks.getTree(function(results) { | 55 chrome.bookmarks.getTree(testFunction(function(results) { |
| 56 assertNoLastError(); | |
| 57 assertTrue(compareTrees(results, expected), | 56 assertTrue(compareTrees(results, expected), |
| 58 "getTree() result != expected"); | 57 "getTree() result != expected"); |
| 59 expected = results; | 58 expected = results; |
| 60 succeed(); | 59 })); |
| 61 }); | |
| 62 }, | 60 }, |
| 63 | 61 |
| 64 function get() { | 62 function get() { |
| 65 chrome.bookmarks.get("1", function(results) { | 63 chrome.bookmarks.get("1", testFunction(function(results) { |
| 66 assertNoLastError(); | |
| 67 assertTrue(compareNode(results[0], expected[0].children[0])); | 64 assertTrue(compareNode(results[0], expected[0].children[0])); |
| 68 succeed(); | 65 })); |
| 69 }); | |
| 70 }, | 66 }, |
| 71 | 67 |
| 72 function getArray() { | 68 function getArray() { |
| 73 chrome.bookmarks.get(["1", "2"], function(results) { | 69 chrome.bookmarks.get(["1", "2"], testFunction(function(results) { |
| 74 assertNoLastError(); | |
| 75 assertTrue(compareNode(results[0], expected[0].children[0]), | 70 assertTrue(compareNode(results[0], expected[0].children[0]), |
| 76 "get() result != expected"); | 71 "get() result != expected"); |
| 77 assertTrue(compareNode(results[1], expected[0].children[1]), | 72 assertTrue(compareNode(results[1], expected[0].children[1]), |
| 78 "get() result != expected"); | 73 "get() result != expected"); |
| 79 succeed(); | 74 })); |
| 80 }); | |
| 81 }, | 75 }, |
| 82 | 76 |
| 83 function getChildren() { | 77 function getChildren() { |
| 84 chrome.bookmarks.getChildren("0", function(results) { | 78 chrome.bookmarks.getChildren("0", testFunction(function(results) { |
| 85 assertNoLastError(); | |
| 86 assertTrue(compareNode(results[0], expected[0].children[0]), | 79 assertTrue(compareNode(results[0], expected[0].children[0]), |
| 87 "getChildren() result != expected"); | 80 "getChildren() result != expected"); |
| 88 assertTrue(compareNode(results[1], expected[0].children[1]), | 81 assertTrue(compareNode(results[1], expected[0].children[1]), |
| 89 "getChildren() result != expected"); | 82 "getChildren() result != expected"); |
| 90 succeed(); | 83 })); |
| 91 }); | |
| 92 }, | 84 }, |
| 93 | 85 |
| 94 function create() { | 86 function create() { |
| 95 var node = {parentId: "1", title:"google", url:"http://www.google.com/"}; | 87 var node = {parentId: "1", title:"google", url:"http://www.google.com/"}; |
| 96 chrome.bookmarks.create(node, function(results) { | 88 chrome.bookmarks.create(node, testFunction(function(results) { |
| 97 assertNoLastError(); | |
| 98 node.id = results.id; // since we couldn't know this going in | 89 node.id = results.id; // since we couldn't know this going in |
| 99 node.index = 0; | 90 node.index = 0; |
| 100 assertTrue(compareNode(node, results), | 91 assertTrue(compareNode(node, results), |
| 101 "created node != source"); | 92 "created node != source"); |
| 102 succeed(); | 93 })); |
| 103 }); | |
| 104 }, | 94 }, |
| 105 ]; | 95 ]; |
| 106 | 96 |
| 107 runNextTest(); | 97 runNextTest(); |
| OLD | NEW |