Bug 912884 - Part 2: Update test case. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2013-09-09 08:19:49 -04:00
parent 5de41462c1
commit 08b26f52e1

View File

@ -28,14 +28,15 @@ function _getWorker() {
var timeoutCallback = null; var timeoutCallback = null;
var timeoutDelayMs = 0; 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. // No window in xpcshell-test. Create our own timer mechanism.
function setTimeout(callback, timeoutMs) { function setTimeout(callback, timeoutMs) {
timeoutCallback = callback; timeoutCallback = callback;
timeoutDelayMs = timeoutMs; timeoutDelayMs = timeoutMs;
do_check_eq(timeoutMs, 300000); // 5 mins. do_check_eq(timeoutMs, TIMEOUT_VALUE);
return TIMER_ID; return TIMER_ID;
} }
@ -56,6 +57,8 @@ add_test(function test_enter_emergencyCbMode() {
let workerHelper = _getWorker(); let workerHelper = _getWorker();
let worker = workerHelper.worker; let worker = workerHelper.worker;
// Do it twice. Should always send the event.
for (let i = 0; i < 2; ++i) {
worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE](); worker.RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE]();
let postedMessage = workerHelper.postedMessage; let postedMessage = workerHelper.postedMessage;
@ -65,10 +68,11 @@ add_test(function test_enter_emergencyCbMode() {
// Should notify change. // Should notify change.
do_check_eq(postedMessage.rilMessageType, "emergencyCbModeChange"); do_check_eq(postedMessage.rilMessageType, "emergencyCbModeChange");
do_check_eq(postedMessage.active, true); do_check_eq(postedMessage.active, true);
do_check_eq(postedMessage.timeoutMs, 300000); do_check_eq(postedMessage.timeoutMs, TIMEOUT_VALUE);
// Should start timer. // Should start timer.
do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID); do_check_eq(worker.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
}
run_next_test(); run_next_test();
}); });