Bug 807055 - Fix SMS test_timestamp.js random orange, update manifest; r=jgriffin, DONTBUILD(NPOTB)
authorRob Wood <rwood@mozilla.com>
Wed, 31 Oct 2012 14:45:21 -0400
changeset 116679 570c7cb5b03dc844b22b7d39cdf05f0c91906fc8
parent 116678 de2e5f230811124a1a255030270fd8d77b4956cc
child 116680 c5fbfc1b1a94b19ce586976aa950aaf949562302
child 116758 9268740945659fbd43cf25580c7baff9c8c9ecc2
push id2735
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 23:12:38 +0000
treeherdermozilla-aurora@b3950b0ad29a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin, DONTBUILD
bugs807055
milestone19.0a1
Bug 807055 - Fix SMS test_timestamp.js random orange, update manifest; r=jgriffin, DONTBUILD(NPOTB)
dom/sms/tests/marionette/manifest.ini
dom/sms/tests/marionette/test_timestamp.js
--- a/dom/sms/tests/marionette/manifest.ini
+++ b/dom/sms/tests/marionette/manifest.ini
@@ -6,9 +6,8 @@ qemu = true
 ;[test_between_emulators.py]
 [test_incoming.js]
 [test_outgoing.js]
 [test_message_classes.js]
 [test_incoming_delete.js]
 [test_outgoing_delete.js]
 [test_getmessage.js]
 [test_getmessage_notfound.js]
