mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 797277 - Part 5/5: test cases, r=marshall_law
This commit is contained in:
parent
e9136f2a7b
commit
3f935f12b2
@ -31,7 +31,7 @@ function sendSmsPduToEmulator(pdu) {
|
||||
}
|
||||
|
||||
const TIMESTAMP = Date.UTC(2000, 0, 1);
|
||||
function checkMessage(message, id) {
|
||||
function checkMessage(message, id, messageClass) {
|
||||
ok(message instanceof MozSmsMessage,
|
||||
"message is instanceof " + message.constructor);
|
||||
if (id == null) {
|
||||
@ -43,6 +43,7 @@ function checkMessage(message, id) {
|
||||
is(message.deliveryStatus, "success", "message.deliveryStatus");
|
||||
is(message.sender, "+1", "message.sender");
|
||||
is(message.body, "A", "message.body");
|
||||
is(message.messageClass, messageClass, "message.messageClass");
|
||||
ok(message.timestamp instanceof Date,
|
||||
"message.timestamp is instanceof " + message.timestamp.constructor);
|
||||
is(message.timestamp.getTime(), TIMESTAMP, "message.timestamp");
|
||||
@ -61,7 +62,7 @@ function test_message_class_0() {
|
||||
sms.removeEventListener("received", onReceived);
|
||||
|
||||
let message = event.message;
|
||||
checkMessage(message, -1);
|
||||
checkMessage(message, -1, "class-0");
|
||||
|
||||
// Make sure the message is not stored.
|
||||
let request = sms.getMessages(null, false);
|
||||
@ -100,13 +101,13 @@ function test_message_class_0() {
|
||||
do_test(0);
|
||||
}
|
||||
|
||||
function doTestMessageClassGeneric(allDCSs, next) {
|
||||
function doTestMessageClassGeneric(allDCSs, messageClass, next) {
|
||||
function do_test(dcsIndex) {
|
||||
sms.addEventListener("received", function onReceived(event) {
|
||||
sms.removeEventListener("received", onReceived);
|
||||
|
||||
// Make sure we can correctly receive the message
|
||||
checkMessage(event.message);
|
||||
checkMessage(event.message, null, messageClass);
|
||||
|
||||
++dcsIndex;
|
||||
if (dcsIndex >= allDCSs.length) {
|
||||
@ -135,7 +136,7 @@ function test_message_class_1() {
|
||||
];
|
||||
|
||||
log("Checking Message Class 1");
|
||||
doTestMessageClassGeneric(allDCSs, test_message_class_2);
|
||||
doTestMessageClassGeneric(allDCSs, "class-1", test_message_class_2);
|
||||
}
|
||||
|
||||
function test_message_class_2() {
|
||||
@ -156,7 +157,7 @@ function test_message_class_2() {
|
||||
function onReceived(event) {
|
||||
if (pidIndex == 0) {
|
||||
// Make sure we can correctly receive the message
|
||||
checkMessage(event.message);
|
||||
checkMessage(event.message, null, "class-2");
|
||||
|
||||
next();
|
||||
return;
|
||||
@ -220,7 +221,7 @@ function test_message_class_3() {
|
||||
];
|
||||
|
||||
log("Checking Message Class 3");
|
||||
doTestMessageClassGeneric(allDCSs, cleanUp);
|
||||
doTestMessageClassGeneric(allDCSs, "class-3", cleanUp);
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
|
@ -106,72 +106,106 @@ add_test(function test_GsmPDUHelper_readDataCodingScheme() {
|
||||
|
||||
// Group 00xx
|
||||
// Bit 3 and 2 indicate the character set being used.
|
||||
test_dcs(0x00, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x04, PDU_DCS_MSG_CODING_8BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x08, PDU_DCS_MSG_CODING_16BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x0C, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x00, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0x04, PDU_DCS_MSG_CODING_8BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0x08, PDU_DCS_MSG_CODING_16BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0x0C, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
// Bit 4, if set to 0, indicates that bits 1 to 0 are reserved and have no
|
||||
// message class meaning.
|
||||
test_dcs(0x01, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x02, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x03, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x01, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0x02, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0x03, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
// Bit 4, if set to 1, indicates that bits 1 to 0 have a message class meaning.
|
||||
test_dcs(0x10, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_0);
|
||||
test_dcs(0x11, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_ME_SPECIFIC);
|
||||
test_dcs(0x12, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_SIM_SPECIFIC);
|
||||
test_dcs(0x13, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_TE_SPECIFIC);
|
||||
test_dcs(0x10, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_0]);
|
||||
test_dcs(0x11, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_1]);
|
||||
test_dcs(0x12, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]);
|
||||
test_dcs(0x13, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_3]);
|
||||
|
||||
// Group 01xx
|
||||
test_dcs(0x50, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_0);
|
||||
test_dcs(0x50, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_0]);
|
||||
|
||||
// Group 1000..1011: reserved
|
||||
test_dcs(0x8F, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x9F, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0xAF, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0xBF, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN);
|
||||
test_dcs(0x8F, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0x9F, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0xAF, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
test_dcs(0xBF, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL]);
|
||||
|
||||
// Group 1100: Message Waiting Indication Group: Discard Message
|
||||
// Bit 3 indicates Indication Sense:
|
||||
test_dcs(0xC0, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xC0, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: false, discard: true, msgCount: 0});
|
||||
test_dcs(0xC8, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xC8, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: true, discard: true, msgCount: -1});
|
||||
// Bit 2 is reserved, and set to 0:
|
||||
test_dcs(0xCC, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xCC, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: true, discard: true, msgCount: -1});
|
||||
|
||||
// Group 1101: Message Waiting Indication Group: Store Message
|
||||
// Bit 3 indicates Indication Sense:
|
||||
test_dcs(0xD0, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xD0, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: false, discard: false, msgCount: 0});
|
||||
test_dcs(0xD8, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xD8, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: true, discard: false, msgCount: -1});
|
||||
// Bit 2 is reserved, and set to 0:
|
||||
test_dcs(0xDC, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xDC, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: true, discard: false, msgCount: -1});
|
||||
|
||||
// Group 1110: Message Waiting Indication Group: Store Message, UCS2
|
||||
// Bit 3 indicates Indication Sense:
|
||||
test_dcs(0xE0, PDU_DCS_MSG_CODING_16BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xE0, PDU_DCS_MSG_CODING_16BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: false, discard: false, msgCount: 0});
|
||||
test_dcs(0xE8, PDU_DCS_MSG_CODING_16BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xE8, PDU_DCS_MSG_CODING_16BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: true, discard: false, msgCount: -1});
|
||||
// Bit 2 is reserved, and set to 0:
|
||||
test_dcs(0xEC, PDU_DCS_MSG_CODING_16BITS_ALPHABET, PDU_DCS_MSG_CLASS_UNKNOWN,
|
||||
test_dcs(0xEC, PDU_DCS_MSG_CODING_16BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_NORMAL],
|
||||
{active: true, discard: false, msgCount: -1});
|
||||
|
||||
// Group 1111
|
||||
test_dcs(0xF0, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_0);
|
||||
test_dcs(0xF1, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_ME_SPECIFIC);
|
||||
test_dcs(0xF2, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_SIM_SPECIFIC);
|
||||
test_dcs(0xF3, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_TE_SPECIFIC);
|
||||
test_dcs(0xF4, PDU_DCS_MSG_CODING_8BITS_ALPHABET, PDU_DCS_MSG_CLASS_0);
|
||||
test_dcs(0xF5, PDU_DCS_MSG_CODING_8BITS_ALPHABET, PDU_DCS_MSG_CLASS_ME_SPECIFIC);
|
||||
test_dcs(0xF6, PDU_DCS_MSG_CODING_8BITS_ALPHABET, PDU_DCS_MSG_CLASS_SIM_SPECIFIC);
|
||||
test_dcs(0xF7, PDU_DCS_MSG_CODING_8BITS_ALPHABET, PDU_DCS_MSG_CLASS_TE_SPECIFIC);
|
||||
test_dcs(0xF0, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_0]);
|
||||
test_dcs(0xF1, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_1]);
|
||||
test_dcs(0xF2, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]);
|
||||
test_dcs(0xF3, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_3]);
|
||||
test_dcs(0xF4, PDU_DCS_MSG_CODING_8BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_0]);
|
||||
test_dcs(0xF5, PDU_DCS_MSG_CODING_8BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_1]);
|
||||
test_dcs(0xF6, PDU_DCS_MSG_CODING_8BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]);
|
||||
test_dcs(0xF7, PDU_DCS_MSG_CODING_8BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_3]);
|
||||
// Bit 3 is reserved and should be set to 0, but if it doesn't we should
|
||||
// ignore it.
|
||||
test_dcs(0xF8, PDU_DCS_MSG_CODING_7BITS_ALPHABET, PDU_DCS_MSG_CLASS_0);
|
||||
test_dcs(0xF8, PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
||||
GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_0]);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user