test_localizableequalizerpreset.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN NIGHTINGALE GPL
4 //
5 // This file is part of the Nightingale web player.
6 //
7 // http://getnightingale.com
8 //
9 // This file may be licensed under the terms of of the
10 // GNU General Public License Version 2 (the "GPL").
11 //
12 // Software distributed under the License is distributed
13 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
14 // express or implied. See the GPL for the specific language
15 // governing rights and limitations.
16 //
17 // You should have received a copy of the GPL along with this
18 // program. If not, go to http://www.gnu.org/licenses/gpl.html
19 // or write to the Free Software Foundation, Inc.,
20 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 //
22 // END NIGHTINGALE GPL
23 //
24 */
25 
26 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
27 Components.utils.import("resource://app/jsmodules/ArrayConverter.jsm");
28 
29 if (typeof(Cc) == "undefined")
30  this.Cc = Components.classes;
31 if (typeof(Ci) == "undefined")
32  this.Ci = Components.interfaces;
33 if(!Cr)
34  this.Cr = Components.results;
35 
36 function runTest() {
37  var localizablePreset = Cc["@getnightingale.com/equalizer-presets/localizable;1"]
38  .createInstance(Ci.ngILocalizableEqualizerPreset);
39 
40  assertEqual(localizablePreset.values, null, "Values are already defined");
41 
42  var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"]
43  .getService(Ci.nsIStringBundleService)
44  .createBundle("chrome://songbird/locale/songbird.properties");
45 
46  localizablePreset.property = "equalizer.preset.rock"
47  localizablePreset.stringBundle = stringBundle;
48  assertEqual(localizablePreset.name,
49  stringBundle.GetStringFromName("equalizer.preset.rock"),
50  "Name not set correctly");
51 
52  localizablePreset.setValues(ArrayConverter.nsIArray([0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]));
53  assertTrue(localizablePreset.values, "Values not defined even though previously set");
54  assertEqual(localizablePreset.values.length, 10, "Not all values were written into the array");
55 
56  return;
57 }
const Cc
function runTest()
Advanced DataRemote unit tests.
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
return null
Definition: FeedWriter.js:1143
const Cr
const Ci