michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this); michael@0: michael@0: function run_test() { michael@0: run_next_test(); michael@0: } michael@0: michael@0: function _getWorker() { michael@0: let _postedMessage; michael@0: let _worker = newWorker({ michael@0: postRILMessage: function(data) { michael@0: }, michael@0: postMessage: function(message) { michael@0: _postedMessage = message; michael@0: } michael@0: }); michael@0: return { michael@0: get postedMessage() { michael@0: return _postedMessage; michael@0: }, michael@0: get worker() { michael@0: return _worker; michael@0: } michael@0: }; michael@0: } michael@0: michael@0: add_test(function test_notification() { michael@0: let workerHelper = _getWorker(); michael@0: let worker = workerHelper.worker; michael@0: let context = worker.ContextPool._contexts[0]; michael@0: michael@0: function Call(callIndex, number) { michael@0: this.callIndex = callIndex; michael@0: this.number = number; michael@0: } michael@0: michael@0: Call.prototype = { michael@0: // Should use CALL_STATE_ACTIVE. michael@0: // Any new outgoing call (state = dialing or alerting) will be drop if there michael@0: // is no pending outgoing call created before. michael@0: state: CALL_STATE_ACTIVE, michael@0: //callIndex: 0, michael@0: toa: 0, michael@0: isMpty: false, michael@0: isMT: false, michael@0: als: 0, michael@0: isVoice: true, michael@0: isVoicePrivacy: false, michael@0: //number: null, michael@0: numberPresentation: 0, michael@0: name: null, michael@0: namePresentation: 0, michael@0: uusInfo: null michael@0: }; michael@0: michael@0: let oneCall = { michael@0: 0: new Call(0, '00000') michael@0: }; michael@0: michael@0: let twoCalls = { michael@0: 0: new Call(0, '00000'), michael@0: 1: new Call(1, '11111') michael@0: }; michael@0: michael@0: function testNotification(calls, code, number, resultNotification, michael@0: resultCallIndex) { michael@0: michael@0: let testInfo = {calls: calls, code: code, number: number, michael@0: resultNotification: resultNotification, michael@0: resultCallIndex: resultCallIndex}; michael@0: do_print('Test case info: ' + JSON.stringify(testInfo)); michael@0: michael@0: // Set current calls. michael@0: context.RIL._processCalls(calls); michael@0: michael@0: let notificationInfo = { michael@0: notificationType: 1, // MT michael@0: code: code, michael@0: index: 0, michael@0: type: 0, michael@0: number: number michael@0: }; michael@0: michael@0: context.RIL._processSuppSvcNotification(notificationInfo); michael@0: michael@0: let postedMessage = workerHelper.postedMessage; michael@0: do_check_eq(postedMessage.rilMessageType, 'suppSvcNotification'); michael@0: do_check_eq(postedMessage.notification, resultNotification); michael@0: do_check_eq(postedMessage.callIndex, resultCallIndex); michael@0: michael@0: // Clear all existed calls. michael@0: context.RIL._processCalls(null); michael@0: } michael@0: michael@0: testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null, michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 0); michael@0: michael@0: testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED, null, michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED, 0); michael@0: michael@0: testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null, michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, -1); michael@0: michael@0: testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED, null, michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED, -1); michael@0: michael@0: testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '00000', michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 0); michael@0: michael@0: testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '11111', michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 1); michael@0: michael@0: testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '22222', michael@0: GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, -1); michael@0: michael@0: run_next_test(); michael@0: });