33 this.gotLength =
false;
39 this.gotValue =
false;
42 this.gotMediaItemId =
false;
43 this.mediaItemId =
null;
52 this.gotLength =
true;
55 ArrayListener.prototype.onGetGuidByIndex =
function(index, guid, rv)
69 ArrayListener.prototype.onGetMediaItemIdByIndex =
function(index, mediaItemId, rv)
71 this.mediaItemId = mediaItemId;
73 this.gotMediaItemId =
true;
81 if (!iid.equals(
Ci.sbILocalDatabaseAsyncGUIDArrayListener) &&
82 !iid.equals(
Ci.nsISupportsWeakReference) &&
83 !iid.equals(
Ci.nsISupports))
84 throw Cr.NS_ERROR_NO_INTERFACE;
91 case "getLengthAsync":
94 array.addAsyncListener(listener);
95 array.getLengthAsync();
99 tester.func =
function() {
100 if (listener.gotLength) {
101 if (listener.rv ==
Cr.NS_OK && listener.length == 101) {
114 case "getGuidByIndexAsync":
116 dump(
"------------------------------------- 1\n");
118 array.addAsyncListener(listener);
119 array.getGuidByIndexAsync(0);
120 dump(
"------------------------------------- 2\n");
124 tester.func =
function() {
125 if (listener.gotGuid) {
126 if (listener.rv ==
Cr.NS_OK &&
127 listener.guid ==
"3E4FAFDA-AD99-11DB-9321-C22AB7121F49") {
137 dump(
"------------------------------------- 3\n");
141 case "getSortPropertyValueByIndex":
144 array.addAsyncListener(listener);
145 array.getSortPropertyValueByIndexAsync(0);
149 tester.func =
function() {
150 if (listener.gotValue) {
151 if (listener.rv ==
Cr.NS_OK &&
152 listener.value ==
"ac black") {
165 case "getMediaItemIdByIndex":
168 array.addAsyncListener(listener);
169 array.getMediaItemIdByIndexAsync(0);
173 tester.func =
function() {
174 if (listener.gotMediaItemId) {
175 if (listener.rv ==
Cr.NS_OK &&
192 tester.func =
function() {
return -1; }
203 var shouldContinue =
false;
212 log(
"exception: " + ex);
221 shouldContinue =
true;
227 shouldContinue =
false;
231 shouldContinue =
true;
238 shouldContinue =
true;
241 log(
"exception: " + ex);
243 shouldContinue =
false;
248 if (shouldContinue) {
251 this.
_timer =
Cc[
"@mozilla.org/timer;1"].createInstance(
Ci.nsITimer);
252 this.
_timer.initWithCallback(
this, 10,
Ci.nsITimer.TYPE_ONE_SHOT);
259 fail(
"maximum iterations reached");
273 var phases = [
"getLengthAsync",
274 "getGuidByIndexAsync",
275 "getSortPropertyValueByIndex",
276 "getMediaItemIdByIndex"];
286 var databaseGUID =
"test_asyncguidarray";
289 testMediaItemId = library.QueryInterface(
Ci.sbILocalDatabaseLibrary).getMediaItemIdForGuid(
"3E4FAFDA-AD99-11DB-9321-C22AB7121F49");
291 var
array =
Cc[
"@songbirdnest.com/Songbird/Library/LocalDatabase/AsyncGUIDArray;1"]
292 .createInstance(
Ci.sbILocalDatabaseAsyncGUIDArray);
293 array.databaseGUID = databaseGUID;
294 array.propertyCache =
295 library.QueryInterface(
Ci.sbILocalDatabaseLibrary).propertyCache;
296 array.baseTable =
"media_items";
297 array.addSort(
"http://songbirdnest.com/data/1.0#albumName",
true);
298 array.addSort(
"http://songbirdnest.com/data/1.0#trackNumber",
true);
function runTest()
Advanced DataRemote unit tests.
sbDeviceFirmwareAutoCheckForUpdate prototype _timer
function createLibrary(databaseGuid, databaseLocation)
function ArrayListener()
Test file.
function TimerLoop(array)