OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Bookmark Manager API test for Chrome. | 5 // Bookmark Manager API test for Chrome. |
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.BookmarkManager | 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.BookmarkManager |
7 | 7 |
8 const pass = chrome.test.callbackPass; | 8 const pass = chrome.test.callbackPass; |
9 const fail = chrome.test.callbackFail; | 9 const fail = chrome.test.callbackFail; |
10 const assertEq = chrome.test.assertEq; | 10 const assertEq = chrome.test.assertEq; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 bookmarkManager.setMetaInfo(nodeA.id, 'meta2', 'foo'); | 334 bookmarkManager.setMetaInfo(nodeA.id, 'meta2', 'foo'); |
335 bookmarkManager.getMetaInfo(nodeA.id, 'meta', pass(function(result) { | 335 bookmarkManager.getMetaInfo(nodeA.id, 'meta', pass(function(result) { |
336 assertEq('bla', result); | 336 assertEq('bla', result); |
337 })); | 337 })); |
338 | 338 |
339 bookmarkManager.getMetaInfo(nodeA.id, pass(function(result) { | 339 bookmarkManager.getMetaInfo(nodeA.id, pass(function(result) { |
340 assertEq({meta: 'bla', meta2: 'foo'}, result); | 340 assertEq({meta: 'bla', meta2: 'foo'}, result); |
341 })); | 341 })); |
342 }, | 342 }, |
343 | 343 |
| 344 function setMetaInfoPermanent() { |
| 345 bookmarks.getTree(pass(function(nodes) { |
| 346 var unmodifiableFolder = nodes[0].children[0]; |
| 347 bookmarkManager.setMetaInfo(unmodifiableFolder.id, 'meta', 'foo', fail( |
| 348 "Can't modify the root bookmark folders.")); |
| 349 bookmarkManager.updateMetaInfo(unmodifiableFolder.id, {a: 'a', b: 'b'}, |
| 350 fail("Can't modify the root bookmark folders.")); |
| 351 })); |
| 352 }, |
| 353 |
| 354 function setMetaInfoManaged() { |
| 355 bookmarks.getChildren('4', pass(function(result) { |
| 356 assertTrue(result.length > 0); |
| 357 bookmarkManager.setMetaInfo(result[0].id, 'meta', 'foo', fail( |
| 358 "Can't modify managed bookmarks.")); |
| 359 bookmarkManager.updateMetaInfo(result[0].id, {a: 'a', b: 'b'}, |
| 360 fail("Can't modify managed bookmarks.")); |
| 361 })); |
| 362 }, |
| 363 |
344 function updateMetaInfo() { | 364 function updateMetaInfo() { |
345 bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){ | 365 bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){ |
346 assertEq({}, result); | 366 assertEq({}, result); |
347 })); | 367 })); |
348 | 368 |
349 chrome.test.listenOnce(bookmarkManager.onMetaInfoChanged, pass( | 369 chrome.test.listenOnce(bookmarkManager.onMetaInfoChanged, pass( |
350 function(id, changes) { | 370 function(id, changes) { |
351 assertEq(nodeB.id, id); | 371 assertEq(nodeB.id, id); |
352 assertEq({a: 'a', b: 'b', c: 'c'}, changes); | 372 assertEq({a: 'a', b: 'b', c: 'c'}, changes); |
353 })); | 373 })); |
(...skipping 23 matching lines...) Expand all Loading... |
377 })); | 397 })); |
378 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( | 398 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( |
379 function(createdNode) { | 399 function(createdNode) { |
380 assertEq(node.title, createdNode.title); | 400 assertEq(node.title, createdNode.title); |
381 assertEq(node.url, createdNode.url); | 401 assertEq(node.url, createdNode.url); |
382 })); | 402 })); |
383 } | 403 } |
384 ]; | 404 ]; |
385 | 405 |
386 chrome.test.runTests(tests); | 406 chrome.test.runTests(tests); |
OLD | NEW |