31 var
file =
Cc[
"@mozilla.org/file/directory_service;1"]
32 .getService(
Ci.nsIProperties)
33 .get(
"resource:app",
Ci.nsIFile);
35 file.append(
"testharness");
36 file.append(
"playlistreader");
37 file.append(fileName);
43 var xmlReader =
Cc[
"@mozilla.org/saxparser/xmlreader;1"]
44 .createInstance(
Ci.nsISAXXMLReader);
46 var failMessage =
null;
48 xmlReader.contentHandler = {
50 startDocument:
function() {
53 endDocument:
function() {
60 if (localName ==
"item-test") {
61 var prop =
attributes.getValueFromName(
"",
"property");
62 if (prop.indexOf(
"#") == 0) {
63 prop =
"http://songbirdnest.com/data/1.0" + prop;
67 value = value.replace(
"%PORT%", aPort);
71 failMessage =
"item with property '" + prop +
"' equal to '" + value +
"' not found";
75 if (localName ==
"assert-property-value" && this._item) {
76 var prop =
attributes.getValueFromName(
"",
"name");
77 if (prop.indexOf(
"#") == 0) {
78 prop =
"http://songbirdnest.com/data/1.0" + prop;
82 value = value.replace(
"%PORT%", aPort);
84 var itemValue = this._item.getProperty(prop);
86 if (itemValue != value) {
87 failMessage =
"item with url '" + this._item.contentSrc.spec +
88 "' does not match result at property '" + prop +
89 "', '" + itemValue +
"' != '" + value +
"'";
94 endElement:
function(
uri, localName, qName) {
97 characters:
function(
value) {
100 processingInstruction:
function(
target,
data) {
103 ignorableWhitespace:
function(whitespace) {
106 startPrefixMapping:
function(prefix,
uri) {
109 endPrefixMapping:
function(prefix) {
114 if(!iid.equals(
Ci.nsISupports) &&
115 !iid.equals(
Ci.nsISAXContentHandler))
116 throw Cr.NS_ERROR_NO_INTERFACE;
121 var
istream =
Cc[
"@mozilla.org/network/file-input-stream;1"]
122 .createInstance(
Ci.nsIFileInputStream);
123 istream.init(aItemTestsFile, 0x01, 0444, 0);
124 xmlReader.parseFromStream(istream,
null,
"text/xml");
127 xmlReader.contentHandler =
null;
138 onEnumerationBegin:
function() {
140 onEnumeratedItem:
function(list, item) {
142 return Components.interfaces.sbIMediaListEnumerationListener.CANCEL;
144 onEnumerationEnd:
function() {
148 aMediaList.enumerateItemsByProperty(aProperty,
151 Ci.sbIMediaList.ENUMERATIONTYPE_LOCKING);
153 return listener.item;
sbOSDControlService prototype QueryInterface
function assertMediaList(aMediaList, aItemTestsFile, aPort)
function getFirstItemByProperty(aMediaList, aProperty, aValue)
function getFile(fileName)
Some globally useful stuff for the playlistreader tests.