Bug 912884 - Part 2: Update test case. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Mon, 09 Sep 2013 08:19:49 -0400
changeset 146148 035ce07737626ce7fa3b5651d0b63b7e30798e05
parent 146147 f7ac432b38b5d1d15e58ae41d80fe4d209ac280a
child 146149 2dd351292f7cc21f6e657bb285b5b98b3984d28b
push id25243
push userryanvm@gmail.com
push dateMon, 09 Sep 2013 19:52:36 +0000
treeherdermozilla-central@9edc229b7d09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs912884
milestone26.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 912884 - Part 2: Update test case. r=hsinyi
dom/system/gonk/tests/test_ril_worker_ecm.js
--- a/dom/system/gonk/tests/test_ril_worker_ecm.js
+++ b/dom/system/gonk/tests/test_ril_worker_ecm.js
@@ -23,24 +23,25 @@ function _getWorker() {
     get worker() {
       return _worker;
     }
   };
 }
 
 var timeoutCallback = null;
 var timeoutDelayMs = 0;
-var TIMER_ID = 1234;
+const TIMER_ID = 1234;
+const TIMEOUT_VALUE = 300000;  // 5 mins.
 
 // No window in xpcshell-test. Create our own timer mechanism.
 
 function setTimeout(callback, timeoutMs) {
   timeoutCallback = callback;
   timeoutDelayMs = timeoutMs;
-  do_check_eq(timeoutMs, 300000);  // 5 mins.
+  do_check_eq(timeoutMs, TIMEOUT_VALUE);
   return TIMER_ID;
 }
 
 function clearTimeout(timeoutId) {
   do_check_eq(timeoutId, TIMER_ID);
   timeoutCallback = null;
 }
 
@@ -51,29 +52,32 @@ function fireTimeout() {
     timeoutCallback = null;
   }
 }
 
 add_test(function test_enter_emergencyCbMode() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
-  let postedMessage = workerHelper.postedMessage;
+  // Do it twice. Should always send the event.
+  for (let i = 0; i < 2; ++i) {
+    worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
+    let postedMessage = workerHelper.postedMessage;
 
-  // Should store the mode.
-  do_check_eq(worker.RIL._isInEmergencyCbMode, true);
+    // Should store the mode.
+    do_check_eq(worker.RIL._isInEmergencyCbMode, true);
 
-  // Should notify change.
-  do_check_eq(postedMessage.rilMessageType, "emergencyCbModeChange");
-  do_check_eq(postedMessage.active, true);
-  do_check_eq(postedMessage.timeoutMs, 300000);
+    // Should notify change.
+    do_check_eq(postedMessage.rilMessageType, "emergencyCbModeChange");
+    do_check_eq(postedMessage.active, true);
+    do_check_eq(postedMessage.timeoutMs, TIMEOUT_VALUE);
 
-  // Should start timer.
-  do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
+    // Should start timer.
+    do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
+  }
 
   run_next_test();
 });
 
 add_test(function test_exit_emergencyCbMode() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;