31 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
57 var dps =
Cc[
"@songbirdnest.com/Songbird/Library/DynamicPlaylistService;1"]
58 .getService(
Ci.sbIDynamicPlaylistService);
60 .getService(
Ci.sbILibraryManager);
68 libraryManager.registerLibrary(library1,
false);
73 var dest =
Cc[
"@mozilla.org/file/directory_service;1"]
74 .getService(
Ci.nsIProperties)
75 .get(
"TmpD",
Ci.nsIFile);
76 var list = dps.createList(library1, uri, 60, dest);
79 assertEqual(list.getProperty(SBProperties.isSubscription),
"1");
80 assertEqual(list.getProperty(SBProperties.base +
"subscriptionURL"), uri.spec);
81 assertEqual(list.getProperty(SBProperties.base +
"subscriptionInterval"),
"60");
84 var scheduled = dps.scheduledLists.getNext();
88 libraryManager.unregisterLibrary(library1);
92 libraryManager.registerLibrary(library1,
false);
93 assertTrue(dps.scheduledLists.getNext(), list);
96 library1.remove(list);
99 libraryManager.unregisterLibrary(library1);
105 .getService(
Ci.sbILibraryManager);
108 libraryManager.registerLibrary(library1,
false);
110 var playlistFile =
getFile(
"test_dynamicplaylist_playlist.m3u");
113 var
server =
Cc[
"@mozilla.org/server/jshttp;1"]
114 .createInstance(
Ci.nsIHttpServer);
117 server.start(PORT_NUMBER);
118 server.registerDirectory(
"/",
getFile(
"."));
120 var dps =
Cc[
"@songbirdnest.com/Songbird/Library/DynamicPlaylistService;1"]
121 .getService(
Ci.sbIDynamicPlaylistService);
123 var dest =
Cc[
"@mozilla.org/file/directory_service;1"]
124 .getService(
Ci.nsIProperties)
125 .get(
"TmpD",
Ci.nsIFile);
127 var
url =
"http://localhost:" + PORT_NUMBER +
128 "/test_dynamicplaylist_playlist.m3u";
130 var list = dps.createList(library1,
newURI(url), 60, dest);
138 while (list.length < 2 && sleepCount++ < 20) {
146 for (sleepCount = 0; sleepCount < 20; ++sleepCount) {
147 if (list.getItemByIndex(0).getProperty(SBProperties.trackName) ==
"test1 title" &&
148 list.getItemByIndex(1).getProperty(SBProperties.trackName) ==
"test2 title")
154 assertEqual(list.getItemByIndex(0).getProperty(SBProperties.trackName),
"test1 title");
155 assertEqual(list.getItemByIndex(1).getProperty(SBProperties.trackName),
"test2 title");
162 while (list.length < 3 && sleepCount++ < 20) {
169 for (sleepCount = 0; sleepCount < 20; ++sleepCount) {
170 if (list.getItemByIndex(0).getProperty(SBProperties.trackName) ==
"test1 title" &&
171 list.getItemByIndex(1).getProperty(SBProperties.trackName) ==
"test2 title" &&
172 list.getItemByIndex(2).getProperty(SBProperties.trackName) ==
"test3 title")
178 assertEqual(list.getItemByIndex(0).getProperty(SBProperties.trackName),
"test1 title");
179 assertEqual(list.getItemByIndex(1).getProperty(SBProperties.trackName),
"test2 title");
180 assertEqual(list.getItemByIndex(2).getProperty(SBProperties.trackName),
"test3 title");
185 server.stop(
function() {});
187 libraryManager.unregisterLibrary(library1);
194 .getService(
Ci.sbILibraryManager);
197 libraryManager.registerLibrary(library1,
false);
200 var dps =
Cc[
"@songbirdnest.com/Songbird/Library/DynamicPlaylistService;1"]
201 .getService(
Ci.sbIDynamicPlaylistService);
203 var podcast = dps.createPodcast(library1, uri);
205 assertEqual(podcast.getProperty(SBProperties.customType),
"podcast");
208 libraryManager.unregisterLibrary(library1);
213 var foStream =
Cc[
"@mozilla.org/network/file-output-stream;1"]
214 .createInstance(
Ci.nsIFileOutputStream);
216 foStream.init(
file, 0x02 | 0x08 | 0x20, 0664, 0);
function sleep(ms, suppressOutput)
function writeFile(file, data)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function server(port, basePath)
function getFile(fileName)
function newFileURI(file)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function assertFalse(aTest, aMessage)
function testRegistration()
function getTestServerPortNumber()
function runTest()
Advanced DataRemote unit tests.