2013-07-17 08:28:34 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this);
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
run_next_test();
|
|
|
|
}
|
|
|
|
|
|
|
|
function _getWorker() {
|
|
|
|
let _postedMessage;
|
|
|
|
let _worker = newWorker({
|
2014-01-12 18:44:40 -08:00
|
|
|
postRILMessage: function(data) {
|
2013-07-17 08:28:34 -07:00
|
|
|
},
|
2014-01-12 18:44:40 -08:00
|
|
|
postMessage: function(message) {
|
2013-07-17 08:28:34 -07:00
|
|
|
_postedMessage = message;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
get postedMessage() {
|
|
|
|
return _postedMessage;
|
|
|
|
},
|
|
|
|
get worker() {
|
|
|
|
return _worker;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
add_test(function test_queryCLIP_provisioned() {
|
|
|
|
let workerHelper = _getWorker();
|
|
|
|
let worker = workerHelper.worker;
|
2014-02-17 03:35:13 -08:00
|
|
|
let context = worker.ContextPool._contexts[0];
|
2013-07-17 08:28:34 -07:00
|
|
|
|
2014-02-17 03:35:13 -08:00
|
|
|
context.Buf.readInt32 = function fakeReadUint32() {
|
|
|
|
return context.Buf.int32Array.pop();
|
2013-07-17 08:28:34 -07:00
|
|
|
};
|
|
|
|
|
2014-02-17 03:35:13 -08:00
|
|
|
context.RIL.queryCLIP = function fakeQueryCLIP(options) {
|
|
|
|
context.Buf.int32Array = [
|
2013-07-17 08:28:34 -07:00
|
|
|
1, // CLIP provisioned.
|
|
|
|
1 // Length.
|
|
|
|
];
|
2014-02-17 03:35:13 -08:00
|
|
|
context.RIL[REQUEST_QUERY_CLIP](1, {
|
2013-07-17 08:28:34 -07:00
|
|
|
rilRequestError: ERROR_SUCCESS
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-17 03:35:13 -08:00
|
|
|
context.RIL.queryCLIP({});
|
2013-07-17 08:28:34 -07:00
|
|
|
|
|
|
|
let postedMessage = workerHelper.postedMessage;
|
|
|
|
|
|
|
|
do_check_eq(postedMessage.errorMsg, undefined);
|
|
|
|
do_check_true(postedMessage.success);
|
|
|
|
do_check_eq(postedMessage.provisioned, 1);
|
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
|
|
|
|
add_test(function test_getCLIP_error_generic_failure_invalid_length() {
|
|
|
|
let workerHelper = _getWorker();
|
|
|
|
let worker = workerHelper.worker;
|
2014-02-17 03:35:13 -08:00
|
|
|
let context = worker.ContextPool._contexts[0];
|
2013-07-17 08:28:34 -07:00
|
|
|
|
2014-02-17 03:35:13 -08:00
|
|
|
context.Buf.readInt32 = function fakeReadUint32() {
|
|
|
|
return context.Buf.int32Array.pop();
|
2013-07-17 08:28:34 -07:00
|
|
|
};
|
|
|
|
|
2014-02-17 03:35:13 -08:00
|
|
|
context.RIL.queryCLIP = function fakeQueryCLIP(options) {
|
|
|
|
context.Buf.int32Array = [
|
2013-07-17 08:28:34 -07:00
|
|
|
1, // CLIP provisioned.
|
|
|
|
0 // Length.
|
|
|
|
];
|
2014-02-17 03:35:13 -08:00
|
|
|
context.RIL[REQUEST_QUERY_CLIP](1, {
|
2013-07-17 08:28:34 -07:00
|
|
|
rilRequestError: ERROR_SUCCESS
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-17 03:35:13 -08:00
|
|
|
context.RIL.queryCLIP({});
|
2013-07-17 08:28:34 -07:00
|
|
|
|
|
|
|
let postedMessage = workerHelper.postedMessage;
|
|
|
|
|
|
|
|
do_check_eq(postedMessage.errorMsg, "GenericFailure");
|
|
|
|
do_check_false(postedMessage.success);
|
|
|
|
run_next_test();
|
|
|
|
});
|