Bug 838467 5/5: test cases. r=gwagner

This commit is contained in:
Vicamo Yang 2013-04-09 10:21:43 +08:00
parent 97b776a0fc
commit 30f4e10332
13 changed files with 169 additions and 209 deletions

View File

@ -21,16 +21,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -45,8 +43,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -138,20 +136,18 @@ function getMsgs() {
log("Getting SMS messages with dates between " + yesterday + " and "
+ tomorrow +".");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -169,8 +165,8 @@ function getMsgs() {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -21,16 +21,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -45,8 +43,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -138,18 +136,16 @@ function getMsgs() {
log("Getting SMS messages with dates between " + twoDaysAgo + " and "
+ yesterday +".");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
log("SMS getMessages returned a message but should not have.");
ok(false, "SMS date filter did not work");
} else {
@ -159,8 +155,8 @@ function getMsgs() {
deleteAllMsgs(cleanUp);
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -64,10 +64,9 @@ function getAllMessages(callback, filter, reverse) {
let messages = [];
let request = sms.getMessages(filter, reverse || false);
request.onsuccess = function(event) {
let cursor = event.target.result;
if (cursor.message) {
messages.push(cursor.message);
cursor.continue();
if (request.result) {
messages.push(request.result);
request.continue();
return;
}

View File

@ -23,16 +23,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -47,8 +45,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -192,20 +190,18 @@ function getMsgs(secondNumber) {
log("Getting the SMS messages with numbers " + defaultRemoteNumber + " and "
+ secondNumber + ".");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -223,8 +219,8 @@ function getMsgs(secondNumber) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -23,16 +23,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -47,8 +45,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -150,20 +148,18 @@ function getMsgs() {
filter.numbers = new Array(defaultRemoteNumber);
log("Getting the SMS messages from sender " + defaultRemoteNumber + ".");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -181,8 +177,8 @@ function getMsgs() {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -21,16 +21,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -45,8 +43,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -170,20 +168,18 @@ function getMsgs() {
filter.read = true;
log("Getting the read SMS messages.");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -201,8 +197,8 @@ function getMsgs() {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -21,16 +21,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -45,8 +43,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -182,20 +180,18 @@ function getMsgs() {
filter.delivery = "received";
log("Getting the received SMS messages.");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -213,8 +209,8 @@ function getMsgs() {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -21,16 +21,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -45,8 +43,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -179,20 +177,18 @@ function getMsgs() {
filter.delivery = "sent";
log("Getting the sent SMS messages.");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -210,8 +206,8 @@ function getMsgs() {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -21,16 +21,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let filter = new MozSmsFilter;
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -45,8 +43,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -164,20 +162,18 @@ function getMsgs() {
filter.read = false;
log("Getting the unread SMS messages.");
let request = sms.getMessages(filter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(filter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -195,8 +191,8 @@ function getMsgs() {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -25,16 +25,14 @@ function deleteAllMsgs(nextFunction) {
let msgList = new Array();
let smsFilter = new MozSmsFilter;
let request = sms.getMessages(smsFilter, false);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(smsFilter, false);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
// Check if message was found
if (cursor.message) {
msgList.push(cursor.message.id);
if (cursor.result) {
msgList.push(cursor.result.id);
// Now get next message in the list
cursor.continue();
} else {
@ -49,8 +47,8 @@ function deleteAllMsgs(nextFunction) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");
@ -144,21 +142,19 @@ function getMsgs(reverse) {
// Note: This test is intended for getMessages, so just a basic test with
// no filter (default); separate tests will be written for sms filtering
let request = sms.getMessages(smsFilter, reverse);
ok(request instanceof MozSmsRequest,
"request is instanceof " + request.constructor);
let cursor = sms.getMessages(smsFilter, reverse);
ok(cursor instanceof DOMCursor,
"cursor is instanceof " + cursor.constructor);
request.onsuccess = function(event) {
log("Received 'onsuccess' smsrequest event.");
ok(event.target.result, "smsrequest event.target.result");
cursor = event.target.result;
cursor.onsuccess = function(event) {
log("Received 'onsuccess' event.");
if (cursor.message) {
if (cursor.result) {
// Another message found
log("Got SMS (id: " + cursor.message.id + ").");
log("Got SMS (id: " + cursor.result.id + ").");
foundSmsCount++;
// Store found message
foundSmsList.push(cursor.message);
foundSmsList.push(cursor.result);
// Now get next message in the list
cursor.continue();
} else {
@ -175,8 +171,8 @@ function getMsgs(reverse) {
}
};
request.onerror = function(event) {
log("Received 'onerror' smsrequest event.");
cursor.onerror = function(event) {
log("Received 'onerror' event.");
ok(event.target.error, "domerror obj");
log("sms.getMessages error: " + event.target.error.name);
ok(false,"Could not get SMS messages");

View File

@ -70,12 +70,11 @@ function test_message_class_0() {
checkMessage(message, -1, 0, "class-0");
// Make sure the message is not stored.
let request = sms.getMessages(null, false);
request.onsuccess = function onsuccess() {
let cursor = request.result;
if (cursor.message) {
let cursor = sms.getMessages(null, false);
cursor.onsuccess = function onsuccess() {
if (cursor.result) {
// Here we check whether there is any message of the same sender.
isnot(cursor.message.sender, message.sender, "cursor.message.sender");
isnot(cursor.result.sender, message.sender, "cursor.result.sender");
cursor.continue();
return;
@ -89,7 +88,7 @@ function test_message_class_0() {
window.setTimeout(do_test.bind(null, dcsIndex), 0);
}
};
request.onerror = function onerror() {
cursor.onerror = function onerror() {
ok(false, "Can't fetch messages from SMS database");
};
});

View File

@ -46,7 +46,6 @@ function test() {
checkInterface("SmsEvent");
checkInterface("SmsRequest");
checkInterface("SmsFilter");
checkInterface("SmsCursor");
// If sms is disabled and permission is removed, sms is disabled.
SpecialPowers.setBoolPref("dom.sms.enabled", false);

View File

@ -426,7 +426,6 @@ var interfaceNamesInGlobalScope =
"SVGTests",
"RGBColor",
"HTMLLabelElement",
"MozSmsCursor",
"EventSource",
"MozNavigatorSms",
"MozNavigatorMobileMessage",