29 var
file =
Cc[
"@mozilla.org/file/directory_service;1"]
30 .getService(
Ci.nsIProperties)
31 .get(
"resource:app",
Ci.nsIFile);
33 file.append(
"testharness");
34 file.append(
"playlistwriter");
35 file.append(fileName);
41 var xmlReader =
Cc[
"@mozilla.org/saxparser/xmlreader;1"]
42 .createInstance(
Ci.nsISAXXMLReader);
44 var failMessage =
null;
46 xmlReader.contentHandler = {
48 startDocument:
function() {
51 endDocument:
function() {
54 startElement:
function(
uri,
61 if (localName ==
"item-test") {
62 var prop =
attributes.getValueFromName(
"",
"property");
63 if (prop.indexOf(
"#") == 0) {
64 prop =
"http://songbirdnest.com/data/1.0" + prop;
68 value = value.replace(
"%PORT%", aPort);
72 failMessage =
"item with property '" + prop +
73 "' equal to '" + value +
"' not found";
77 if (localName ==
"assert-property-value" && this._item) {
78 var prop =
attributes.getValueFromName(
"",
"name");
79 if (prop.indexOf(
"#") == 0) {
80 prop =
"http://songbirdnest.com/data/1.0" + prop;
84 value = value.replace(
"%PORT%", aPort);
86 var itemValue = this._item.getProperty(prop);
88 if (itemValue != value) {
89 failMessage =
"item with url '" + this._item.contentSrc.spec +
90 "' does not match result at property '" + prop +
91 "', '" + itemValue +
"' != '" + value +
"'";
96 endElement:
function(
uri, localName, qName) {
99 characters:
function(
value) {
102 processingInstruction:
function(
target,
data) {
105 ignorableWhitespace:
function(whitespace) {
108 startPrefixMapping:
function(prefix,
uri) {
111 endPrefixMapping:
function(prefix) {
116 if(!iid.equals(
Ci.nsISupports) &&
117 !iid.equals(
Ci.nsISAXContentHandler))
118 throw Cr.NS_ERROR_NO_INTERFACE;
123 var
istream =
Cc[
"@mozilla.org/network/file-input-stream;1"]
124 .createInstance(
Ci.nsIFileInputStream);
125 istream.init(aItemTestsFile, 0x01, 0444, 0);
126 xmlReader.parseFromStream(istream,
null,
"text/xml");
129 xmlReader.contentHandler =
null;
140 onEnumerationBegin:
function() {
142 onEnumeratedItem:
function(list, item) {
144 return Components.interfaces.sbIMediaListEnumerationListener.CANCEL;
146 onEnumerationEnd:
function() {
150 aMediaList.enumerateItemsByProperty(aProperty,
153 Ci.sbIMediaList.ENUMERATIONTYPE_LOCKING);
155 return listener.item;
function getFirstItemByProperty(aMediaList, aProperty, aValue)
sbOSDControlService prototype QueryInterface
function getFile(fileName)
Some globally useful stuff for the playlistreader tests.
function assertMediaList(aMediaList, aItemTestsFile, aPort)