33 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
35 var databaseGUID =
"test_allowduplicates";
38 var
uri =
newURI(
"http://example.com/foo.mp3");
41 var item1 = library.createMediaItem(uri);
42 var item2 = library.createMediaItem(uri);
46 var item3 = library.createMediaItem(uri,
null,
true);
51 var toAdd =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"].createInstance(
Ci.nsIMutableArray);
52 toAdd.appendElement(
newURI(
"http://example.com/foo.mp3"),
false);
53 toAdd.appendElement(
newURI(
"http://example.com/foo.mp3"),
false);
54 toAdd.appendElement(
newURI(
"http://example.com/foo1.mp3"),
false);
55 toAdd.appendElement(
newURI(
"http://example.com/foo1.mp3"),
false);
57 var added = library.batchCreateMediaItems(toAdd);
61 var added = library.batchCreateMediaItems(toAdd);
65 var added = library.batchCreateMediaItems(toAdd,
null,
true);
75 onProgress:
function(index) {
83 for (var
i = 0;
i <
array.length;
i++) {
84 var mediaItem =
array.queryElementAt(
i,
Ci.sbIMediaItem);
85 var originURL = mediaItem.getProperty(SBProperties.originURL);
89 this.that.testFinished();
96 Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"].createInstance(
Ci.nsIMutableArray);
97 for (var
i = 0;
i < toAdd.length;
i++) {
98 var uri = toAdd.queryElementAt(
i,
Ci.nsIURI);
99 var properties = [ [ SBProperties.originURL, uri.spec ] ];
100 toAddProps.appendElement(SBProperties.createArray(properties),
false);
104 listener.arrayLength = 2;
105 listener.libraryLength = 2;
106 library.batchCreateMediaItemsAsync(listener, toAdd, toAddProps);
110 listener.arrayLength = 0;
111 listener.libraryLength = 2;
112 library.batchCreateMediaItemsAsync(listener, toAdd, toAddProps);
116 listener.arrayLength = 4;
117 listener.libraryLength = 6;
118 library.batchCreateMediaItemsAsync(listener, toAdd, toAddProps,
true);
function runTest()
Test file.
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function assertFalse(aTest, aMessage)
_getSelectedPageStyle s i