dom/system/gonk/tests/test_ril_worker_ssn.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_notification() {
    30   let workerHelper = _getWorker();
    31   let worker = workerHelper.worker;
    32   let context = worker.ContextPool._contexts[0];
    34   function Call(callIndex, number) {
    35     this.callIndex = callIndex;
    36     this.number = number;
    37   }
    39   Call.prototype = {
    40     // Should use CALL_STATE_ACTIVE.
    41     // Any new outgoing call (state = dialing or alerting) will be drop if there
    42     // is no pending outgoing call created before.
    43     state: CALL_STATE_ACTIVE,
    44     //callIndex: 0,
    45     toa: 0,
    46     isMpty: false,
    47     isMT: false,
    48     als: 0,
    49     isVoice: true,
    50     isVoicePrivacy: false,
    51     //number: null,
    52     numberPresentation: 0,
    53     name: null,
    54     namePresentation: 0,
    55     uusInfo: null
    56   };
    58   let oneCall = {
    59     0: new Call(0, '00000')
    60   };
    62   let twoCalls = {
    63     0: new Call(0, '00000'),
    64     1: new Call(1, '11111')
    65   };
    67   function testNotification(calls, code, number, resultNotification,
    68                             resultCallIndex) {
    70     let testInfo = {calls: calls, code: code, number: number,
    71                     resultNotification: resultNotification,
    72                     resultCallIndex: resultCallIndex};
    73     do_print('Test case info: ' + JSON.stringify(testInfo));
    75     // Set current calls.
    76     context.RIL._processCalls(calls);
    78     let notificationInfo = {
    79       notificationType: 1,  // MT
    80       code: code,
    81       index: 0,
    82       type: 0,
    83       number: number
    84     };
    86     context.RIL._processSuppSvcNotification(notificationInfo);
    88     let postedMessage = workerHelper.postedMessage;
    89     do_check_eq(postedMessage.rilMessageType, 'suppSvcNotification');
    90     do_check_eq(postedMessage.notification, resultNotification);
    91     do_check_eq(postedMessage.callIndex, resultCallIndex);
    93     // Clear all existed calls.
    94     context.RIL._processCalls(null);
    95   }
    97   testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null,
    98                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 0);
   100   testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED, null,
   101                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED, 0);
   103   testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null,
   104                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, -1);
   106   testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED, null,
   107                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED, -1);
   109   testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '00000',
   110                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 0);
   112   testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '11111',
   113                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 1);
   115   testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '22222',
   116                    GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, -1);
   118   run_next_test();
   119 });

mercurial