34 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
40 badTestXML =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
41 badTestXML +=
"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n";
44 badTestXML +=
" <key>Major Version</key><integer>1</integer>\n";
45 badTestXML +=
" <key>Minor Version</key><integer>1</integer>\n";
46 badTestXML +=
" <key>Application Version</key><string>8.1</string>\n";
62 Cc[
"@mozilla.org/io/string-input-stream;1"]
63 .createInstance(
Ci.nsIStringInputStream);
64 stream.setData(aString, -1);
73 expectedTopLevelProperties : [
"Major Version",
75 "Application Version",
77 "Show Content Ratings",
79 "Library Persistent ID" ],
80 onTopLevelProperties :
function(aProperties) {
81 var length = this.expectedTopLevelProperties.length;
82 this.topLevelPropertyCount = 0;
83 for (var index =0; index < length; ++index) {
85 if (aProperties.get(
this.expectedTopLevelProperties[index]).length > 0) {
86 ++this.topLevelPropertyCount;
93 onTrack :
function(aProperties) {
96 onTracksComplete :
function() {
97 ++this.onTracksCompleteCount;
99 onPlaylist :
function(aProperties, tracks) {
100 ++this.onPlaylistCount;
102 onPlaylistsComplete :
function () {
103 ++this.onPlaylistsCompleteCount;
104 fail(
"onPlaylistsComplete called when an error should occur");
106 onError :
function(aErrorMessage) {
108 assertEqual(this.topLevelPropertyCount, 0,
"Top level properties do not match");
109 assertEqual(this.onTrackCount, 0,
"Invalid track count for error situation");
110 assertEqual(this.onTracksCompleteCount, 0,
"Invalid track complete count for error situation");
111 assertEqual(this.onPlaylistCount, 0,
"Invalid playlist count for error situation");
112 assertEqual(this.onPlaylistsCompleteCount, 0,
"Invalid playlist complete count for error situation");
113 assertEqual(this.onErrorCount, 1,
"Invalid error count for error situation");
117 onProgress :
function() { },
118 topLevelPropertyCount : 0,
120 onTracksCompleteCount : 0,
122 onPlaylistsCompleteCount : 0,
129 var parser =
Cc[
"@songbirdnest.com/Songbird/sbiTunesXMLParser;1"]
130 .getService(
Ci.sbIiTunesXMLParser);
131 assertTrue(parser,
"iTunes importer component is not available.");
function stringToStream(aString)
sbOSDControlService prototype QueryInterface
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Advanced DataRemote unit tests.