33 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
34 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
39 var view = library.createView();
41 var cfs = view.cascadeFilterSet;
43 view.setSort(SBProperties.createArray([
44 [SBProperties.artistName,
"a"]
48 [SBProperties.isList, [
"0"]]
51 [SBProperties.hidden, [
"0"]]
56 SBProperties.artistName,
57 SBProperties.albumName,
58 SBProperties.trackName
60 cfs.appendFilter(SBProperties.genre);
61 cfs.appendFilter(SBProperties.artistName);
62 cfs.appendFilter(SBProperties.albumName);
64 cfs.set(0, [
"Beat"], 1);
65 cfs.set(1, [
"ROCK"], 1);
66 cfs.set(2, [
"The Beatles"], 1);
68 var clone = view.clone();
71 [SBProperties.artistName,
"a"]
76 [SBProperties.artistName, [
"Beat"]],
77 [SBProperties.albumName, [
"Beat"]],
78 [SBProperties.trackName, [
"Beat"]]
84 [SBProperties.isList, [
"0"]]
87 [SBProperties.hidden, [
"0"]]
90 [SBProperties.genre, [
"ROCK"]]
93 [SBProperties.artistName, [
"The Beatles"]]
97 var cloneCfs = clone.cascadeFilterSet;
99 for (let
i = 0;
i < cfs.length;
i++) {
104 var state = view.getState();
105 var pipe =
Cc[
"@mozilla.org/pipe;1"].createInstance(
Ci.nsIPipe);
106 pipe.init(
false,
false, 0, 0xffffffff,
null);
108 var oos =
Cc[
"@mozilla.org/binaryoutputstream;1"]
109 .createInstance(
Ci.nsIObjectOutputStream);
110 oos.setOutputStream(pipe.outputStream);
111 oos.writeObject(state,
true);
114 var ois =
Cc[
"@mozilla.org/binaryinputstream;1"]
115 .createInstance(
Ci.nsIObjectInputStream);
116 ois.setInputStream(pipe.inputStream);
117 var newState = ois.readObject(
true)
120 var newView = library.createView(newState);
123 [SBProperties.artistName,
"a"]
127 [SBProperties.artistName, [
"Beat"]],
128 [SBProperties.albumName, [
"Beat"]],
129 [SBProperties.trackName, [
"Beat"]]
135 [SBProperties.isList, [
"0"]]
138 [SBProperties.hidden, [
"0"]]
141 [SBProperties.genre, [
"ROCK"]]
144 [SBProperties.artistName, [
"The Beatles"]]
148 var newCfs = newView.cascadeFilterSet;
150 for (let
i = 0;
i < cfs.length;
i++) {
157 if (a1.length != a2.length) {
158 fail(
"Property array lengths differ, " + a1 +
162 for(var
i = 0;
i < a1.length;
i++) {
163 var prop1 = a1.getPropertyAt(
i);
164 var prop2 = a2.getPropertyAt(
i);
165 if (prop1.id != prop2.id) {
166 fail(
"Names are different at index " +
i +
", " +
167 prop1 +
" != " + prop2);
169 if (prop1.value != prop2.value) {
170 fail(
"Values are different at index " +
i +
", " +
171 prop1 +
" != " + prop2);
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function createLibrary(databaseGuid, databaseLocation)
Javascript wrappers for common library tasks.
_getSelectedPageStyle s i