summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-18 19:23:55 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-18 19:23:55 +0000
commita3c94c713dcf12e7d95b7c4548137d7beb790e9c (patch)
tree3cc374f21b4eaca2b5a1ff27850f62a19c28f4f8 /chrome/test
parent761caa4b594ceb7ce534f0abc8e68243204b900d (diff)
downloadchromium_src-a3c94c713dcf12e7d95b7c4548137d7beb790e9c.zip
chromium_src-a3c94c713dcf12e7d95b7c4548137d7beb790e9c.tar.gz
chromium_src-a3c94c713dcf12e7d95b7c4548137d7beb790e9c.tar.bz2
Adds bookmarks.getRecent that returns the recently bookmarked items.
BUG=None TEST=browser_tests.exe --gtest_filter=ExtensionApiTest.FLAKY_Bookmarks Review URL: http://codereview.chromium.org/503053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34972 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/bookmarks/test.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/bookmarks/test.js b/chrome/test/data/extensions/api_test/bookmarks/test.js
index eb32dcc..d96f41f 100644
--- a/chrome/test/data/extensions/api_test/bookmarks/test.js
+++ b/chrome/test/data/extensions/api_test/bookmarks/test.js
@@ -348,4 +348,60 @@ chrome.test.runTests([
chrome.test.resetQuota();
},
+
+ function getRecent_setup() {
+ // Clean up tree
+ ["1", "2"].forEach(function(id) {
+ chrome.bookmarks.getChildren(id, pass(function(children) {
+ children.forEach(function(child, i) {
+ chrome.bookmarks.removeTree(child.id, pass(function() {}));
+
+ // When we have removed the last child we can continue.
+ if (i == children.length - 1)
+ afterRemove();
+ });
+ }));
+ });
+
+ function afterRemove() {
+ // Once done add 3 nodes
+ chrome.bookmarks.getTree(pass(function(results) {
+ chrome.test.assertEq(0, results[0].children[0].children.length);
+ chrome.test.assertEq(0, results[0].children[1].children.length);
+ expected = results;
+
+ // Reset the nodes
+ node1 = {parentId:"1", title:"Foo bar baz",
+ url:"http://www.example.com/hello"};
+ node2 = {parentId:"1", title:"foo quux",
+ url:"http://www.example.com/bar"};
+ node3 = {parentId:"1", title:"bar baz",
+ url:"http://www.google.com/hello/quux"};
+ createThreeNodes(node1, node2, node3);
+ }));
+ }
+ },
+
+ function getRecent() {
+ var failed = false;
+ try {
+ chrome.bookmarks.getRecent(0, function() {});
+ } catch (ex) {
+ failed = true;
+ }
+ chrome.test.assertTrue(failed, "Calling with 0 should fail");
+
+ chrome.bookmarks.getRecent(10000, pass(function(results) {
+ chrome.test.assertEq(3, results.length,
+ "Should have gotten all recent bookmarks");
+ }));
+
+ chrome.bookmarks.getRecent(2, pass(function(results) {
+ chrome.test.assertEq(2, results.length,
+ "Should only get the last 2 bookmarks");
+
+ chrome.test.assertTrue(compareNode(node3, results[0]));
+ chrome.test.assertTrue(compareNode(node2, results[1]));
+ }));
+ }
]);