Chromium Code Reviews| 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 setMetaInfoUnmodifiable() { | |
| 345 bookmarks.getTree(pass(function(nodes) { | |
| 346 var unmodifiableFolder = nodes[0].children[0]; | |
| 347 bookmarkManager.setMetaInfo(unmodifiableFolder.id, 'meta', 'foo', fail( | |
|
Jeffrey Yasskin
2014/09/26 01:19:19
I saw two checks in the real code, for !CanBeModif
Rune Fevang
2014/09/26 20:44:06
Done.
| |
| 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 | |
| 344 function updateMetaInfo() { | 354 function updateMetaInfo() { |
| 345 bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){ | 355 bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){ |
| 346 assertEq({}, result); | 356 assertEq({}, result); |
| 347 })); | 357 })); |
| 348 | 358 |
| 349 chrome.test.listenOnce(bookmarkManager.onMetaInfoChanged, pass( | 359 chrome.test.listenOnce(bookmarkManager.onMetaInfoChanged, pass( |
| 350 function(id, changes) { | 360 function(id, changes) { |
| 351 assertEq(nodeB.id, id); | 361 assertEq(nodeB.id, id); |
| 352 assertEq({a: 'a', b: 'b', c: 'c'}, changes); | 362 assertEq({a: 'a', b: 'b', c: 'c'}, changes); |
| 353 })); | 363 })); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 377 })); | 387 })); |
| 378 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( | 388 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( |
| 379 function(createdNode) { | 389 function(createdNode) { |
| 380 assertEq(node.title, createdNode.title); | 390 assertEq(node.title, createdNode.title); |
| 381 assertEq(node.url, createdNode.url); | 391 assertEq(node.url, createdNode.url); |
| 382 })); | 392 })); |
| 383 } | 393 } |
| 384 ]; | 394 ]; |
| 385 | 395 |
| 386 chrome.test.runTests(tests); | 396 chrome.test.runTests(tests); |
| OLD | NEW |