Bug 1211418 - Part 2: Add Test Coverage for the Collision of SMS Segment. r=echen.
authorBevis Tseng <btseng@mozilla.com>
Wed, 07 Oct 2015 10:51:33 +0800
changeset 267413 b61b2827299785c726fa70892b8df3514dffb103
parent 267412 f5aaa8f6179980648dbbd765ebb5b384e6094904
child 267414 6611408430fb3ea33044623b8144107d2117f17c
push id29519
push usercbook@mozilla.com
push dateWed, 14 Oct 2015 10:29:57 +0000
treeherdermozilla-central@6307530f9f1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1211418
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1211418 - Part 2: Add Test Coverage for the Collision of SMS Segment. r=echen.
dom/mobilemessage/tests/marionette/test_mt_sms_concatenation.js
--- a/dom/mobilemessage/tests/marionette/test_mt_sms_concatenation.js
+++ b/dom/mobilemessage/tests/marionette/test_mt_sms_concatenation.js
@@ -21,40 +21,50 @@ const PDU_DCS_CLASS0_8BIT = "14";
 const PDU_TIMESTAMP = "00101000000000"; // 2000/01/01
 
 function byteValueToHexString(aValue) {
   let str = Number(aValue).toString(16).toUpperCase();
   return str.length == 1 ? "0" + str : str;
 }
 
 var ref_num = 0;
-function buildTextPdus(aDcs) {
+function buildTextPdus(aDcs, aInsertDuplication = false) {
   ref_num++;
 
   let IEI_CONCATE_1 = "0003" + byteValueToHexString(ref_num) + "0301";
   let IEI_CONCATE_2 = "0003" + byteValueToHexString(ref_num) + "0302";
   let IEI_CONCATE_3 = "0003" + byteValueToHexString(ref_num) + "0303";
   let PDU_UDL = "08"; // UDHL(1) + UDH(5) + UCS2 Char (2)
   let PDU_UDHL = "05";
 
   let PDU_UD_A = "0041"; // "A"
   let PDU_UD_B = "0042"; // "B"
   let PDU_UD_C = "0043"; // "C"
 
   let PDU_COMMON = PDU_SMSC_NONE + PDU_FIRST_OCTET + PDU_SENDER +
     PDU_PID_NORMAL + aDcs + PDU_TIMESTAMP + PDU_UDL + PDU_UDHL;
 
-  return [
+  let pdus = [
     PDU_COMMON + IEI_CONCATE_1 + PDU_UD_A,
     PDU_COMMON + IEI_CONCATE_2 + PDU_UD_B,
     PDU_COMMON + IEI_CONCATE_3 + PDU_UD_C
   ];
+
+  if (aInsertDuplication) {
+    log("Insert Duplicated text PDU");
+    // The 2nd PDU_UD_A is expected to be ignored.
+    pdus.unshift(PDU_COMMON + IEI_CONCATE_1 + PDU_UD_A);
+    // Expected to be replaced with PDU_UD_A;
+    pdus.unshift(PDU_COMMON + IEI_CONCATE_1 + PDU_UD_C);
+  }
+
+  return pdus;
 }
 
-function buildBinaryPdus(aDcs) {
+function buildBinaryPdus(aDcs, aInsertDuplication = false) {
   ref_num++;
   let IEI_PORT = "05040B8423F0";
 
   let PDU_DATA1 = "C106316170706C69636174696F6E2F76" +
                   "6E642E7761702E6D6D732D6D65737361" +
                   "676500B131302E382E3133302E313800" +
                   "AF84B4818C82986B4430595538595347" +
                   "77464E446741416B4876736C58303141" +
@@ -76,20 +86,30 @@ function buildBinaryPdus(aDcs) {
     let udh = IEI_PORT + ieiConcat;
     let udhl = byteValueToHexString(udh.length / 2);
     let ud = udhl + udh + aBinaryData;
     let udl = byteValueToHexString(ud.length / 2);
 
     return udl + ud;
   }
 
-  return [
+  let pdus = [
     PDU_COMMON + construstBinaryUserData(PDU_DATA1, 1),
     PDU_COMMON + construstBinaryUserData(PDU_DATA2, 2)
   ];
+
+  if (aInsertDuplication) {
+    log("Insert Duplicated binary PDU");
+    // The 2nd PDU_DATA1 is expected to be ignored.
+    pdus.unshift(PDU_COMMON + construstBinaryUserData(PDU_DATA1, 1));
+    // Expected to be replaced with PDU_DATA1;
+    pdus.unshift(PDU_COMMON + construstBinaryUserData(PDU_DATA2, 1));
+  }
+
+  return pdus;
 }
 
 function verifyTextMessage(aMessage, aMessageClass) {
   is(aMessage.messageClass, aMessageClass, "SmsMessage class");
   is(aMessage.sender, SENDER, "SmsMessage sender");
   is(aMessage.body, "ABC", "SmsMessage body");
 }
 
@@ -99,22 +119,26 @@ function verifyBinaryMessage(aMessage) {
 
   // remove duplicated M-Notification.ind for next test.
   return deleteMessagesById([aMessage.id]);
 }
 
 function testText(aDcs, aClass) {
   log("testText(): aDcs = " + aDcs + ", aClass = " + aClass);
   return sendMultipleRawSmsToEmulatorAndWait(buildTextPdus(aDcs))
+    .then((results) => verifyTextMessage(results[0].message, aClass))
+    .then(() => sendMultipleRawSmsToEmulatorAndWait(buildTextPdus(aDcs, true)))
     .then((results) => verifyTextMessage(results[0].message, aClass));
 }
 
 function testBinary(aDcs) {
   log("testBinary(): aDcs = " + aDcs);
   return sendMultipleRawSmsToEmulatorAndWait(buildBinaryPdus(aDcs))
+    .then((results) => verifyBinaryMessage(results[0].message))
+    .then(() => sendMultipleRawSmsToEmulatorAndWait(buildBinaryPdus(aDcs, true)))
     .then((results) => verifyBinaryMessage(results[0].message));
 }
 
 SpecialPowers.pushPrefEnv(
   {"set": [["dom.mms.retrieval_mode", "manual"]]},
   function startTest() {
     startTestCommon(function testCaseMain() {
       return Promise.resolve()