33 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
34 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
38 var outValuesCount = {};
40 var builder =
Cc[
"@songbirdnest.com/Songbird/Library/ConstraintBuilder;1"]
41 .createInstance(
Ci.sbILibraryConstraintBuilder);
45 fail(
"did not throw");
53 fail(
"did not throw");
60 builder.include(SBProperties.artistName,
"The Beatles")
63 fail(
"did not throw");
69 builder =
Cc[
"@songbirdnest.com/Songbird/Library/ConstraintBuilder;1"]
70 .createInstance(
Ci.sbILibraryConstraintBuilder);
72 var c = builder.include(SBProperties.artistName,
"The Beatles").get();
74 var g = c.getGroup(0);
75 assertEqual(g.properties.getNext(), SBProperties.artistName);
76 assertEqual(g.getValues(SBProperties.artistName).getNext(),
"The Beatles");
78 c = builder.include(SBProperties.artistName,
"The Beatles")
80 .include(SBProperties.albumName,
"Abbey Road")
81 .include(SBProperties.albumName,
"Let It Be").get();
84 var g = c.getGroup(0);
85 assertEqual(g.properties.getNext(), SBProperties.artistName);
86 assertEqual(g.getValues(SBProperties.artistName).getNext(),
"The Beatles");
88 assertEqual(g.properties.getNext(), SBProperties.albumName);
89 var values = g.getValues(SBProperties.albumName);
96 [SBProperties.artistName, [
"hello"]],
97 [SBProperties.artistName, [
"world"]]
103 [SBProperties.artistName, [
"world",
"hello"]]
110 [SBProperties.artistName, [
"hello"]]
113 [SBProperties.albumName, [
"world"]],
114 [SBProperties.trackName, [
"trackName"]],
115 [SBProperties.genre, [
"rock",
"pop",
"jazz"]]
121 [SBProperties.genre, [
"rock",
"pop",
"jazz"]],
122 [SBProperties.albumName, [
"world"]],
123 [SBProperties.trackName, [
"trackName"]]
126 [SBProperties.artistName, [
"hello"]],
133 [SBProperties.genre, [
"rock",
"pop",
"jazz"]],
134 [SBProperties.trackName, [
"trackName"]]
137 [SBProperties.artistName, [
"hello"]],
145 var sort =
Cc[
"@songbirdnest.com/Songbird/Library/Sort;1"]
146 .createInstance(
Ci.sbILibrarySort);
150 fail(
"Did not throw");
156 sort.init(SBProperties.artistName,
true);
159 sort.init(SBProperties.artistName,
true);
160 fail(
"Did not throw");
166 assertEqual(sort.property, SBProperties.artistName);
170 assertEqual(newSort.property, SBProperties.artistName);
177 var pipe =
Cc[
"@mozilla.org/pipe;1"].createInstance(
Ci.nsIPipe);
178 pipe.init(
false,
false, 0, 0xffffffff,
null);
180 var oos =
Cc[
"@mozilla.org/binaryoutputstream;1"]
181 .createInstance(
Ci.nsIObjectOutputStream);
182 oos.setOutputStream(pipe.outputStream);
183 oos.writeObject(o,
true);
186 var ois =
Cc[
"@mozilla.org/binaryinputstream;1"]
187 .createInstance(
Ci.nsIObjectInputStream);
188 ois.setInputStream(pipe.inputStream);
189 var read = ois.readObject(
true)
function runTest()
Test file.
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function assertFalse(aTest, aMessage)
Javascript wrappers for common library tasks.