Bug 1138757 - Part 2: Add Test Coverage for CDMA Wap Push. r=echen
authorBevis Tseng <btseng@mozilla.com>
Tue, 03 Mar 2015 15:40:09 +0800
changeset 231816 82be6cb648403f6d67372a9b1f5b43be08432d10
parent 231815 c6e3576bab27e851bceaed97e4ab2018908da5d5
child 231817 e68e1c2545ca82b39627b9d6e3172c29d3fa526b
push id28360
push userryanvm@gmail.com
push dateWed, 04 Mar 2015 20:58:22 +0000
treeherdermozilla-central@04653ab2dcb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1138757
milestone39.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 1138757 - Part 2: Add Test Coverage for CDMA Wap Push. r=echen
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));
+});