32 var textInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Text;1"]
33 .createInstance(
Ci.sbITextPropertyInfo);
40 textInfo.type =
"mytype";
46 textInfo.id =
"TextInfo";
51 textInfo.id =
"MyTextInfo";
57 textInfo.localizationKey =
"My localization key";
58 assertEqual(textInfo.localizationKey,
"My localization key");
60 textInfo.displayName =
"My Display Name";
61 assertEqual(textInfo.displayName,
"My Display Name");
63 var sample =
"some text";
67 textInfo.minLength = 10;
71 textInfo.maxLength = 10;
72 sample =
"way way way too long";
75 sample =
"just right";
78 textInfo.enforceLowercase =
true;
79 sample =
"JUST RIGHT";
85 sample =
" whitespace";
88 var formatted = textInfo.format(sample);
96 var numberInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Number;1"]
97 .createInstance(
Ci.sbINumberPropertyInfo);
99 numberInfo.id =
"NumberInfo";
102 var sample =
"not a number";
105 numberInfo.format(sample);
114 assertEqual(numberInfo.makeSearchable(sample),
"+0000000000000000001");
116 numberInfo.radix =
Ci.sbINumberPropertyInfo.RADIX_16;
120 assertEqual(numberInfo.makeSearchable(sample),
"0000000000000AAD");
122 numberInfo.radix =
Ci.sbINumberPropertyInfo.RADIX_8;
126 assertEqual(numberInfo.makeSearchable(sample),
"0000000000000000000644");
128 numberInfo.radix =
Ci.sbINumberPropertyInfo.RADIX_10;
130 numberInfo.minValue = 1001;
133 numberInfo.format(sample)
140 numberInfo.maxValue = 1003;
155 var numberInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Number;1"]
156 .createInstance(
Ci.sbINumberPropertyInfo);
158 numberInfo.id =
"FloatingInfo";
161 numberInfo.radix =
Ci.sbINumberPropertyInfo.FLOAT;
163 var sample =
"123 not a number";
166 numberInfo.format(sample);
184 var formatted_sample = numberInfo.format(sample).replace(
",",
".");
185 var searchable_sample = numberInfo.makeSearchable(sample).replace(
",",
".");
186 log(formatted_sample);
187 log(searchable_sample);
193 var delta = Math.abs(searchable_sample - sample);
194 assertTrue(delta < eps,
"make sortable doesn't perturb the value");
199 formatted_sample = numberInfo.format(sample).replace(
",",
".");
200 searchable_sample = numberInfo.makeSearchable(sample).replace(
",",
".");
201 log(formatted_sample);
202 log(searchable_sample);
205 var delta = Math.abs(searchable_sample - sample);
206 assertTrue(delta < eps,
"make sortable doesn't perturb the value");
208 sample =
"12347120349029834.1234341235";
211 formatted_sample = numberInfo.format(sample).replace(
",",
".");
212 searchable_sample = numberInfo.makeSearchable(sample).replace(
",",
".");
213 log(formatted_sample);
214 log(searchable_sample);
216 assertEqual(parseFloat(formatted_sample), 1.23471e+016);
217 var delta = Math.abs(searchable_sample - sample);
218 assertTrue(delta < eps,
true,
"make sortable doesn't perturb the value");
222 var uriInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/URI;1"]
223 .createInstance(
Ci.sbIURIPropertyInfo);
225 uriInfo.id =
"URIInfo";
228 var sample =
"totally not a valid url";
231 sample =
"choohooo://vaguely valid/";
234 sample =
"http://songbirdnest.com/aus/blog";
237 sample =
"file:///Users/Me/Music";
238 uriInfo.constrainScheme =
"http";
241 sample =
"http://shoot.the.tv";
244 sample =
"HTTp://PoorLy.FormaTTEd.URL.com/ArRrRg";
245 assertEqual(uriInfo.format(sample),
"http://poorly.formatted.url.com/ArRrRg");
249 var datetimeInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Datetime;1"]
250 .createInstance(
Ci.sbIDatetimePropertyInfo);
252 datetimeInfo.id =
"DatetimeInfo";
256 datetimeInfo.timeType =
Ci.sbIDatetimePropertyInfo.TIMETYPE_DATETIME;
259 log(datetimeInfo.format(sample));
261 sample =
"12431235123412499";
263 log(datetimeInfo.format(sample));
267 var durationInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Duration;1"]
268 .createInstance(
Ci.sbIDurationPropertyInfo);
270 durationInfo.id =
"DurationInfo";
276 log(durationInfo.format(sample));
278 sample =
"12431235123412499";
280 log(durationInfo.format(sample));
282 durationInfo.durationWithMilliseconds =
true;
283 log(durationInfo.format(sample));
287 var booleanInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Boolean;1"]
288 .createInstance(
Ci.sbIBooleanPropertyInfo);
290 booleanInfo.id =
"BooleanInfo";
293 var sample =
"not a boolean";
296 booleanInfo.format(sample);
305 assertEqual(booleanInfo.makeSearchable(sample),
"0");
310 assertEqual(booleanInfo.makeSearchable(sample),
"1");
315 assertEqual(booleanInfo.makeSearchable(sample),
"");
317 var tvpi = booleanInfo.QueryInterface(
Ci.sbITreeViewPropertyInfo);
324 assertEqual(tvpi.getCellProperties(
""),
"checkbox unchecked");
325 assertEqual(tvpi.getCellProperties(
"0"),
"checkbox unchecked");
326 assertEqual(tvpi.getCellProperties(
"1"),
"checkbox checked");
331 log(
"Testing TextPropertyInfo...");
335 log(
"Testing NumberPropertyInfo...");
340 log(
"Testing URIPropertyInfo...");
344 log(
"Testing DatetimePropertyInfo...");
348 log(
"Testing DurationPropertyInfo...");
352 log(
"Testing BooleanPropertyInfo...");
function testDatetimeInfo()
function testNumberInfoFloatingPoint()
function testNumberInfo()
function assertTrue(aTest, aMessage)
function testBooleanInfo()
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Advanced DataRemote unit tests.
function testTextInfo()
Test file.
function testDurationInfo()