36 log (
"dumpArray: " +
array +
" (count = " + count +
")");
37 for (var index = 0; index <
count; index++) {
38 var prop =
array.getPropertyAt(index);
39 log(
"array[" + index +
"] = {id: " + prop.id +
", value: " +
46 Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].
50 for (var index = 0; index < 15; index++) {
51 var
id =
"Property" + index;
52 var
value =
"Value" + index;
53 propertyArray.appendProperty(
id, value);
60 Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].
62 for (var index = 10; index < 20; index++) {
63 var
id =
"Property" + index;
64 var
value =
"Value" + index;
65 propertyArray2.appendProperty(
id, value);
70 Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].
72 propertyArray3.appendProperties(propertyArray,
false);
73 propertyArray3.appendProperties(propertyArray2,
false);
77 propertyArray3.clear();
78 propertyArray3.appendProperties(propertyArray,
true);
79 propertyArray3.appendProperties(propertyArray2,
true);
83 var
property = propertyArray.queryElementAt(0,
Ci.sbIProperty);
86 property = propertyArray.queryElementAt(1,
Ci.nsISupports);
92 property = propertyArray.queryElementAt(2,
Ci.nsIFile);
99 property = propertyArray.getPropertyAt(5);
103 var index = propertyArray.indexOf(0, property);
107 var enumerator = propertyArray.enumerate();
109 while (enumerator.hasMoreElements()) {
110 var
property = enumerator.getNext().QueryInterface(
Ci.sbIProperty);
117 var factory =
Cc[
"@songbirdnest.com/Songbird/Properties/PropertyFactory;1"].
119 var newProperty = factory.createProperty(
"NewProperty",
"NewValue");
121 propertyArray.replaceElementAt(newProperty, 9,
false);
123 var replaceException;
125 propertyArray.replaceElementAt(newProperty, 13,
true);
127 replaceException =
true;
131 var testProperty = propertyArray.getPropertyAt(9);
137 newProperty = factory.createProperty(
"SuperNewProperty",
"SuperNewValue");
139 propertyArray.insertElementAt(newProperty, 10,
false);
143 propertyArray.insertElementAt(newProperty, 13,
true);
145 insertException =
true;
149 testProperty = propertyArray.getPropertyAt(9);
152 testProperty = propertyArray.getPropertyAt(11);
155 testProperty = propertyArray.getPropertyAt(10);
161 propertyArray.removeElementAt(10);
163 testProperty = propertyArray.getPropertyAt(9);
166 testProperty = propertyArray.getPropertyAt(10);
169 testProperty = propertyArray.getPropertyAt(11);
175 propertyArray.clear();
181 newTestProperty = propertyArray.getPropertyAt(6);
190 Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].
193 for (var index = 0; index < 10; index++) {
194 var
id =
"Property" + index;
195 var
value =
"Value" + index;
196 propertyArray.appendProperty(
id, value);
198 var pipe =
Cc[
"@mozilla.org/pipe;1"].createInstance(
Ci.nsIPipe);
199 pipe.init(
false,
false, 0, 0xffffffff,
null);
201 var oos =
Cc[
"@mozilla.org/binaryoutputstream;1"]
202 .createInstance(
Ci.nsIObjectOutputStream);
203 oos.setOutputStream(pipe.outputStream);
204 oos.writeObject(propertyArray,
true);
207 var ois =
Cc[
"@mozilla.org/binaryinputstream;1"]
208 .createInstance(
Ci.nsIObjectInputStream);
209 ois.setInputStream(pipe.inputStream);
210 propertyArray = ois.readObject(
true)
213 for (var index = 0; index < 10; index++) {
214 var
property = propertyArray.queryElementAt(index,
Ci.sbIProperty);
220 var
file =
Cc[
"@mozilla.org/file/directory_service;1"]
221 .getService(
Ci.nsIProperties)
222 .get(
"TmpD",
Ci.nsIFile);
224 file.createUnique(
Ci.nsIFile.NORMAL_FILE_TYPE, 0664);
225 var registerFileForDelete =
Cc[
"@mozilla.org/uriloader/external-helper-app-service;1"]
226 .getService(
Ci.nsPIExternalAppLauncher);
227 registerFileForDelete.deleteTemporaryFileOnExit(file);
function dumpArray(array)
function assertNotEqual(aExpected, aActual, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Advanced DataRemote unit tests.
function getTempFile(name)
function assertPropertyData(property, id, value)