-[test_timestamp.js]
deleted file mode 100644
--- a/dom/sms/tests/marionette/test_timestamp.js
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 15000;
-
-SpecialPowers.setBoolPref("dom.sms.enabled", true);
-SpecialPowers.addPermission("sms", true, document);
-
-let sms = window.navigator.mozSms;
-let inText;
-let remoteNumber = "5559997777";
-let outText;
-let gotSmsOnsent;
-let gotReqOnsuccess;
-let inSmsId = 0;
-let outSmsId = 0;
-let inSmsTime = 0;
-let outSmsTime = 0;
-let testCount = 10;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(sms, "mozSms");
-  simulateIncomingSms();  
-}
-
-function simulateIncomingSms() {
-  log("Simulating incoming SMS.");
-
-  sms.onreceived = function onreceived(event) {
-    log("Received 'onreceived' smsmanager event.");
-    let incomingSms = event.message;
-    ok(incomingSms, "incoming sms");
-    ok(incomingSms.id, "sms id");
-    inSmsId = incomingSms.id;
-    is(incomingSms.body, inText, "msg body");
-    is(incomingSms.delivery, "received", "delivery");
-    is(incomingSms.read, false, "read");
-    is(incomingSms.receiver, null, "receiver");
-    is(incomingSms.sender, remoteNumber, "sender");
-    is(incomingSms.messageClass, "normal", "messageClass");
-    ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
-    // The max resolution of the SCTS (SMS Centre TimeStamp) is one second
-    // therefore we want to compare in seconds not milliseconds. No need to
-    // round received sms timestamp, the value is in milliseconds but at
-    // seconds resolution already (always ends with 000) so just convert
-    inSmsTime = Math.floor(incomingSms.timestamp.getTime() / 1000);
-    log("Received SMS (id: " + inSmsId + ") timestamp: " + inSmsTime + ".");
-    if(outSmsTime) {
-      // Test is repeating; compare received SMS timestamp with last sent sms.
-      // Can be some time drift between the SCTS and host/emulator, but we are
-      // comparing seconds (not milliseconds) so should be ok. If this test
-      // goes random orange, then may need to add a 1 second lee-way here.
-      if(inSmsTime >= outSmsTime) {
-        log("Timestamp in sms " + inSmsId + " is >= timestamp in sms "
-            + outSmsId + ".");
-      } else {
-        log("* Timestamp in sms " + inSmsId + " is < timestamp in sms "
-            + outSmsId + ".");
-        ok(false, "sms timestamp is incorrect");
-      }
-    }
-    sendSms();
-  };
-  // Simulate incoming sms sent from remoteNumber to our emulator
-  inText = "Incoming SMS " + Date.now();
-  runEmulatorCmd("sms send " + remoteNumber + " " + inText, function(result) {
-    is(result[0], "OK", "emulator output");
-  });
-}
-
-function sendSms() {
-  log("Sending an SMS.");
-  let gotSmsOnsent = false;
-  let gotReqOnsuccess = false;  
-  sms.onsent = function(event) {
-    log("Received 'onsent' smsmanager event.");
-    gotSmsOnsent = true;
-    let sentSms = event.message;
-    ok(sentSms, "outgoing sms");
-    ok(sentSms.id, "sms id");
-    outSmsId = sentSms.id;
-    is(sentSms.body, outText, "msg body");
-    is(sentSms.delivery, "sent", "delivery");
-    is(sentSms.read, true, "read");
-    is(sentSms.receiver, remoteNumber, "receiver");
-    is(sentSms.sender, null, "sender");
-    is(sentSms.messageClass, "normal", "messageClass");
-    ok(sentSms.timestamp instanceof Date, "timestamp is instanceof date");
-    // The max resolution of the SCTS (SMS Centre TimeStamp) is one second
-    // therefore we want to compare in seconds not milliseconds. Round the
-    // sent sms timestamp to nearest second.
-    outSmsTime = Math.round(sentSms.timestamp.getTime() / 1000);
-    log("Sent SMS (id: " + outSmsId + ") timestamp: " + outSmsTime + ".");
-
-    if (gotSmsOnsent && gotReqOnsuccess) { verifyTimeStamps(); }
-  };
-  outText = "Outgoing SMS " + Date.now();
-  let requestRet = sms.send(remoteNumber, outText);
-  ok(requestRet, "smsrequest obj returned");
-
-  requestRet.onsuccess = function(event) {
-    log("Received 'onsuccess' smsrequest event.");
-    gotReqOnsuccess = true;
-    if(event.target.result){
-      if (gotSmsOnsent && gotReqOnsuccess) { verifyTimeStamps(); }
-    } else {
-      log("smsrequest returned false for sms.send");
-      ok(false,"SMS send failed");
-      cleanUp();
-    }
-  };
-
-  requestRet.onerror = function(event) {
-    log("Received 'onerror' smsrequest event.");
-    ok(event.target.error, "domerror obj");
-    ok(false, "sms.send request returned unexpected error: "
-        + event.target.error.name );
-    cleanUp();
-  };
-}
-
-function verifyTimeStamps() {
-  // Compare sent sms timestamp with that of the previously received sms.
-  // Can be some time drift between the SCTS and host/emulator, but we are
-  // comparing seconds (not milliseconds) so should be ok. If this test
-  // goes random orange, then may need to add a 1 second lee-way here.
-  if(outSmsTime >= inSmsTime) {
-    log("Timestamp in sms " + outSmsId + " is >= timestamp in sms "
-        + inSmsId + ".");
-  } else {
-    log("* Timestamp in sms " + outSmsId + " is < timestamp in sms "
-        + inSmsId + ".");
-    ok(false, "sms timestamp is incorrect");
-  }
-  deleteMsgs();
-}
-
-function deleteMsgs() {
-  log("Deleting SMS (id: " + inSmsId + ").");
-  let requestRet = sms.delete(inSmsId);
-  ok(requestRet,"smsrequest obj returned");
-
-  requestRet.onsuccess = function(event) {
-    log("Received 'onsuccess' smsrequest event.");
-    if(event.target.result){
-      log("Deleting SMS (id: " + outSmsId + ").");
-      let nextReqRet = sms.delete(outSmsId);
-      ok(nextReqRet,"smsrequest obj returned");
-
-      nextReqRet.onsuccess = function(event) {
-        log("Received 'onsuccess' smsrequest event.");
-        if(event.target.result) {
-          if(--testCount) {
-            simulateIncomingSms();
-          } else {
-            cleanUp();
-          }
-        } else {
-          log("smsrequest returned false for sms.delete");
-          ok(false,"SMS delete failed");
-          cleanUp();
-        }
-      };
-    } else {
-      log("smsrequest returned false for sms.delete");
-      ok(false,"SMS delete failed");
-      cleanUp();
-    }
-  };
-
-  requestRet.onerror = function(event) {
-    log("Received 'onerror' smsrequest event.");
-    ok(event.target.error, "domerror obj");
-    ok(false, "sms.delete request returned unexpected error: "
-        + event.target.error.name );
-    cleanUp();
-  };
-}
-
-function cleanUp() {
-  sms.onreceived = null;
-  SpecialPowers.removePermission("sms", document);
-  SpecialPowers.setBoolPref("dom.sms.enabled", false);
-  finish();
-}
-
-// Start the test
-verifyInitialState();