2013-08-08 15:06:55 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
2014-05-12 12:17:13 +04:00
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
2013-08-08 15:06:55 +04:00
|
|
|
|
|
|
|
subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this);
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
run_next_test();
|
|
|
|
}
|
|
|
|
|
|
|
|
add_test(function test_setVoicePrivacyMode_success() {
|
2014-06-23 16:56:03 +04:00
|
|
|
let workerHelper = newInterceptWorker();
|
2013-08-08 15:06:55 +04:00
|
|
|
let worker = workerHelper.worker;
|
2014-02-17 15:35:13 +04:00
|
|
|
let context = worker.ContextPool._contexts[0];
|
2013-08-08 15:06:55 +04:00
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.setVoicePrivacyMode = function fakeSetVoicePrivacyMode(options) {
|
|
|
|
context.RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE](0, {
|
2013-08-08 15:06:55 +04:00
|
|
|
rilRequestError: ERROR_SUCCESS
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.setVoicePrivacyMode({
|
2013-08-08 15:06:55 +04:00
|
|
|
enabled: true
|
|
|
|
});
|
|
|
|
|
|
|
|
let postedMessage = workerHelper.postedMessage;
|
|
|
|
|
2015-02-12 14:18:00 +03:00
|
|
|
equal(postedMessage.errorMsg, undefined);
|
2013-08-08 15:06:55 +04:00
|
|
|
|
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
|
|
|
|
add_test(function test_setVoicePrivacyMode_generic_failure() {
|
2014-06-23 16:56:03 +04:00
|
|
|
let workerHelper = newInterceptWorker();
|
2013-08-08 15:06:55 +04:00
|
|
|
let worker = workerHelper.worker;
|
2014-02-17 15:35:13 +04:00
|
|
|
let context = worker.ContextPool._contexts[0];
|
2013-08-08 15:06:55 +04:00
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.setVoicePrivacyMode = function fakeSetVoicePrivacyMode(options) {
|
|
|
|
context.RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE](0, {
|
2014-05-12 12:17:13 +04:00
|
|
|
rilRequestError: ERROR_GENERIC_FAILURE,
|
|
|
|
errorMsg: GECKO_ERROR_GENERIC_FAILURE
|
2013-08-08 15:06:55 +04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.setVoicePrivacyMode({
|
2013-08-08 15:06:55 +04:00
|
|
|
enabled: true
|
|
|
|
});
|
|
|
|
|
|
|
|
let postedMessage = workerHelper.postedMessage;
|
|
|
|
|
2014-05-12 12:17:13 +04:00
|
|
|
equal(postedMessage.errorMsg, GECKO_ERROR_GENERIC_FAILURE);
|
2013-08-08 15:06:55 +04:00
|
|
|
|
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
|
|
|
|
add_test(function test_queryVoicePrivacyMode_success_enabled_true() {
|
2014-06-23 16:56:03 +04:00
|
|
|
let workerHelper = newInterceptWorker();
|
2013-08-08 15:06:55 +04:00
|
|
|
let worker = workerHelper.worker;
|
2014-02-17 15:35:13 +04:00
|
|
|
let context = worker.ContextPool._contexts[0];
|
2013-08-08 15:06:55 +04:00
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.Buf.readInt32List = function fakeReadUint32List() {
|
2013-08-08 15:06:55 +04:00
|
|
|
return [1];
|
|
|
|
};
|
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
|
|
|
|
context.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
|
2013-08-08 15:06:55 +04:00
|
|
|
rilRequestError: ERROR_SUCCESS
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.queryVoicePrivacyMode();
|
2013-08-08 15:06:55 +04:00
|
|
|
|
|
|
|
let postedMessage = workerHelper.postedMessage;
|
|
|
|
|
2015-02-12 14:18:00 +03:00
|
|
|
equal(postedMessage.errorMsg, undefined);
|
|
|
|
ok(postedMessage.enabled);
|
2013-08-08 15:06:55 +04:00
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
|
|
|
|
add_test(function test_queryVoicePrivacyMode_success_enabled_false() {
|
2014-06-23 16:56:03 +04:00
|
|
|
let workerHelper = newInterceptWorker();
|
2013-08-08 15:06:55 +04:00
|
|
|
let worker = workerHelper.worker;
|
2014-02-17 15:35:13 +04:00
|
|
|
let context = worker.ContextPool._contexts[0];
|
2013-08-08 15:06:55 +04:00
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.Buf.readInt32List = function fakeReadUint32List() {
|
2013-08-08 15:06:55 +04:00
|
|
|
return [0];
|
|
|
|
};
|
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
|
|
|
|
context.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
|
2013-08-08 15:06:55 +04:00
|
|
|
rilRequestError: ERROR_SUCCESS
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-17 15:35:13 +04:00
|
|
|
context.RIL.queryVoicePrivacyMode();
|
2013-08-08 15:06:55 +04:00
|
|
|
|
|
|
|
let postedMessage = workerHelper.postedMessage;
|
|
|
|
|
2015-02-12 14:18:00 +03:00
|
|
|
equal(postedMessage.errorMsg, undefined);
|
|
|
|
ok(!postedMessage.enabled);
|
2013-08-08 15:06:55 +04:00
|
|
|
run_next_test();
|
|
|
|
});
|