33 var databaseGUID =
"test_smartmedialist";
54 var albumProp =
SB_NS +
"albumName";
55 var list = library.createMediaList(
"smart");
57 assertEqual(list.matchType,
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_ANY);
58 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_ALL;
59 assertEqual(list.matchType,
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_ALL);
61 assertEqual(list.limitType,
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_NONE);
62 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
63 assertEqual(list.limitType,
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS);
70 list.selectPropertyID = albumProp;
74 list.selectDirection =
false;
78 list.randomSelection =
true;
82 list.autoUpdate =
true;
88 var albumProp =
SB_NS +
"albumName";
90 var list = library.createMediaList(
"smart");
95 var condition1 = list.appendCondition(albumProp, op,
"Back In Black",
null,
"a");
100 assertEqual(condition1.leftValue,
"Back In Black");
104 var condition2 = list.appendCondition(albumProp, op,
"The Life of Riley",
null,
"b");
110 list.removeConditionAt(0);
114 list.removeConditionAt(0);
120 var albumProp =
SB_NS +
"albumName";
121 var artistProp =
SB_NS +
"artistName";
122 var contentLengthProp =
SB_NS +
"contentLength";
124 var list = library.createMediaList(
"smart");
125 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_ALL;
129 list.appendCondition(albumProp,
141 list.appendCondition(artistProp,
151 list.appendCondition(artistProp,
160 list.removeConditionAt(2);
166 list.appendCondition(contentLengthProp,
178 var albumProp =
SB_NS +
"albumName";
179 var artistProp =
SB_NS +
"artistName";
180 var contentLengthProp =
SB_NS +
"contentLength";
182 var list = library.createMediaList(
"smart");
183 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_ANY;
185 list.appendCondition(albumProp,
197 list.appendCondition(artistProp,
208 list.appendCondition(artistProp,
221 var list = library.createMediaList(
"smart");
222 var lastPlayTimeProp =
SB_NS +
"lastPlayTime";
223 var albumProp =
SB_NS +
"albumName";
225 function setConditions(prop, op,
value) {
226 list.clearConditions();
227 list.appendCondition(prop,
235 var
value =
"1166399962000";
237 list.notExistsMode = list.NOTEXISTS_ASNULL;
239 setConditions(lastPlayTimeProp,
"=", value);
243 list.notExistsMode = list.NOTEXISTS_ASZERO;
245 setConditions(lastPlayTimeProp,
"=", value);
249 list.notExistsMode = list.NOTEXISTS_ASNULL;
251 setConditions(lastPlayTimeProp,
"!=", value);
255 list.notExistsMode = list.NOTEXISTS_ASZERO;
257 setConditions(lastPlayTimeProp,
"!=", value);
261 list.notExistsMode = list.NOTEXISTS_ASNULL;
263 setConditions(lastPlayTimeProp,
">", value);
267 list.notExistsMode = list.NOTEXISTS_ASZERO;
269 setConditions(lastPlayTimeProp,
">", value);
273 list.notExistsMode = list.NOTEXISTS_ASNULL;
275 setConditions(lastPlayTimeProp,
">=", value);
279 list.notExistsMode = list.NOTEXISTS_ASZERO;
281 setConditions(lastPlayTimeProp,
">=", value);
285 list.notExistsMode = list.NOTEXISTS_ASNULL;
287 setConditions(lastPlayTimeProp,
"<", value);
291 list.notExistsMode = list.NOTEXISTS_ASZERO;
293 setConditions(lastPlayTimeProp,
"<", value);
297 list.notExistsMode = list.NOTEXISTS_ASNULL;
299 setConditions(lastPlayTimeProp,
"<=", value);
303 list.notExistsMode = list.NOTEXISTS_ASZERO;
305 setConditions(lastPlayTimeProp,
"<=", value);
309 list.notExistsMode = list.NOTEXISTS_ASNULL;
311 var value =
"1166399960000";
312 setConditions(lastPlayTimeProp,
"#=", value);
316 list.notExistsMode = list.NOTEXISTS_ASZERO;
318 setConditions(lastPlayTimeProp,
"#=", value);
322 list.notExistsMode = list.NOTEXISTS_ASNULL;
324 setConditions(lastPlayTimeProp,
"#!=", value);
328 list.notExistsMode = list.NOTEXISTS_ASZERO;
330 setConditions(lastPlayTimeProp,
"#!=", value);
334 list.notExistsMode = list.NOTEXISTS_ASNULL;
336 setConditions(lastPlayTimeProp,
"#>", value);
340 list.notExistsMode = list.NOTEXISTS_ASZERO;
342 setConditions(lastPlayTimeProp,
"#>", value);
346 list.notExistsMode = list.NOTEXISTS_ASNULL;
348 setConditions(lastPlayTimeProp,
"#>=", value);
352 list.notExistsMode = list.NOTEXISTS_ASZERO;
354 setConditions(lastPlayTimeProp,
"#>=", value);
358 list.notExistsMode = list.NOTEXISTS_ASNULL;
360 setConditions(lastPlayTimeProp,
"#<", value);
364 list.notExistsMode = list.NOTEXISTS_ASZERO;
366 setConditions(lastPlayTimeProp,
"#<", value);
370 list.notExistsMode = list.NOTEXISTS_ASNULL;
372 setConditions(lastPlayTimeProp,
"#<=", value);
376 list.notExistsMode = list.NOTEXISTS_ASZERO;
378 setConditions(lastPlayTimeProp,
"#<=", value);
382 list.notExistsMode = list.NOTEXISTS_ASNULL;
385 list.clearConditions();
386 list.appendCondition(lastPlayTimeProp,
395 list.notExistsMode = list.NOTEXISTS_ASZERO;
397 list.clearConditions();
398 list.appendCondition(lastPlayTimeProp,
407 list.notExistsMode = list.NOTEXISTS_ASNULL;
409 list.clearConditions();
410 list.appendCondition(lastPlayTimeProp,
419 list.notExistsMode = list.NOTEXISTS_ASNULL;
421 list.clearConditions();
422 list.appendCondition(albumProp,
431 list.notExistsMode = list.NOTEXISTS_ASZERO;
433 list.clearConditions();
434 list.appendCondition(albumProp,
443 list.notExistsMode = list.NOTEXISTS_ASNULL;
445 list.clearConditions();
446 list.appendCondition(albumProp,
455 list.notExistsMode = list.NOTEXISTS_ASZERO;
457 list.clearConditions();
458 list.appendCondition(albumProp,
467 list.notExistsMode = list.NOTEXISTS_ASNULL;
469 list.clearConditions();
470 list.appendCondition(albumProp,
479 list.notExistsMode = list.NOTEXISTS_ASZERO;
481 list.clearConditions();
482 list.appendCondition(albumProp,
495 var albumProp =
SB_NS +
"albumName";
496 var trackProp =
SB_NS +
"trackNumber";
498 var list = library.createMediaList(
"smart");
500 list.appendCondition(albumProp,
509 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
511 list.selectPropertyID = trackProp;
512 list.selectDirection =
true;
520 list.selectDirection =
false;
526 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_NONE;
533 var albumProp =
SB_NS +
"albumName";
534 var trackProp =
SB_NS +
"trackNumber";
536 var list = library.createMediaList(
"smart");
538 list.appendCondition(albumProp,
544 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS;
545 list.limit = 30 * 60 * 1000 * 1000;
546 list.selectPropertyID = trackProp;
547 list.selectDirection =
true;
556 list.selectDirection =
false;
566 var albumProp =
SB_NS +
"albumName";
567 var trackProp =
SB_NS +
"trackNumber";
569 var list = library.createMediaList(
"smart");
571 list.appendCondition(albumProp,
577 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES;
579 list.selectPropertyID = trackProp;
580 list.selectDirection =
true;
589 list.selectDirection =
false;
599 var artistProp =
SB_NS +
"artistName";
601 var list = library.createMediaList(
"smart");
602 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_NONE;
603 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
605 list.selectPropertyID = artistProp;
606 list.selectDirection =
true;
622 var artistProp =
SB_NS +
"artistName";
623 var durationProp =
SB_NS +
"duration";
625 var list = library.createMediaList(
"smart");
626 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_NONE;
627 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS;
630 list.limit = 120 * 60 * 1000 * 1000;
631 list.selectPropertyID = artistProp;
632 list.selectDirection =
true;
651 var artistProp =
SB_NS +
"artistName";
652 var contentLengthProp =
SB_NS +
"contentLength";
654 var list = library.createMediaList(
"smart");
655 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_NONE;
656 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES;
659 list.selectPropertyID = artistProp;
660 list.selectDirection =
true;
682 var albumProp =
SB_NS +
"albumName";
683 var trackProp =
SB_NS +
"trackNumber";
685 var list = library.createMediaList(
"smart");
687 list.appendCondition(albumProp,
693 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
695 list.randomSelection =
true;
707 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS;
708 list.limit = 10 * 60 * 1000 * 1000;
712 list.limit = 240 * 60 * 1000 * 1000;
717 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES;
722 list.limit = 1000000000;
730 var list = library.createMediaList(
"smart");
733 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_NONE;
734 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
736 list.randomSelection =
true;
748 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS;
749 list.limit = 10 * 60 * 1000 * 1000;
753 list.limit = 100 * 60 * 60 * 1000 * 1000;
758 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES;
763 list.limit = 1000000000;
771 var lastPlayTimeProp =
SB_NS +
"lastPlayTime";
772 var albumProp =
SB_NS +
"albumName";
774 var list = library.createMediaList(
"smart");
775 var guid = list.guid;
776 list.matchType =
Ci.sbILocalDatabaseSmartMediaList.MATCH_TYPE_ALL;
777 list.limitType =
Ci.sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
778 list.selectPropertyID = albumProp;
779 list.selectDirection =
false;
781 list.randomSelection =
true;
782 list.autoUpdate =
true;
783 list.appendCondition(albumProp,
788 list.appendCondition(lastPlayTimeProp,
797 var databaseGUID =
"test_smartmedialist";
799 var restoredList = library2.getMediaItem(guid);
801 assertEqual(list.matchType, restoredList.matchType);
802 assertEqual(list.limitType, restoredList.limitType);
803 assertEqual(list.selectPropertyID, restoredList.selectPropertyID);
804 assertEqual(list.selectDirection, restoredList.selectDirection);
806 assertEqual(list.randomSelection, restoredList.randomSelection);
807 assertEqual(list.autoUpdate, restoredList.autoUpdate);
808 assertEqual(list.conditionCount, restoredList.conditionCount);
810 for (var
i = 0;
i < list.conditionCount;
i++) {
817 var propMan =
Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
818 .getService(
Ci.sbIPropertyManager);
819 var info = propMan.getPropertyInfo(propertyID);
820 var op = info.getOperator(
operator);
828 assertEqual(a.operator.operator, b.operator.operator);
836 for (var
i = 0;
i < a.length;
i++) {
843 for (var
i =
start;
i < length;
i++) {
844 var item = list.getItemByIndex(
i);
851 for (var
i = 0;
i < list.length;
i++) {
852 var item = list.getItemByIndex(
i);
853 var
artist = item.getProperty(
SB_NS +
"artistName");
854 var album = item.getProperty(
SB_NS +
"albumName");
855 var track = item.getProperty(
SB_NS +
"trackNumber");
856 var size = item.getProperty(
SB_NS +
"contentLength");
858 var v = parseInt(item.getProperty(sumprop));
861 log(
"" +
i +
": " + artist +
" " + album +
" " + track +
" " + size + (sumprop ? (
" -> " + sum ) :
"" ));
869 for (var
i = 0;
i < list.length;
i++) {
870 var item = list.getItemByIndex(
i);
871 if (item.guid in guids) {
872 fail(
"list not unique, gud '" + item.guid +
"' appears more than once");
874 guids[item.guid] = 1;
880 var
PROP_ISLIST =
"http://songbirdnest.com/data/1.0#isList";
884 onEnumerationBegin:
function() {
886 onEnumeratedItem:
function(list, item) {
889 onEnumerationEnd:
function() {
893 library.enumerateItemsByProperty(PROP_ISLIST,
"0",
895 Ci.sbIMediaList.ENUMERATIONTYPE_LOCKING);
897 return listener.length;
904 for (var
i = 0;
i < list.length;
i++) {
905 var item = list.getItemByIndex(
i);
906 sum += parseInt(item.getProperty(prop));
function assertNotEqual(aExpected, aActual, aMessage)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
var getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('Songbird SBProperties artist
function createLibrary(databaseGuid, databaseLocation)
_getSelectedPageStyle s i