Bug 973024 - 1.b/3: share newInterceptWorker. r=yoshi

This commit is contained in:
Vicamo Yang 2014-06-23 20:56:03 +08:00
parent dfa8d115d2
commit edfc885756
10 changed files with 64 additions and 214 deletions

View File

@ -110,6 +110,28 @@ function newUint8Worker() {
return worker;
}
/**
* Create a worker that keeps posted chrome message.
*/
function newInterceptWorker() {
let postedMessage;
let worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
postedMessage = message;
}
});
return {
get postedMessage() {
return postedMessage;
},
get worker() {
return worker;
}
};
}
/**
* Create a parcel suitable for postRILMessage().
*

View File

@ -52,27 +52,8 @@ add_test(function test_toaFromString_international() {
run_next_test();
});
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
add_test(function test_setCallForward_unconditional() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -99,7 +80,7 @@ add_test(function test_setCallForward_unconditional() {
});
add_test(function test_queryCallForwardStatus_unconditional() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -7,27 +7,8 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
add_test(function test_queryCLIP_provisioned() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -56,7 +37,7 @@ add_test(function test_queryCLIP_provisioned() {
});
add_test(function test_getCLIP_error_generic_failure_invalid_length() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -16,27 +16,8 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
add_test(function test_setCLIR_success() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -60,7 +41,7 @@ add_test(function test_setCLIR_success() {
});
add_test(function test_setCLIR_generic_failure() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -84,7 +65,7 @@ add_test(function test_setCLIR_generic_failure() {
});
add_test(function test_getCLIR_n0_m1() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -117,7 +98,7 @@ add_test(function test_getCLIR_n0_m1() {
});
add_test(function test_getCLIR_error_generic_failure_invalid_length() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -7,27 +7,8 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
add_test(function test_setCallWaiting_success() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -50,7 +31,7 @@ add_test(function test_setCallWaiting_success() {
});
add_test(function test_setCallWaiting_generic_failure() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -73,7 +54,7 @@ add_test(function test_setCallWaiting_generic_failure() {
});
add_test(function test_queryCallWaiting_success_enabled_true() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -104,7 +85,7 @@ add_test(function test_queryCallWaiting_success_enabled_true() {
});
add_test(function test_queryCallWaiting_success_enabled_false() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -7,25 +7,6 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
var timeoutCallback = null;
var timeoutDelayMs = 0;
const TIMER_ID = 1234;
@ -54,7 +35,7 @@ function fireTimeout() {
}
add_test(function test_enter_emergencyCbMode() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -79,7 +60,7 @@ add_test(function test_enter_emergencyCbMode() {
});
add_test(function test_exit_emergencyCbMode() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -101,7 +82,7 @@ add_test(function test_exit_emergencyCbMode() {
});
add_test(function test_request_exit_emergencyCbMode_when_timeout() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -127,7 +108,7 @@ add_test(function test_request_exit_emergencyCbMode_when_timeout() {
});
add_test(function test_request_exit_emergencyCbMode_when_dial() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -154,7 +135,7 @@ add_test(function test_request_exit_emergencyCbMode_when_dial() {
});
add_test(function test_request_exit_emergencyCbMode_explicitly() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -20,28 +20,8 @@ function parseMMI(mmi) {
return context.RIL._parseMMI(mmi);
}
function getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
},
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
function testSendMMI(mmi, error) {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -371,7 +351,7 @@ add_test(function test_sendMMI_invalid() {
});
add_test(function test_sendMMI_short_code() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -404,7 +384,7 @@ add_test(function test_sendMMI_dial_string() {
});
function setCallForwardSuccess(mmi) {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -436,7 +416,7 @@ add_test(function test_sendMMI_call_forwarding_deactivation() {
});
add_test(function test_sendMMI_call_forwarding_interrogation() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -478,7 +458,7 @@ add_test(function test_sendMMI_call_forwarding_interrogation() {
});
add_test(function test_sendMMI_call_forwarding_interrogation_no_rules() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -547,7 +527,7 @@ add_test(function test_sendMMI_call_forwarding_CFAllConditional() {
});
add_test(function test_sendMMI_change_PIN() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -593,7 +573,7 @@ add_test(function test_sendMMI_change_PIN_new_PIN_mismatch() {
});
add_test(function test_sendMMI_change_PIN2() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -639,7 +619,7 @@ add_test(function test_sendMMI_change_PIN2_new_PIN2_mismatch() {
});
add_test(function test_sendMMI_unblock_PIN() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -685,7 +665,7 @@ add_test(function test_sendMMI_unblock_PIN_new_PIN_mismatch() {
});
add_test(function test_sendMMI_unblock_PIN2() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -731,7 +711,7 @@ add_test(function test_sendMMI_unblock_PIN2_new_PIN_mismatch() {
});
add_test(function test_sendMMI_get_IMEI() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
let mmiOptions;
@ -755,7 +735,7 @@ add_test(function test_sendMMI_get_IMEI() {
});
add_test(function test_sendMMI_get_IMEI_error() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
let mmiOptions;
@ -779,7 +759,7 @@ add_test(function test_sendMMI_get_IMEI_error() {
});
add_test(function test_sendMMI_call_barring_BAIC_interrogation_voice() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -810,7 +790,7 @@ add_test(function test_sendMMI_call_barring_BAIC_interrogation_voice() {
});
add_test(function test_sendMMI_call_barring_BAIC_activation() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
let mmiOptions;
@ -838,7 +818,7 @@ add_test(function test_sendMMI_call_barring_BAIC_activation() {
});
add_test(function test_sendMMI_call_barring_BAIC_deactivation() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
let mmiOptions;
@ -872,7 +852,7 @@ add_test(function test_sendMMI_call_barring_BAIC_procedure_not_supported() {
});
add_test(function test_sendMMI_USSD() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
let ussdOptions;
@ -898,7 +878,7 @@ add_test(function test_sendMMI_USSD() {
});
add_test(function test_sendMMI_USSD_error() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
let ussdOptions;
@ -924,7 +904,7 @@ add_test(function test_sendMMI_USSD_error() {
});
function setCallWaitingSuccess(mmi) {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];
@ -968,7 +948,7 @@ add_test(function test_sendMMI_call_waiting_erasure() {
});
add_test(function test_sendMMI_call_waiting_interrogation() {
let workerhelper = getWorker();
let workerhelper = newInterceptWorker();
let worker = workerhelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -7,25 +7,6 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
/*
* Helper function to covert a HEX string to a byte array.
*
@ -188,7 +169,7 @@ function pduToParcelData(cdmaPduHelper, pdu) {
* Verify CDMA SMS Delivery ACK Message.
*/
add_test(function test_processCdmaSmsStatusReport() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -262,7 +243,7 @@ add_test(function test_processCdmaSmsStatusReport() {
* Verify WAP Push over CDMA SMS Message.
*/
add_test(function test_processCdmaSmsWapPush() {
let workerHelper = _getWorker(),
let workerHelper = newInterceptWorker(),
worker = workerHelper.worker,
context = worker.ContextPool._contexts[0],
bitBufferHelper = context.BitBufferHelper,

View File

@ -7,27 +7,8 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
add_test(function test_notification() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];

View File

@ -7,27 +7,8 @@ function run_test() {
run_next_test();
}
function _getWorker() {
let _postedMessage;
let _worker = newWorker({
postRILMessage: function(data) {
},
postMessage: function(message) {
_postedMessage = message;
}
});
return {
get postedMessage() {
return _postedMessage;
},
get worker() {
return _worker;
}
};
}
add_test(function test_setVoicePrivacyMode_success() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -49,7 +30,7 @@ add_test(function test_setVoicePrivacyMode_success() {
});
add_test(function test_setVoicePrivacyMode_generic_failure() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -71,7 +52,7 @@ add_test(function test_setVoicePrivacyMode_generic_failure() {
});
add_test(function test_queryVoicePrivacyMode_success_enabled_true() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];
@ -95,7 +76,7 @@ add_test(function test_queryVoicePrivacyMode_success_enabled_true() {
});
add_test(function test_queryVoicePrivacyMode_success_enabled_false() {
let workerHelper = _getWorker();
let workerHelper = newInterceptWorker();
let worker = workerHelper.worker;
let context = worker.ContextPool._contexts[0];