33 var databaseGUID =
"test_guidarray_nullsorting";
41 var
array =
Cc[
"@songbirdnest.com/Songbird/Library/LocalDatabase/GUIDArray;1"]
42 .createInstance(
Ci.sbILocalDatabaseGUIDArray);
43 array.databaseGUID = databaseGUID;
44 array.baseTable =
"media_items";
46 library.QueryInterface(
Ci.sbILocalDatabaseLibrary).propertyCache;
79 var numberInfo =
Cc[
"@songbirdnest.com/Songbird/Properties/Info/Number;1"]
80 .createInstance(
Ci.sbINumberPropertyInfo);
81 numberInfo.id =
"http://songbirdnest.com/data/1.0#testNumber";
82 numberInfo.nullSort =
Ci.sbIPropertyInfo.SORT_NULL_SMALL;
84 var propMan =
Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
85 .getService(
Ci.sbIPropertyManager);
86 propMan.addPropertyInfo(numberInfo);
91 for (var
i = 0;
i < 20;
i++) {
92 var item = library.createMediaItem(
newURI(
"file://foo/" +
i));
94 item.setProperty(
"http://songbirdnest.com/data/1.0#testNumber",
i - 10);
96 items.push(item.guid);
100 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
true);
107 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
false);
109 var sortNullSmall =
swap(items, 10);
114 numberInfo.nullSort =
Ci.sbIPropertyInfo.SORT_NULL_BIG;
118 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
true);
120 var sortNullBig =
swap(items, 10);
126 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
false);
132 numberInfo.nullSort =
Ci.sbIPropertyInfo.SORT_NULL_FIRST;
136 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
true);
143 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
false);
149 numberInfo.nullSort =
Ci.sbIPropertyInfo.SORT_NULL_LAST;
154 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
true);
156 var sortNullLast =
swap(items, 10);
161 array.addSort(
"http://songbirdnest.com/data/1.0#testNumber",
false);
170 if (guidArray.length != guids.length) {
171 fail(
"different lengths, " + guidArray.length +
" != " + guids.length);
174 for (var
i = 0;
i < guidArray.length;
i++) {
175 if (guidArray.getGuidByIndex(
i) != guids[
i]) {
176 fail(
"different items at " +
i +
", " + guidArray.getGuidByIndex(
i) +
" != " + guids[
i]);
184 var before = a.slice(0,
start);
186 var after = a.slice(
start + length);
188 return before.concat(range).concat(after);
193 var before = a.slice(0, length);
194 var after = a.slice(length);
196 return after.concat(before);
function reverseRange(a, start, length)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function runTest()
Test file.
function assertArraySame(guidArray, guids)
_getSelectedPageStyle s i