test_m3uhandler.js
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
29 function runTest () {
30  var library = createLibrary("test_playlistwriter", null, false);
31  library.clear();
32 
33  var playlistWriter = Cc["@songbirdnest.com/Songbird/PlaylistWriter/M3U;1"]
34  .createInstance(Ci.sbIPlaylistWriter);
35 
36  var ioService = Cc["@mozilla.org/network/io-service;1"]
37  .getService(Ci.nsIIOService);
38  var temporaryFileService =
39  Cc["@songbirdnest.com/Songbird/TemporaryFileService;1"]
40  .getService(Ci.sbITemporaryFileService);
41  var testDir = temporaryFileService.createFile(Ci.nsIFile.DIRECTORY_TYPE);
42 
43  var testMediaList = library.createMediaList("simple");
44 
45  var item1File = testDir.clone();
46  item1File.append("item1.mp3");
47  var item1 = library.createMediaItem(ioService.newFileURI(item1File));
48  testMediaList.add(item1);
49 
50  var item2File = testDir.clone();
51  item2File.append("item2Dir");
52  item2File.append("item2.mp3");
53  var item2 = library.createMediaItem(ioService.newFileURI(item2File));
54  testMediaList.add(item2);
55 
56  var playlistFile = testDir.clone();
57  playlistFile.append("playlist1.m3u");
58 
59  playlistWriter.write(playlistFile, testMediaList, "");
60  assertFilesEqual(playlistFile, getFile("test.m3u"));
61 }
62 
const Cc
var ioService
function getFile(fileName)
function assertFilesEqual(aFile1, aFile2, aMessage)
return null
Definition: FeedWriter.js:1143
function createLibrary(databaseGuid, databaseLocation)
Definition: test_load.js:151
const Ci
function runTest()
Test file.