33 var databaseGUID =
"test_guidarray_prefix";
35 var listId = library.QueryInterface(
Ci.sbILocalDatabaseLibrary)
36 .getMediaItemIdForGuid(
"7e8dcc95-7a1d-4bb3-9b14-d4906a9952cb");
38 var
array =
Cc[
"@songbirdnest.com/Songbird/Library/LocalDatabase/GUIDArray;1"]
39 .createInstance(
Ci.sbILocalDatabaseGUIDArray);
40 array.databaseGUID = databaseGUID;
42 library.QueryInterface(
Ci.sbILocalDatabaseLibrary).propertyCache;
44 array.baseTable =
"media_items";
45 array.addSort(
"http://songbirdnest.com/data/1.0#albumName",
true);
57 for (var
i = 0;
i < tests.length;
i++) {
61 array.getFirstIndexByPrefix(tests[i]);
62 fail(
"NS_ERROR_NOT_AVAILABLE not thrown");
69 assertEqual(array.getFirstIndexByPrefix(tests[i]), index);
73 array.addFilter(
"http://songbirdnest.com/data/1.0#genre",
77 for (var
i = 0;
i < tests.length;
i++) {
81 array.getFirstIndexByPrefix(tests[i]);
82 fail(
"NS_ERROR_NOT_AVAILABLE not thrown");
89 assertEqual(array.getFirstIndexByPrefix(tests[i]), index);
94 array =
Cc[
"@songbirdnest.com/Songbird/Library/LocalDatabase/GUIDArray;1"]
95 .createInstance(
Ci.sbILocalDatabaseGUIDArray);
96 array.databaseGUID = databaseGUID;
98 library.QueryInterface(
Ci.sbILocalDatabaseLibrary).propertyCache;
100 array.baseTable =
"simple_media_lists";
101 array.baseConstraintColumn =
"media_item_id";
102 array.baseConstraintValue = listId;
104 array.addSort(
"http://songbirdnest.com/data/1.0#albumName",
true);
116 for (var
i = 0;
i < tests.length;
i++) {
120 array.getFirstIndexByPrefix(tests[i]);
121 fail(
"NS_ERROR_NOT_AVAILABLE not thrown");
128 assertEqual(array.getFirstIndexByPrefix(tests[i]), index);
132 array.addFilter(
"http://songbirdnest.com/data/1.0#genre",
136 for (var
i = 0;
i < tests.length;
i++) {
140 array.getFirstIndexByPrefix(tests[i]);
141 fail(
"NS_ERROR_NOT_AVAILABLE not thrown");
148 assertEqual(array.getFirstIndexByPrefix(tests[i]), index);
153 array.clearFilters();
156 array.addSort(
"http://songbirdnest.com/data/1.0#ordinal",
true);
160 for (let
i = 0;
i < array.length;
i++) {
164 array.addFilter(
"http://songbirdnest.com/data/1.0#artistName",
168 for (let
i = 10;
i < array.length;
i++) {
176 var length =
array.length;
177 var re =
new RegExp(
"^" + prefix);
178 for (var
i = 0;
i < length;
i++) {
180 if (value.match(re)) {
function assertEqual(aExpected, aActual, aMessage)
function createLibrary(databaseGuid, databaseLocation)
function findFirstIndexByPrefix(array, prefix)
function StringArrayEnumerator(aArray)
_getSelectedPageStyle s i
function runTest()
Test file.