Bug 1138757 - Part 2: Add Test Coverage for CDMA Wap Push. r=echen, a=bajaj
authorBevis Tseng <btseng@mozilla.com>
Tue, 03 Mar 2015 15:40:09 +0800
changeset 237443 f850ac0af68a27e64f57307312f8a723facaf8af
parent 237442 d1c2dd2f5d4f6ed7f89edaad493e9d27eeb39ef5
child 237444 095de5dd0e8490a15d8e24b28c8e94a45b64e491
push id274
push userryanvm@gmail.com
push dateThu, 05 Mar 2015 21:09:52 +0000
treeherdermozilla-b2g37_v2_2@f850ac0af68a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen, bajaj
bugs1138757
milestone37.0
Bug 1138757 - Part 2: Add Test Coverage for CDMA Wap Push. r=echen, a=bajaj
dom/mobilemessage/tests/marionette/manifest.ini
dom/mobilemessage/tests/marionette/test_mmdb_ports_in_cdma_wappush.js
--- a/dom/mobilemessage/tests/marionette/manifest.ini
+++ b/dom/mobilemessage/tests/marionette/manifest.ini
@@ -38,14 +38,15 @@ qemu = true
 [test_dsds_default_service_id.js]
 [test_thread_subject.js]
 [test_mmdb_new.js]
 [test_mmdb_setmessagedeliverybyid_sms.js]
 [test_mmdb_foreachmatchedmmsdeliveryinfo.js]
 [test_mmdb_full_storage.js]
 [test_mmdb_upgradeSchema_current_structure.js]
 [test_mmdb_upgradeSchema_22.js]
+[test_mmdb_ports_in_cdma_wappush.js]
 [test_replace_short_message_type.js]
 [test_mt_sms_concatenation.js]
 [test_error_of_mms_manual_retrieval.js]
 [test_error_of_mms_send.js]
 [test_error_of_sms_send.js]
 [test_ondeleted_event.js]
new file mode 100644
--- /dev/null
+++ b/dom/mobilemessage/tests/marionette/test_mmdb_ports_in_cdma_wappush.js
@@ -0,0 +1,74 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = 'mmdb_head.js';
+
+const DBNAME = "test_mmdb_ports_in_cdma_wappush:" + newUUID();
+
+const TEST_PDU = [
+  {
+    sender: "+0987654321",
+    iccId: "1029384756",
+    segmentRef: 0,
+    segmentSeq: 1, // 1st segment
+    segmentMaxSeq: 2,
+    encoding: 0x04, // 8-bit encoding
+    data: [0, 1, 2],
+    teleservice: 0x1004, // PDU_CDMA_MSG_TELESERIVCIE_ID_WAP
+    // Port numbers are only provided in 1st segment from CDMA SMS PDUs.
+    originatorPort: 9200, // WDP_PORT_PUSH (server-side)
+    destinationPort: 2948 // WDP_PORT_PUSH (client-side)
+  },
+  {
+    sender: "+0987654321",
+    iccId: "1029384756",
+    segmentRef: 0,
+    segmentSeq: 2, // 2nd segment
+    segmentMaxSeq: 2,
+    encoding: 0x04, // 8-bit encoding
+    data: [3, 4, 5],
+    teleservice: 0x1004, // PDU_CDMA_MSG_TELESERIVCIE_ID_WAP
+    // Port numbers are only provided in 1st segment from CDMA SMS PDUs.
+    originatorPort: Ci.nsIGonkSmsService.SMS_APPLICATION_PORT_INVALID,
+    destinationPort: Ci.nsIGonkSmsService.SMS_APPLICATION_PORT_INVALID
+  }
+];
+
+function testSaveCdmaWapPush(aMmdb, aReverse) {
+  log("testSaveCdmaWapPush(), aReverse: " + aReverse);
+
+  let testPDUs = aReverse ? Array.from(TEST_PDU).reverse() : TEST_PDU;
+  let lengthOfFullData = 0;
+  let promises = [];
+
+  for (let pdu of testPDUs) {
+    lengthOfFullData += pdu.data.length;
+    promises.push(saveSmsSegment(aMmdb, pdu));
+  };
+
+  return Promise.all(promises)
+    .then((aResults) => {
+      // Complete message shall be returned after 2 segments are saved.
+      let completeMsg = aResults[1][1];
+
+      is(completeMsg.originatorPort, TEST_PDU[0].originatorPort, "originatorPort");
+      is(completeMsg.destinationPort, TEST_PDU[0].destinationPort, "destinationPort");
+
+      is(completeMsg.fullData.length, lengthOfFullData, "fullData.length");
+      for (let i = 0; i < lengthOfFullData; i++) {
+        is(completeMsg.fullData[i], i, "completeMsg.fullData[" + i + "]");
+      }
+    });
+}
+
+startTestBase(function testCaseMain() {
+
+  let mmdb = newMobileMessageDB();
+  return initMobileMessageDB(mmdb, DBNAME, 0)
+
+    .then(() => testSaveCdmaWapPush(mmdb, false))
+    .then(() => testSaveCdmaWapPush(mmdb, true))
+
+    .then(() => closeMobileMessageDB(mmdb));
+});