33 var
SB_NS =
"http://songbirdnest.com/data/1.0#";
34 var
ios =
Cc[
"@mozilla.org/network/io-service;1"].getService(
Ci.nsIIOService);
36 var databaseGUID =
"test_batchcreate";
39 var toAdd =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"].createInstance(
Ci.nsIMutableArray);
40 var propertyArray =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"].createInstance(
Ci.nsIMutableArray);
41 for (var
i = 1;
i < 101;
i++) {
42 toAdd.appendElement(
newURI(
"file:///foo/" +
i +
".mp3"),
false);
43 var props =
Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
44 .createInstance(
Ci.sbIMutablePropertyArray);
45 props.appendProperty(SB_NS +
"contentLength",
i);
46 props.appendProperty(SB_NS +
"trackNumber",
i);
47 propertyArray.appendElement(props,
false);
51 library.addListener(libraryListener);
53 var added = library.batchCreateMediaItems(toAdd, propertyArray);
55 var e = added.enumerate();
56 while(e.hasMoreElements()) {
57 var item = e.getNext();
61 onEnumerationBegin:
function() {
63 onEnumeratedItem:
function(list, item) {
65 return Ci.sbIMediaListEnumerationListener.CANCEL;
67 onEnumerationEnd:
function() {
71 library.enumerateItemsByProperty(
"http://songbirdnest.com/data/1.0#contentURL",
74 Ci.sbIMediaList.ENUMERATIONTYPE_SNAPSHOT);
78 assertEqual(listener._item.getProperty(SB_NS +
"contentLength"),
79 item.getProperty(SB_NS +
"contentLength"));
80 assertEqual(listener._item.getProperty(SB_NS +
"trackNumber"),
81 item.getProperty(SB_NS +
"trackNumber"));
86 for (var
i = 1;
i < 101;
i++) {
87 assertEqual(libraryListener.added[
i - 1].item.contentSrc.spec,
"file:///foo/" +
i +
".mp3");
89 libraryListener.reset();
92 toAdd =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"].createInstance(
Ci.nsIMutableArray);
93 propertyArray =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"].createInstance(
Ci.nsIMutableArray);
94 for (var
i = 1;
i < 101;
i++) {
95 toAdd.appendElement(
newURI(
"file:///foo/duplicate.mp3"),
false);
96 var props =
Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
97 .createInstance(
Ci.sbIMutablePropertyArray);
98 props.appendProperty(SB_NS +
"contentLength",
i);
99 props.appendProperty(SB_NS +
"trackNumber",
i);
100 propertyArray.appendElement(props,
false);
103 added = library.batchCreateMediaItems(toAdd, propertyArray,
true);
106 for (var
i = 1;
i < 101;
i++) {
107 assertEqual(libraryListener.added[
i - 1].item.contentSrc.spec,
"file:///foo/duplicate.mp3");
110 library.removeListener(libraryListener);
function runTest()
Test file.
function assertEqual(aExpected, aActual, aMessage)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
_getSelectedPageStyle s i
function TestMediaListListener()