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 providerManager =
Cc[
"@getnightingale.com/equalizer-presets/manager;1"]
36 .getService(
Ci.ngIEqualizerPresetProviderManager);
38 assertTrue(providerManager.providers.length >= 2,
"Not all providers were registered");
39 assertTrue(providerManager.presets.length >= 17,
"Not all presets are offered by the manager");
41 var presetName = providerManager.presets.enumerate().getNext()
42 .QueryInterface(
Ci.ngIEqualizerPreset).name;
44 var collection = providerManager.QueryInterface(
Ci.ngIEqualizerPresetCollection);
45 assertTrue(collection.hasPresetNamed(presetName),
46 "Preset wasn't found even though it is in the presets array");
47 assertTrue(collection.getPresetByName(presetName) instanceof
Ci.ngIEqualizerPreset,
48 "Preset returned by getPresetByName isn't actually a preset");
50 var mainProvider =
Cc[
"@getnightingale.com/equalizer-presets/main-provider;1"]
51 .getService(
Ci.ngIMainEqualizerPresetProvider);
53 var
array = [0,0.1,0.2,-0.3,0.4,0.5,0.6,0.7,0.8,0.9];
56 "Presets list was not regenerated after a preset was saved");
58 var otherArray = [-0.1,0,0,0,0,0,0,0,0,0];
61 var presetValues = ArrayConverter.JSArray(collection.getPresetByName(
"test").values);
62 presetValues.forEach(
function(item,
i) {
63 var
value = item.QueryInterface(
Ci.nsISupportsDouble).data;
64 assertEqual(value, otherArray[
i],
"Preset was not overwritten correctly");
67 mainProvider.deletePreset(
"test");
69 "Delete preset was not removed from collection");
77 var
double =
Cc[
"@mozilla.org/supports-double;1"]
78 .createInstance(
Ci.nsISupportsDouble);
82 return ArrayConverter.nsIArray(ret);
function convertArrayToSupportsDouble(array)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
_getSelectedPageStyle s i
function runTest()
Advanced DataRemote unit tests.