dom/system/gonk/tests/test_ril_worker_clip.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this);
     6 function run_test() {
     7   run_next_test();
     8 }
    10 function _getWorker() {
    11   let _postedMessage;
    12   let _worker = newWorker({
    13     postRILMessage: function(data) {
    14     },
    15     postMessage: function(message) {
    16       _postedMessage = message;
    17     }
    18   });
    19   return {
    20     get postedMessage() {
    21       return _postedMessage;
    22     },
    23     get worker() {
    24       return _worker;
    25     }
    26   };
    27 }
    29 add_test(function test_queryCLIP_provisioned() {
    30   let workerHelper = _getWorker();
    31   let worker = workerHelper.worker;
    32   let context = worker.ContextPool._contexts[0];
    34   context.Buf.readInt32 = function fakeReadUint32() {
    35     return context.Buf.int32Array.pop();
    36   };
    38   context.RIL.queryCLIP = function fakeQueryCLIP(options) {
    39     context.Buf.int32Array = [
    40       1,  // CLIP provisioned.
    41       1   // Length.
    42     ];
    43     context.RIL[REQUEST_QUERY_CLIP](1, {
    44       rilRequestError: ERROR_SUCCESS
    45     });
    46   };
    48   context.RIL.queryCLIP({});
    50   let postedMessage = workerHelper.postedMessage;
    52   do_check_eq(postedMessage.errorMsg, undefined);
    53   do_check_true(postedMessage.success);
    54   do_check_eq(postedMessage.provisioned, 1);
    55   run_next_test();
    56 });
    58 add_test(function test_getCLIP_error_generic_failure_invalid_length() {
    59   let workerHelper = _getWorker();
    60   let worker = workerHelper.worker;
    61   let context = worker.ContextPool._contexts[0];
    63   context.Buf.readInt32 = function fakeReadUint32() {
    64     return context.Buf.int32Array.pop();
    65   };
    67   context.RIL.queryCLIP = function fakeQueryCLIP(options) {
    68     context.Buf.int32Array = [
    69       1,  // CLIP provisioned.
    70       0   // Length.
    71     ];
    72     context.RIL[REQUEST_QUERY_CLIP](1, {
    73       rilRequestError: ERROR_SUCCESS
    74     });
    75   };
    77   context.RIL.queryCLIP({});
    79   let postedMessage = workerHelper.postedMessage;
    81   do_check_eq(postedMessage.errorMsg, "GenericFailure");
    82   do_check_false(postedMessage.success);
    83   run_next_test();
    84 });

mercurial