33 const PROP_ISLIST =
"http://songbirdnest.com/data/1.0#isList";
34 const LSP=
'http://songbirdnest.com/rdf/library-servicepane#';
80 servicePane = Components.classes[
'@songbirdnest.com/servicepane/service;1']
81 .getService(Components.interfaces.sbIServicePaneService);
85 .getService(Components.interfaces.sbILibraryServicePaneService);
88 libraryManager = Components.classes[
'@songbirdnest.com/Songbird/library/Manager;1']
89 .getService(Components.interfaces.sbILibraryManager);
102 DBG(
"About to remove all test items from tree");
103 showTree(servicePane.root,
"tree-before-delete: ");
115 DBG(
"Finished removing test items from tree");
116 showTree(servicePane.root,
"tree-after-delete: ");
133 var myCaller =
DBG.caller;
135 log(
'DBG:test_libraryservicepane:' + myCaller.name +
": " +s+
'\n');
143 var
node = root.firstChild;
145 DBG(prefix + node.name +
" [" + node.id +
"]");
147 node = node.nextSibling;
165 DBG(
"About to check library manager against the service tree:");
166 showTree(servicePane.root,
"before-checking-libraries: ");
169 while (libraries.hasMoreElements()) {
170 var library = libraries.getNext();
199 library.setProperty(SBProperties.hidden,
true);
200 library.name =
"Testing createNodeForLibrary";
212 DBG(
"processed " + count +
" libraries");
227 onEnumerationBegin:
function() { },
228 onEnumerationEnd:
function() { },
229 onEnumeratedItem:
function(list, item) {
230 this.items.push(item);
235 aLibrary.enumerateItemsByProperty(
PROP_ISLIST,
"1",
237 Components.interfaces.sbIMediaList.ENUMERATIONTYPE_LOCKING);
240 for (var
i = 0;
i < listener.items.length;
i++) {
281 var mediaList = library.createMediaList(
"simple");
282 mediaList.name =
"test playlist";
309 list1.name =
"Test1";
310 list2.name =
"Test2";
322 var
node = mainLibraryNode.nextSibling;
323 while (node && node.contractid == mainLibraryNode.contractid) {
327 node = node.nextSibling;
337 var bmNode1 = servicePane.createNode();
338 bmNode1.id =
"urn:test:1";
339 servicePane.root.appendChild(bmNode1);
341 var bmNode2 = servicePane.createNode();
342 bmNode1.id =
"urn:test:2";
343 servicePane.root.appendChild(bmNode2);
345 DBG(
"About to move all playlists between some bookmarks");
346 showTree(servicePane.root,
"tree-before-move: ");
347 var type = node1.getAttributeNS(
LSP,
"ListType");
348 node = mainLibraryNode;
350 DBG(
"About to iterate");
351 while (node && node != bmNode1) {
353 DBG(
"checking node " + node.id);
354 if (node.getAttributeNS(
LSP,
"ListType") == type) {
355 DBG(
"moving node " + node.id);
356 node = node.nextSibling;
357 servicePane.root.insertBefore(node.previousSibling, bmNode2);
359 node = node.nextSibling;
362 DBG(
"Finished moving playlists");
363 showTree(servicePane.root,
"tree-after-move: ");
369 list3.name =
"Test3";
371 DBG(
"After adding a new playlist:");
372 showTree(servicePane.root,
"tree-after-add: ");
381 newLibrary.name =
"Test1";
384 DBG(
"After adding a new library:");
385 showTree(servicePane.root,
"tree-after-newlibrary: ");
391 type = newLibraryNode.getAttributeNS(
LSP,
"ListType");
392 node = newLibraryNode.previousSibling;
393 while (node && node.getAttributeNS(
LSP,
"ListType") == type &&
394 node != mainLibraryNode)
396 DBG(
"Scanning backwards from new library to main library: " + node.id);
397 node = node.previousSibling;
403 var list4 = newLibrary.createMediaList(
"simple");
404 list4.name =
"Test4";
406 DBG(
"After adding a playlist into the new library:");
407 showTree(servicePane.root,
"tree-after-newlibrary-playlist: ");
427 DBG(
"About to test library suggestion functionality");
436 newLibrary.name =
"Test2";
444 "simple", newLibraryNode);
450 var list1 = newLibrary.createMediaList(
"simple");
451 list1.name =
"Test1";
459 var list2 = newLibrary.createMediaList(
"simple");
460 list2.name =
"Test2";
468 var bmNode1 = servicePane.createNode();
469 bmNode1.id =
"urn:select-test:1";
470 newLibraryNode.appendChild(bmNode1);
478 var bmNode2 = servicePane.createNode();
479 bmNode2.id =
"urn:select-test:2";
480 servicePane.root.appendChild(bmNode2);
488 "fakemedialisttype",
null);
491 DBG(
"Tree after suggestion testing:");
492 showTree(servicePane.root,
"tree-after-newlibrary: ");
508 DBG(
"About to test library renaming functionality");
511 newLibrary.name =
"Test2";
516 var list1 = newLibrary.createMediaList(
"simple");
517 list1.name =
"Test1";
521 var newName =
"RenameTest1";
522 servicePane.onRename(newLibraryNode, newName);
527 newName =
"RenameTest2";
528 servicePane.onRename(node1, newName);
533 servicePane.onRename(node1,
"");
554 if (
id.
indexOf(
"urn:item") == 0) {
557 }
else if (
id.
indexOf(
"urn:library") == 0) {
function testLibrarySuggestion()
function runTest()
Advanced DataRemote unit tests.
function testAllItemsRemoved()
function assertNotEqual(aExpected, aActual, aMessage)
function assertEqual(aExpected, aActual, aMessage)
return elem filter &&elem filter indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity
function testInsertionLogic()
function testLibraryMediaLists(aLibrary)
function testLibrariesAndContents()
function showTree(root, prefix)
function createLibrary(databaseGuid, databaseLocation)
function testAddingSimplePlaylists()
_getSelectedPageStyle s i
function removeAddedItems()
const DEBUG_OUTPUT
Basic library service pane unit tests.