26 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
27 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
29 if (typeof(
Cc) ==
"undefined")
30 this.
Cc = Components.classes;
31 if (typeof(
Ci) ==
"undefined")
32 this.
Ci = Components.interfaces;
35 var mainProvider =
Cc[
"@getnightingale.com/equalizer-presets/main-provider;1"]
36 .getService(
Ci.ngIMainEqualizerPresetProvider);
38 assertTrue(mainProvider.presets instanceof
Ci.nsIArray,
"Presets aren't an nsIArray");
39 var initialLength = mainProvider.presets.length;
40 var
array = [0,0.1,0.2,-0.3,0.4,0.5,0.6,0.7,0.8,0.9];
44 mainProvider.presets.length,
45 "Preset isn't in the presets list after saving");
47 var collection = mainProvider.QueryInterface(
Ci.ngIEqualizerPresetCollection);
49 assertTrue(collection.hasPresetNamed(
"test"),
"Preset isn't in the collection");
50 assertTrue(collection.getPresetByName(
"test") instanceof
Ci.ngIEqualizerPreset,
51 "Returned preset doesn't implement ngIEqualizerPreset");
54 var otherArray = [-0.1,0,0,0,0,0,0,0,0,0];
57 var presetValues = ArrayConverter.JSArray(collection.getPresetByName(
"test").values);
58 presetValues.forEach(
function(item,
i) {
59 var
value = item.QueryInterface(
Ci.nsISupportsDouble).data;
60 assertEqual(value, otherArray[
i],
"Preset was not overwritten correctly");
64 mainProvider.deletePreset(
"test");
65 assertTrue(!collection.hasPresetNamed(
"test"),
"Preset wasn't deleted");
73 var
double =
Cc[
"@mozilla.org/supports-double;1"]
74 .createInstance(
Ci.nsISupportsDouble);
78 return ArrayConverter.nsIArray(ret);
function convertArrayToSupportsDouble(array)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Advanced DataRemote unit tests.
_getSelectedPageStyle s i