test_manager.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
31 function runTest () {
32 
33  var library = createLibrary("test_playlistmanager");
34 
35  var manager = Cc["@songbirdnest.com/Songbird/PlaylistReaderManager;1"]
36  .getService(Ci.sbIPlaylistReaderManager);
37  var platform = getPlatform();
38 
39  // Test mime types
40  var mimeTypesCount = {};
41  var mimeTypes = manager.supportedMIMETypes(mimeTypesCount);
42  var expected = ["audio/mpegurl", "audio/x-mpegurl", "audio/x-scpls", "text/html", "application/rss+xml", "application/atom+xml", "video/x-ms-asf"];
43  assertEqual(mimeTypesCount.value, expected.length);
44  for (var i = 0; i < mimeTypesCount.value; i++) {
45  expected = removeFromArray(expected, mimeTypes[i]);
46  }
47  assertEqual(expected.length, 0);
48 
49  // Test extensions
50  var extCount = {};
51  var exts = manager.supportedFileExtensions(extCount);
52  expected = ["pls", "m3u", "m3u8", "html", "htm", "php", "php3", "", "atom", "rss", "asx"];
53  assertEqual(extCount.value, expected.length);
54  for (var i = 0; i < extCount.value; i++) {
55  expected = removeFromArray(expected, exts[i]);
56  }
57  assertEqual(expected.length, 0);
58 
59  // Test read with extension
60  var mediaList = library.createMediaList("simple");
61  var file = getFile("relative_remote.m3u");
62  manager.originalURI = newURI("http://www.foo.com/");
63  manager.read(file, mediaList, null, false);
64  assertMediaList(mediaList, getFile("relative_remote_result.xml"));
65 
66  // Test read with content type
67  mediaList.clear();
68  var file = getFile("relative_remote.pls");
69  manager.originalURI = newURI("http://www.foo.com/");
70  manager.read(file, mediaList, "audio/x-scpls", false);
71  assertMediaList(mediaList, getFile("relative_remote_result.xml"));
72 
73  // Test loadPlaylist, local file
74  mediaList.clear();
75  if (platform == "Windows_NT") {
76  mediaList.clear();
77  var fileUri = getFileUri(getFile("win_parse.m3u"));
78  manager.loadPlaylist(fileUri, mediaList, null, false, null);
79  assertMediaList(mediaList, getFile("win_parsem3u_result.xml"));
80  } else {
81  var fileUri = getFileUri(getFile("maclin_parse.m3u"));
82  manager.loadPlaylist(fileUri, mediaList, null, false, null);
83  assertMediaList(mediaList, getFile("maclin_parsem3u_result.xml"));
84  }
85 
86  // Test loadPlaylist, remote file
87 
88 
89 }
90 
91 function removeFromArray(a, v) {
92 
93  return a.filter(function(e) { return e != v; });
94 
95 }
96 
97 function getFileUri(aFile) {
98  var ioService = Cc["@mozilla.org/network/io-service;1"].
99  getService(Ci.nsIIOService);
100  return ioService.newFileURI(aFile);
101 }
102 
function getFileUri(aFile)
const Cc
function runTest()
Test file.
Definition: test_manager.js:29
function getPlatform()
var ioService
function assertEqual(aExpected, aActual, aMessage)
getService(Ci.sbIFaceplateManager)
function getFile(fileName)
function removeFromArray(a, v)
Definition: test_manager.js:91
return null
Definition: FeedWriter.js:1143
function createLibrary(databaseGuid, databaseLocation)
Definition: test_load.js:151
function newURI(aURLString)
var expected
const Ci
function assertMediaList(aMediaList, aItemTestsFile, aPort)
_getSelectedPageStyle s i
var file