mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 901457 - [sms][mms] We need a property for the "sent" timestamp (part 3, test cases). r=vicamo
This commit is contained in:
parent
b94e9d8c60
commit
eaa3ec1b3b
@ -20,7 +20,9 @@ let outSmsId = 0;
|
||||
let inThreadId = 0;
|
||||
let outThreadId = 0;
|
||||
let inSmsTimeStamp;
|
||||
let inSmsSentTimeStamp;
|
||||
let outSmsTimeStamp;
|
||||
let outSmsSentTimeStamp;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
@ -49,6 +51,7 @@ function simulateIncomingSms() {
|
||||
is(incomingSms.sender, REMOTE, "sender");
|
||||
is(incomingSms.messageClass, "normal", "messageClass");
|
||||
inSmsTimeStamp = incomingSms.timestamp;
|
||||
inSmsSentTimeStamp = incomingSms.sentTimestamp;
|
||||
sendSms();
|
||||
};
|
||||
// Simulate incoming sms sent from remoteNumber to our emulator
|
||||
@ -77,6 +80,7 @@ function sendSms() {
|
||||
is(sentSms.sender, EMULATOR, "sender");
|
||||
is(sentSms.messageClass, "normal", "messageClass");
|
||||
outSmsTimeStamp = sentSms.timestamp;
|
||||
outSmsSentTimeStamp = sentSms.sentTimestamp;
|
||||
is(sentSms.deliveryTimestamp, 0, "deliveryTimestamp is 0");
|
||||
|
||||
if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
|
||||
@ -127,6 +131,7 @@ function getReceivedSms() {
|
||||
is(foundSms.sender, REMOTE, "sender");
|
||||
is(foundSms.messageClass, "normal", "messageClass");
|
||||
is(foundSms.timestamp, inSmsTimeStamp, "timestamp matches");
|
||||
is(foundSms.sentTimestamp, inSmsSentTimeStamp, "sentTimestamp matches");
|
||||
getSentSms();
|
||||
};
|
||||
|
||||
@ -160,6 +165,7 @@ function getSentSms() {
|
||||
is(foundSms.sender, EMULATOR, "sender");
|
||||
is(foundSms.messageClass, "normal", "messageClass");
|
||||
is(foundSms.timestamp, outSmsTimeStamp, "timestamp matches");
|
||||
is(foundSms.sentTimestamp, outSmsSentTimeStamp, "sentTimestamp matches");
|
||||
deleteMsgs();
|
||||
};
|
||||
|
||||
|
@ -202,6 +202,7 @@ function verifyFoundMsgs(foundSmsList, reverse) {
|
||||
|
||||
isIn(foundSmsList[x].sender, [smsList[x].sender, "+15552229797"], "sender");
|
||||
is(foundSmsList[x].timestamp, smsList[x].timestamp, "timestamp");
|
||||
is(foundSmsList[x].sentTimestamp, smsList[x].sentTimestamp, "sentTimestamp");
|
||||
}
|
||||
|
||||
log("Content in all of the returned SMS messages is correct.");
|
||||
|
@ -13,6 +13,8 @@ const PDU_TIMESTAMP = "00101000000000"; // 2000/01/01
|
||||
const PDU_UDL = "01";
|
||||
const PDU_UD = "41";
|
||||
|
||||
const SENT_TIMESTAMP = Date.UTC(2000, 0, 1); // Must be equal to PDU_TIMESTAMP.
|
||||
|
||||
SpecialPowers.addPermission("sms", true, document);
|
||||
|
||||
let manager = window.navigator.mozMobileMessage;
|
||||
@ -70,6 +72,8 @@ function test_message_class_0() {
|
||||
"Message's timestamp should be greater then the timetamp of sending");
|
||||
ok(event.message.timestamp <= Date.now(),
|
||||
"Message's timestamp should be lesser than the timestamp of now");
|
||||
is(event.message.sentTimestamp, SENT_TIMESTAMP,
|
||||
"Message's sentTimestamp should be equal to SENT_TIMESTAMP");
|
||||
|
||||
// Make sure the message is not stored.
|
||||
let cursor = manager.getMessages(null, false);
|
||||
@ -118,6 +122,8 @@ function doTestMessageClassGeneric(allDCSs, messageClass, next) {
|
||||
"Message's timestamp should be greater then the timetamp of sending");
|
||||
ok(event.message.timestamp <= Date.now(),
|
||||
"Message's timestamp should be lesser than the timestamp of now");
|
||||
is(event.message.sentTimestamp, SENT_TIMESTAMP,
|
||||
"Message's sentTimestamp should be equal to SENT_TIMESTAMP");
|
||||
|
||||
++dcsIndex;
|
||||
if (dcsIndex >= allDCSs.length) {
|
||||
@ -173,6 +179,8 @@ function test_message_class_2() {
|
||||
"Message's timestamp should be greater then the timetamp of sending");
|
||||
ok(event.message.timestamp <= Date.now(),
|
||||
"Message's timestamp should be lesser than the timestamp of now");
|
||||
is(event.message.sentTimestamp, SENT_TIMESTAMP,
|
||||
"Message's sentTimestamp should be equal to SENT_TIMESTAMP");
|
||||
|
||||
next();
|
||||
return;
|
||||
|
@ -43,11 +43,17 @@ function checkMessage(message, delivery, body) {
|
||||
ok(message.receiver, "message.receiver");
|
||||
is(message.body, body, "message.body");
|
||||
is(message.messageClass, "normal", "message.messageClass");
|
||||
is(message.read, true, "message.read");
|
||||
|
||||
// TODO: bug 788928 - add test cases for deliverysuccess event.
|
||||
is(message.deliveryTimestamp, 0, "deliveryTimestamp is 0");
|
||||
|
||||
is(message.read, true, "message.read");
|
||||
// Test message.sentTimestamp.
|
||||
if (message.delivery == "sending") {
|
||||
ok(message.sentTimestamp == 0, "message.sentTimestamp should be 0");
|
||||
} else if (message.delivery == "sent") {
|
||||
ok(message.sentTimestamp != 0, "message.sentTimestamp shouldn't be 0");
|
||||
}
|
||||
}
|
||||
|
||||
function doSendMessageAndCheckSuccess(receivers, body, callback) {
|
||||
@ -90,8 +96,7 @@ function doSendMessageAndCheckSuccess(receivers, body, callback) {
|
||||
is(message.id, saved.id, "message.id");
|
||||
is(message.receiver, saved.receiver, "message.receiver");
|
||||
is(message.body, saved.body, "message.body");
|
||||
is(message.timestamp, saved.timestamp,
|
||||
"the messages got from onsent event and request result must be the same");
|
||||
is(message.timestamp, saved.timestamp, "message.timestamp");
|
||||
|
||||
opt[mark] = true;
|
||||
|
||||
|
@ -33,7 +33,7 @@ function run_test() {
|
||||
*/
|
||||
add_test(function test_interface() {
|
||||
let sms = newMessage(null, null, ICC_ID, "sent", "success", null, null, null,
|
||||
"normal", new Date(), 0, true);
|
||||
"normal", new Date(), new Date(), new Date(), true);
|
||||
do_check_true(sms instanceof Ci.nsIDOMMozSmsMessage);
|
||||
do_check_eq(sms.id, 0);
|
||||
do_check_eq(sms.threadId, 0);
|
||||
@ -44,7 +44,6 @@ add_test(function test_interface() {
|
||||
do_check_eq(sms.sender, null);
|
||||
do_check_eq(sms.body, null);
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_eq(sms.deliveryTimestamp, 0);
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -54,7 +53,7 @@ add_test(function test_interface() {
|
||||
*/
|
||||
add_test(function test_icc_id_not_available() {
|
||||
let sms = newMessage(null, null, null, "sent", "success", null, null, null,
|
||||
"normal", new Date(), 0, true);
|
||||
"normal", new Date(), new Date(), new Date(), true);
|
||||
do_check_true(sms instanceof Ci.nsIDOMMozSmsMessage);
|
||||
do_check_eq(sms.id, 0);
|
||||
do_check_eq(sms.threadId, 0);
|
||||
@ -65,7 +64,6 @@ add_test(function test_icc_id_not_available() {
|
||||
do_check_eq(sms.sender, null);
|
||||
do_check_eq(sms.body, null);
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_eq(sms.deliveryTimestamp, 0);
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -74,8 +72,8 @@ add_test(function test_icc_id_not_available() {
|
||||
* Verify that attributes are read-only.
|
||||
*/
|
||||
add_test(function test_readonly_attributes() {
|
||||
let sms = newMessage(null, null, ICC_ID, "received", "success", null, null, null,
|
||||
"normal", new Date(), 0, true);
|
||||
let sms = newMessage(null, null, ICC_ID, "sent", "success", null, null, null,
|
||||
"normal", new Date(), new Date(), new Date(), true);
|
||||
|
||||
sms.id = 1;
|
||||
do_check_eq(sms.id, 0);
|
||||
@ -86,8 +84,8 @@ add_test(function test_readonly_attributes() {
|
||||
sms.iccId = "987654321";
|
||||
do_check_eq(sms.iccId, ICC_ID);
|
||||
|
||||
sms.delivery = "sent";
|
||||
do_check_eq(sms.delivery, "received");
|
||||
sms.delivery = "received";
|
||||
do_check_eq(sms.delivery, "sent");
|
||||
|
||||
sms.deliveryStatus = "pending";
|
||||
do_check_eq(sms.deliveryStatus, "success");
|
||||
@ -108,6 +106,10 @@ add_test(function test_readonly_attributes() {
|
||||
sms.timestamp = Date.now();
|
||||
do_check_eq(sms.timestamp, oldTimestamp);
|
||||
|
||||
let oldSentTimestamp = sms.sentTimestamp;
|
||||
sms.sentTimestamp = Date.now();
|
||||
do_check_eq(sms.sentTimestamp, oldSentTimestamp);
|
||||
|
||||
let oldDeliveryTimestamp = sms.deliveryTimestamp;
|
||||
sms.deliveryTimestamp = Date.now();
|
||||
do_check_eq(sms.deliveryTimestamp, oldDeliveryTimestamp);
|
||||
@ -124,7 +126,7 @@ add_test(function test_readonly_attributes() {
|
||||
add_test(function test_timestamp_number() {
|
||||
let ts = Date.now();
|
||||
let sms = newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", ts, 0, true);
|
||||
"the body", "normal", ts, ts, ts, true);
|
||||
do_check_eq(sms.id, 42);
|
||||
do_check_eq(sms.threadId, 1);
|
||||
do_check_eq(sms.iccId, ICC_ID);
|
||||
@ -135,7 +137,8 @@ add_test(function test_timestamp_number() {
|
||||
do_check_eq(sms.body, "the body");
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_eq(sms.timestamp, ts);
|
||||
do_check_eq(sms.deliveryTimestamp, 0);
|
||||
do_check_eq(sms.sentTimestamp, ts);
|
||||
do_check_eq(sms.deliveryTimestamp, ts);
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -146,7 +149,7 @@ add_test(function test_timestamp_number() {
|
||||
add_test(function test_timestamp_date() {
|
||||
let date = new Date();
|
||||
let sms = newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", date, 0, true);
|
||||
"the body", "normal", date, date, date, true);
|
||||
do_check_eq(sms.id, 42);
|
||||
do_check_eq(sms.threadId, 1);
|
||||
do_check_eq(sms.iccId, ICC_ID);
|
||||
@ -157,7 +160,8 @@ add_test(function test_timestamp_date() {
|
||||
do_check_eq(sms.body, "the body");
|
||||
do_check_eq(sms.messageClass, "normal");
|
||||
do_check_eq(sms.timestamp, date.getTime());
|
||||
do_check_eq(sms.deliveryTimestamp, 0);
|
||||
do_check_eq(sms.sentTimestamp, date.getTime());
|
||||
do_check_eq(sms.deliveryTimestamp, date.getTime());
|
||||
do_check_true(sms.read);
|
||||
run_next_test();
|
||||
});
|
||||
@ -169,13 +173,19 @@ add_test(function test_invalid_timestamp_float() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 3.1415, 0, true);
|
||||
"the body", "normal", 3.1415, new Date(), new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test sentTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", new Date(), 3.1415, new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, 3.1415, true);
|
||||
"the body", "normal", new Date(), new Date(), 3.1415, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
@ -188,13 +198,19 @@ add_test(function test_invalid_timestamp_null() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", null, 0, true);
|
||||
"the body", "normal", null, new Date(), new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test sentTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", new Date(), null, new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, null, true);
|
||||
"the body", "normal", new Date(), new Date(), null, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
@ -207,13 +223,19 @@ add_test(function test_invalid_timestamp_undefined() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", undefined, 0, true);
|
||||
"the body", "normal", undefined, new Date(), new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test sentTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", new Date(), undefined, new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, undefined, true);
|
||||
"the body", "normal", new Date(), new Date(), undefined, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
@ -226,13 +248,19 @@ add_test(function test_invalid_timestamp_object() {
|
||||
// Test timestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", {}, 0, true);
|
||||
"the body", "normal", {}, new Date(), new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test sentTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", new Date(), {}, new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
// Test deliveryTimestamp.
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "normal", 0, {}, true);
|
||||
"the body", "normal", new Date(), new Date(), {}, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
run_next_test();
|
||||
@ -244,7 +272,7 @@ add_test(function test_invalid_timestamp_object() {
|
||||
add_test(function test_invalid_delivery_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "this is invalid", "pending", "the sender",
|
||||
"the receiver", "the body", "normal", new Date(), 0, true);
|
||||
"the receiver", "the body", "normal", new Date(), 0, 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -255,7 +283,7 @@ add_test(function test_invalid_delivery_string() {
|
||||
add_test(function test_invalid_delivery_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, 1, "pending", "the sender", "the receiver", "the body",
|
||||
"normal", new Date(), 0, true);
|
||||
"normal", new Date(), 0, 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -266,7 +294,7 @@ add_test(function test_invalid_delivery_string() {
|
||||
add_test(function test_invalid_delivery_status_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "this is invalid", "the sender", "the receiver",
|
||||
"the body", "normal", new Date(), 0, true);
|
||||
"the body", "normal", new Date(), new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -277,7 +305,7 @@ add_test(function test_invalid_delivery_status_string() {
|
||||
add_test(function test_invalid_delivery_status_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", 1, "the sender", "the receiver", "the body",
|
||||
"normal", new Date(), 0, true);
|
||||
"normal", new Date(), new Date(), 0, true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -288,7 +316,7 @@ add_test(function test_invalid_delivery_status_string() {
|
||||
add_test(function test_invalid_message_class_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", "this is invalid", new Date(), 0, true);
|
||||
"the body", "this is invalid", new Date(), new Date(), new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
@ -299,7 +327,7 @@ add_test(function test_invalid_message_class_string() {
|
||||
add_test(function test_invalid_message_class_string() {
|
||||
do_check_throws(function() {
|
||||
newMessage(42, 1, ICC_ID, "sent", "success", "the sender", "the receiver",
|
||||
"the body", 1, new Date(), 0, true);
|
||||
"the body", 1, new Date(), new Date(), new Date(), true);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
run_next_test();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user