Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this); |
michael@0 | 5 | |
michael@0 | 6 | function run_test() { |
michael@0 | 7 | run_next_test(); |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | function _getWorker() { |
michael@0 | 11 | let _postedMessage; |
michael@0 | 12 | let _worker = newWorker({ |
michael@0 | 13 | postRILMessage: function(data) { |
michael@0 | 14 | }, |
michael@0 | 15 | postMessage: function(message) { |
michael@0 | 16 | _postedMessage = message; |
michael@0 | 17 | } |
michael@0 | 18 | }); |
michael@0 | 19 | return { |
michael@0 | 20 | get postedMessage() { |
michael@0 | 21 | return _postedMessage; |
michael@0 | 22 | }, |
michael@0 | 23 | get worker() { |
michael@0 | 24 | return _worker; |
michael@0 | 25 | } |
michael@0 | 26 | }; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | add_test(function test_notification() { |
michael@0 | 30 | let workerHelper = _getWorker(); |
michael@0 | 31 | let worker = workerHelper.worker; |
michael@0 | 32 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 33 | |
michael@0 | 34 | function Call(callIndex, number) { |
michael@0 | 35 | this.callIndex = callIndex; |
michael@0 | 36 | this.number = number; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | Call.prototype = { |
michael@0 | 40 | // Should use CALL_STATE_ACTIVE. |
michael@0 | 41 | // Any new outgoing call (state = dialing or alerting) will be drop if there |
michael@0 | 42 | // is no pending outgoing call created before. |
michael@0 | 43 | state: CALL_STATE_ACTIVE, |
michael@0 | 44 | //callIndex: 0, |
michael@0 | 45 | toa: 0, |
michael@0 | 46 | isMpty: false, |
michael@0 | 47 | isMT: false, |
michael@0 | 48 | als: 0, |
michael@0 | 49 | isVoice: true, |
michael@0 | 50 | isVoicePrivacy: false, |
michael@0 | 51 | //number: null, |
michael@0 | 52 | numberPresentation: 0, |
michael@0 | 53 | name: null, |
michael@0 | 54 | namePresentation: 0, |
michael@0 | 55 | uusInfo: null |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | let oneCall = { |
michael@0 | 59 | 0: new Call(0, '00000') |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | let twoCalls = { |
michael@0 | 63 | 0: new Call(0, '00000'), |
michael@0 | 64 | 1: new Call(1, '11111') |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | function testNotification(calls, code, number, resultNotification, |
michael@0 | 68 | resultCallIndex) { |
michael@0 | 69 | |
michael@0 | 70 | let testInfo = {calls: calls, code: code, number: number, |
michael@0 | 71 | resultNotification: resultNotification, |
michael@0 | 72 | resultCallIndex: resultCallIndex}; |
michael@0 | 73 | do_print('Test case info: ' + JSON.stringify(testInfo)); |
michael@0 | 74 | |
michael@0 | 75 | // Set current calls. |
michael@0 | 76 | context.RIL._processCalls(calls); |
michael@0 | 77 | |
michael@0 | 78 | let notificationInfo = { |
michael@0 | 79 | notificationType: 1, // MT |
michael@0 | 80 | code: code, |
michael@0 | 81 | index: 0, |
michael@0 | 82 | type: 0, |
michael@0 | 83 | number: number |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | context.RIL._processSuppSvcNotification(notificationInfo); |
michael@0 | 87 | |
michael@0 | 88 | let postedMessage = workerHelper.postedMessage; |
michael@0 | 89 | do_check_eq(postedMessage.rilMessageType, 'suppSvcNotification'); |
michael@0 | 90 | do_check_eq(postedMessage.notification, resultNotification); |
michael@0 | 91 | do_check_eq(postedMessage.callIndex, resultCallIndex); |
michael@0 | 92 | |
michael@0 | 93 | // Clear all existed calls. |
michael@0 | 94 | context.RIL._processCalls(null); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null, |
michael@0 | 98 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 0); |
michael@0 | 99 | |
michael@0 | 100 | testNotification(oneCall, SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED, null, |
michael@0 | 101 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED, 0); |
michael@0 | 102 | |
michael@0 | 103 | testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, null, |
michael@0 | 104 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, -1); |
michael@0 | 105 | |
michael@0 | 106 | testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED, null, |
michael@0 | 107 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED, -1); |
michael@0 | 108 | |
michael@0 | 109 | testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '00000', |
michael@0 | 110 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 0); |
michael@0 | 111 | |
michael@0 | 112 | testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '11111', |
michael@0 | 113 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, 1); |
michael@0 | 114 | |
michael@0 | 115 | testNotification(twoCalls, SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD, '22222', |
michael@0 | 116 | GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD, -1); |
michael@0 | 117 | |
michael@0 | 118 | run_next_test(); |
michael@0 | 119 | }); |