31 var
TEST_STRING =
"The quick brown fox jumps over the lazy dog. Bitches."
39 Cc[
"@mozilla.org/binaryinputstream;1"].
41 wrapper.setInputStream(stream);
47 var bytes = wrapper.readByteArray(Math.min(65535,
count));
48 data.push(
String.fromCharCode.apply(
null, bytes));
49 count -= bytes.length;
50 if (bytes.length == 0)
51 do_throw(
"Nothing read from input stream!");
57 var
file = Components.classes[
"@mozilla.org/file/directory_service;1"]
58 .getService(Components.interfaces.nsIProperties)
59 .get(
"TmpD", Components.interfaces.nsIFile);
61 file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0664);
62 var registerFileForDelete =
Cc[
"@mozilla.org/uriloader/external-helper-app-service;1"]
63 .getService(
Ci.nsPIExternalAppLauncher);
64 registerFileForDelete.deleteTemporaryFileOnExit(file);
66 log(
"newTempURI = " + retval.spec );
71 return library.createMediaItem(
newURI(
url));
75 var test_value = item[ attrib ];
77 if ( test_value.spec )
78 test_value = test_value.spec;
85 log(
"testSet: " + attrib +
" -> " +
value);
86 item[ attrib ] =
value;
95 var is_available_observer = {
97 _available: available,
98 _completion: completion,
100 if ( aTopic ==
"available" ) {
101 log(
"(sbIMediaItem::TestIsURIAvailable) COMPLETE " + this._item.contentSrc.spec +
": " + aTopic +
" == " +
aData );
103 if ( this._completion !=
null )
113 if (!iid.equals(Components.interfaces.nsIObserver) &&
114 !iid.equals(Components.interfaces.nsISupports))
115 throw Components.results.NS_ERROR_NO_INTERFACE;
121 item.testIsURIAvailable( is_available_observer );
123 log(
"(sbIMediaItem::TestIsURIAvailable) START " +
url );
127 var databaseGUID =
"test_mediaitem_isuriavailable";
148 onDataAvailable:
function LLL_onDataAvailable(request, context, inputStream,
149 sourceOffset,
count) {
159 onStartRequest:
function LLL_onStartRequest(request, context) {
165 onStopRequest:
function LLL_onStopReqeust(request, context, status) {
175 if (iid.equals(
Ci.nsIStreamListener) ||
176 iid.equals(
Ci.nsIRequestObserver)||
177 iid.equals(
Ci.nsISupports))
179 throw Cr.NS_ERROR_NO_INTERFACE;
182 var inputChannel = ioItem.openInputStreamAsync(listener,
null);
184 listener._inputChannel = inputChannel;
190 gServer =
Cc[
"@mozilla.org/server/jshttp;1"]
191 .createInstance(
Ci.nsIHttpServer);
193 var databaseGUID =
"test_mediaitem";
197 var item = testlib.getMediaItem(
"3E586C1A-AD99-11DB-9321-C22AB7121F49");
200 testGet( item,
"library", testlib );
201 testGet( item,
"isMutable",
true );
202 testGet( item,
"mediaCreated", 1169855962000 );
203 testGet( item,
"mediaUpdated", 1169855962000 );
204 testGet( item,
"contentSrc",
"file:///home/steve/Hells%20Bells.mp3" );
205 testGet( item,
"contentLength", 0x21C );
206 testGet( item,
"contentType",
"audio/mpeg" );
209 testSet( item,
"mediaCreated", 0x1337baadf00d );
210 testSet( item,
"mediaUpdated", 0x1337baadf00d );
211 var newSrc =
newURI(
"file:///poo/MyTrack.mp3");
212 testSet( item,
"contentSrc", newSrc);
213 testSet( item,
"contentLength", 0xbaadf00d );
214 testSet( item,
"contentType",
"x-media/x-poo" );
216 item.setProperty(
"newpropertyneverseenever",
"valuevalue");
219 var ioItem = testlib.createMediaItem(
newTempURI(
"test_mediaitem") );
221 var outputStream = ioItem.openOutputStream();
227 outputStream.flush();
228 outputStream.close();
231 var inputStream = ioItem.openInputStream().QueryInterface(Components.interfaces.nsILineInputStream);
234 inputStream.readLine( out );
function sleep(ms, suppressOutput)
function assertNotEqual(aExpected, aActual, aMessage)
sbOSDControlService prototype QueryInterface
function assertEqual(aExpected, aActual, aMessage)
function getFile(fileName)
function newFileURI(file)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function getTestServerPortNumber()
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe