48 var
ioService =
Cc[
"@mozilla.org/network/io-service;1"]
49 .getService(
Ci.nsIIOService);
50 var fileProtocolHandler = ioService.getProtocolHandler(
"file")
51 .QueryInterface(
Ci.nsIFileProtocolHandler);
54 var temporaryFileService;
56 temporaryFileService =
57 Cc[
"@songbirdnest.com/Songbird/TemporaryFileService;1"]
58 .getService(
Ci.sbITemporaryFileService);
61 "Temporary file service component is not available.");
64 assertTrue(temporaryFileService.rootTemporaryDirectory,
65 "Temporary file service directory is null.");
66 assertTrue(temporaryFileService.rootTemporaryDirectory.exists(),
67 "Temporary file service directory does not exist.");
70 var tmpFile1 = temporaryFileService.createFile(
Ci.nsIFile.NORMAL_FILE_TYPE);
71 assertTrue(tmpFile1,
"Could not create temporary file.");
72 assertTrue(tmpFile1.exists(),
"Temporary file does not exist.");
75 var tmpFile2 = temporaryFileService.createFile(
Ci.nsIFile.NORMAL_FILE_TYPE);
76 assertTrue(tmpFile2,
"Could not create temporary file.");
77 assertTrue(tmpFile2.exists(),
"Temporary file does not exist.");
78 assertTrue(!tmpFile2.equals(tmpFile1),
"Temporary file is not unique.");
81 var fileBaseName =
"test";
82 tmpFile1 = temporaryFileService.createFile(
Ci.nsIFile.NORMAL_FILE_TYPE,
84 assertTrue(tmpFile1,
"Could not create temporary file.");
85 var fileURL = fileProtocolHandler.newFileURI(tmpFile1);
86 fileURL = fileURL.QueryInterface(
Ci.nsIURL);
87 assertEqual(fileURL.fileBaseName.search(fileBaseName), 0);
90 tmpFile1 = temporaryFileService.createFile(
Ci.nsIFile.NORMAL_FILE_TYPE,
93 assertTrue(tmpFile1,
"Could not create temporary file.");
94 assertTrue(tmpFile1.path.match(/\.tst$/),
"File extension incorrect.");
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Advanced DataRemote unit tests.