|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this); |
|
5 |
|
6 function run_test() { |
|
7 run_next_test(); |
|
8 } |
|
9 |
|
10 function parseMMI(mmi) { |
|
11 let worker = newWorker({ |
|
12 postRILMessage: function(data) { |
|
13 // Do nothing |
|
14 }, |
|
15 postMessage: function(message) { |
|
16 // Do nothing |
|
17 } |
|
18 }); |
|
19 let context = worker.ContextPool._contexts[0]; |
|
20 return context.RIL._parseMMI(mmi); |
|
21 } |
|
22 |
|
23 function getWorker() { |
|
24 let _postedMessage; |
|
25 let _worker = newWorker({ |
|
26 postRILMessage: function(data) { |
|
27 }, |
|
28 postMessage: function(message) { |
|
29 _postedMessage = message; |
|
30 }, |
|
31 }); |
|
32 |
|
33 return { |
|
34 get postedMessage() { |
|
35 return _postedMessage; |
|
36 }, |
|
37 get worker() { |
|
38 return _worker; |
|
39 } |
|
40 }; |
|
41 } |
|
42 |
|
43 function testSendMMI(mmi, error) { |
|
44 let workerhelper = getWorker(); |
|
45 let worker = workerhelper.worker; |
|
46 let context = worker.ContextPool._contexts[0]; |
|
47 |
|
48 do_print("worker.postMessage " + worker.postMessage); |
|
49 |
|
50 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
51 context.RIL.sendMMI({rilMessageType: "sendMMI", mmi: mmi}); |
|
52 |
|
53 let postedMessage = workerhelper.postedMessage; |
|
54 |
|
55 do_check_eq(postedMessage.rilMessageType, "sendMMI"); |
|
56 do_check_eq(postedMessage.errorMsg, error); |
|
57 } |
|
58 |
|
59 add_test(function test_parseMMI_empty() { |
|
60 let mmi = parseMMI(""); |
|
61 |
|
62 do_check_null(mmi); |
|
63 |
|
64 run_next_test(); |
|
65 }); |
|
66 |
|
67 add_test(function test_parseMMI_undefined() { |
|
68 let mmi = parseMMI(); |
|
69 |
|
70 do_check_null(mmi); |
|
71 |
|
72 run_next_test(); |
|
73 }); |
|
74 |
|
75 add_test(function test_parseMMI_one_digit_short_code() { |
|
76 let mmi = parseMMI("1"); |
|
77 |
|
78 do_check_eq(mmi.fullMMI, "1"); |
|
79 do_check_eq(mmi.procedure, undefined); |
|
80 do_check_eq(mmi.serviceCode, undefined); |
|
81 do_check_eq(mmi.sia, undefined); |
|
82 do_check_eq(mmi.sib, undefined); |
|
83 do_check_eq(mmi.sic, undefined); |
|
84 do_check_eq(mmi.pwd, undefined); |
|
85 do_check_eq(mmi.dialNumber, undefined); |
|
86 |
|
87 run_next_test(); |
|
88 }); |
|
89 |
|
90 add_test(function test_parseMMI_invalid_short_code() { |
|
91 let mmi = parseMMI("11"); |
|
92 |
|
93 do_check_null(mmi); |
|
94 |
|
95 run_next_test(); |
|
96 }); |
|
97 |
|
98 add_test(function test_parseMMI_short_code() { |
|
99 let mmi = parseMMI("21"); |
|
100 |
|
101 do_check_eq(mmi.fullMMI, "21"); |
|
102 do_check_eq(mmi.procedure, undefined); |
|
103 do_check_eq(mmi.serviceCode, undefined); |
|
104 do_check_eq(mmi.sia, undefined); |
|
105 do_check_eq(mmi.sib, undefined); |
|
106 do_check_eq(mmi.sic, undefined); |
|
107 do_check_eq(mmi.pwd, undefined); |
|
108 do_check_eq(mmi.dialNumber, undefined); |
|
109 |
|
110 run_next_test(); |
|
111 }); |
|
112 |
|
113 add_test(function test_parseMMI_dial_string() { |
|
114 let mmi = parseMMI("12345"); |
|
115 |
|
116 do_check_null(mmi); |
|
117 |
|
118 run_next_test(); |
|
119 }); |
|
120 |
|
121 add_test(function test_parseMMI_USSD_without_asterisk_prefix() { |
|
122 let mmi = parseMMI("123#"); |
|
123 |
|
124 do_check_eq(mmi.fullMMI, "123#"); |
|
125 do_check_eq(mmi.procedure, undefined); |
|
126 do_check_eq(mmi.serviceCode, undefined); |
|
127 do_check_eq(mmi.sia, undefined); |
|
128 do_check_eq(mmi.sib, undefined); |
|
129 do_check_eq(mmi.sic, undefined); |
|
130 do_check_eq(mmi.pwd, undefined); |
|
131 do_check_eq(mmi.dialNumber, undefined); |
|
132 |
|
133 run_next_test(); |
|
134 }); |
|
135 |
|
136 add_test(function test_parseMMI_USSD() { |
|
137 let mmi = parseMMI("*123#"); |
|
138 |
|
139 do_check_eq(mmi.fullMMI, "*123#"); |
|
140 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
141 do_check_eq(mmi.serviceCode, "123"); |
|
142 do_check_eq(mmi.sia, undefined); |
|
143 do_check_eq(mmi.sib, undefined); |
|
144 do_check_eq(mmi.sic, undefined); |
|
145 do_check_eq(mmi.pwd, undefined); |
|
146 do_check_eq(mmi.dialNumber, ""); |
|
147 |
|
148 run_next_test(); |
|
149 }); |
|
150 |
|
151 add_test(function test_parseMMI_sia() { |
|
152 let mmi = parseMMI("*123*1#"); |
|
153 |
|
154 do_check_eq(mmi.fullMMI, "*123*1#"); |
|
155 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
156 do_check_eq(mmi.serviceCode, "123"); |
|
157 do_check_eq(mmi.sia, "1"); |
|
158 do_check_eq(mmi.sib, undefined); |
|
159 do_check_eq(mmi.sic, undefined); |
|
160 do_check_eq(mmi.pwd, undefined); |
|
161 do_check_eq(mmi.dialNumber, ""); |
|
162 |
|
163 run_next_test(); |
|
164 }); |
|
165 |
|
166 add_test(function test_parseMMI_sib() { |
|
167 let mmi = parseMMI("*123**1#"); |
|
168 |
|
169 do_check_eq(mmi.fullMMI, "*123**1#"); |
|
170 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
171 do_check_eq(mmi.serviceCode, "123"); |
|
172 do_check_eq(mmi.sia, ""); |
|
173 do_check_eq(mmi.sib, "1"); |
|
174 do_check_eq(mmi.sic, undefined); |
|
175 do_check_eq(mmi.pwd, undefined); |
|
176 do_check_eq(mmi.dialNumber, ""); |
|
177 |
|
178 run_next_test(); |
|
179 }); |
|
180 |
|
181 add_test(function test_parseMMI_sic() { |
|
182 let mmi = parseMMI("*123***1#"); |
|
183 |
|
184 do_check_eq(mmi.fullMMI, "*123***1#"); |
|
185 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
186 do_check_eq(mmi.serviceCode, "123"); |
|
187 do_check_eq(mmi.sia, ""); |
|
188 do_check_eq(mmi.sib, ""); |
|
189 do_check_eq(mmi.sic, "1"); |
|
190 do_check_eq(mmi.pwd, undefined); |
|
191 do_check_eq(mmi.dialNumber, ""); |
|
192 |
|
193 run_next_test(); |
|
194 }); |
|
195 |
|
196 add_test(function test_parseMMI_sia_sib() { |
|
197 let mmi = parseMMI("*123*1*1#"); |
|
198 |
|
199 do_check_eq(mmi.fullMMI, "*123*1*1#"); |
|
200 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
201 do_check_eq(mmi.serviceCode, "123"); |
|
202 do_check_eq(mmi.sia, "1"); |
|
203 do_check_eq(mmi.sib, "1"); |
|
204 do_check_eq(mmi.sic, undefined); |
|
205 do_check_eq(mmi.pwd, undefined); |
|
206 do_check_eq(mmi.dialNumber, ""); |
|
207 |
|
208 run_next_test(); |
|
209 }); |
|
210 |
|
211 add_test(function test_parseMMI_sia_sic() { |
|
212 let mmi = parseMMI("*123*1**1#"); |
|
213 |
|
214 do_check_eq(mmi.fullMMI, "*123*1**1#"); |
|
215 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
216 do_check_eq(mmi.serviceCode, "123"); |
|
217 do_check_eq(mmi.sia, "1"); |
|
218 do_check_eq(mmi.sib, ""); |
|
219 do_check_eq(mmi.sic, "1"); |
|
220 do_check_eq(mmi.pwd, undefined); |
|
221 do_check_eq(mmi.dialNumber, ""); |
|
222 |
|
223 run_next_test(); |
|
224 }); |
|
225 |
|
226 add_test(function test_parseMMI_sib_sic() { |
|
227 let mmi = parseMMI("*123**1*1#"); |
|
228 |
|
229 do_check_eq(mmi.fullMMI, "*123**1*1#"); |
|
230 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
231 do_check_eq(mmi.serviceCode, "123"); |
|
232 do_check_eq(mmi.sia, ""); |
|
233 do_check_eq(mmi.sib, "1"); |
|
234 do_check_eq(mmi.sic, "1"); |
|
235 do_check_eq(mmi.pwd, undefined); |
|
236 do_check_eq(mmi.dialNumber, ""); |
|
237 |
|
238 run_next_test(); |
|
239 }); |
|
240 |
|
241 add_test(function test_parseMMI_pwd() { |
|
242 let mmi = parseMMI("*123****1#"); |
|
243 |
|
244 do_check_eq(mmi.fullMMI, "*123****1#"); |
|
245 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
246 do_check_eq(mmi.serviceCode, "123"); |
|
247 do_check_eq(mmi.sia, ""); |
|
248 do_check_eq(mmi.sib, ""); |
|
249 do_check_eq(mmi.sic, ""); |
|
250 do_check_eq(mmi.pwd, "1"); |
|
251 do_check_eq(mmi.dialNumber, ""); |
|
252 |
|
253 run_next_test(); |
|
254 }); |
|
255 |
|
256 add_test(function test_parseMMI_dial_number() { |
|
257 let mmi = parseMMI("*123#345"); |
|
258 |
|
259 do_check_eq(mmi.fullMMI, "*123#"); |
|
260 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
261 do_check_eq(mmi.serviceCode, "123"); |
|
262 do_check_eq(mmi.sia, undefined); |
|
263 do_check_eq(mmi.sib, undefined); |
|
264 do_check_eq(mmi.sic, undefined); |
|
265 do_check_eq(mmi.pwd, undefined); |
|
266 do_check_eq(mmi.dialNumber, "345"); |
|
267 |
|
268 run_next_test(); |
|
269 }); |
|
270 |
|
271 |
|
272 /** |
|
273 * MMI procedures tests |
|
274 */ |
|
275 |
|
276 add_test(function test_parseMMI_activation() { |
|
277 let mmi = parseMMI("*00*12*34*56#"); |
|
278 |
|
279 do_check_eq(mmi.fullMMI, "*00*12*34*56#"); |
|
280 do_check_eq(mmi.procedure, MMI_PROCEDURE_ACTIVATION); |
|
281 do_check_eq(mmi.serviceCode, "00"); |
|
282 do_check_eq(mmi.sia, "12"); |
|
283 do_check_eq(mmi.sib, "34"); |
|
284 do_check_eq(mmi.sic, "56"); |
|
285 do_check_eq(mmi.pwd, undefined); |
|
286 do_check_eq(mmi.dialNumber, ""); |
|
287 |
|
288 run_next_test(); |
|
289 }); |
|
290 |
|
291 add_test(function test_parseMMI_deactivation() { |
|
292 let mmi = parseMMI("#00*12*34*56#"); |
|
293 |
|
294 do_check_eq(mmi.fullMMI, "#00*12*34*56#"); |
|
295 do_check_eq(mmi.procedure, MMI_PROCEDURE_DEACTIVATION); |
|
296 do_check_eq(mmi.serviceCode, "00"); |
|
297 do_check_eq(mmi.sia, "12"); |
|
298 do_check_eq(mmi.sib, "34"); |
|
299 do_check_eq(mmi.sic, "56"); |
|
300 do_check_eq(mmi.pwd, undefined); |
|
301 do_check_eq(mmi.dialNumber, ""); |
|
302 |
|
303 run_next_test(); |
|
304 }); |
|
305 |
|
306 add_test(function test_parseMMI_interrogation() { |
|
307 let mmi = parseMMI("*#00*12*34*56#"); |
|
308 |
|
309 do_check_eq(mmi.fullMMI, "*#00*12*34*56#"); |
|
310 do_check_eq(mmi.procedure, MMI_PROCEDURE_INTERROGATION); |
|
311 do_check_eq(mmi.serviceCode, "00"); |
|
312 do_check_eq(mmi.sia, "12"); |
|
313 do_check_eq(mmi.sib, "34"); |
|
314 do_check_eq(mmi.sic, "56"); |
|
315 do_check_eq(mmi.pwd, undefined); |
|
316 do_check_eq(mmi.dialNumber, ""); |
|
317 |
|
318 run_next_test(); |
|
319 }); |
|
320 |
|
321 add_test(function test_parseMMI_registration() { |
|
322 let mmi = parseMMI("**00*12*34*56#"); |
|
323 |
|
324 do_check_eq(mmi.fullMMI, "**00*12*34*56#"); |
|
325 do_check_eq(mmi.procedure, MMI_PROCEDURE_REGISTRATION); |
|
326 do_check_eq(mmi.serviceCode, "00"); |
|
327 do_check_eq(mmi.sia, "12"); |
|
328 do_check_eq(mmi.sib, "34"); |
|
329 do_check_eq(mmi.sic, "56"); |
|
330 do_check_eq(mmi.pwd, undefined); |
|
331 do_check_eq(mmi.dialNumber, ""); |
|
332 |
|
333 run_next_test(); |
|
334 }); |
|
335 |
|
336 add_test(function test_parseMMI_erasure() { |
|
337 let mmi = parseMMI("##00*12*34*56#"); |
|
338 |
|
339 do_check_eq(mmi.fullMMI, "##00*12*34*56#"); |
|
340 do_check_eq(mmi.procedure, MMI_PROCEDURE_ERASURE); |
|
341 do_check_eq(mmi.serviceCode, "00"); |
|
342 do_check_eq(mmi.sia, "12"); |
|
343 do_check_eq(mmi.sib, "34"); |
|
344 do_check_eq(mmi.sic, "56"); |
|
345 do_check_eq(mmi.pwd, undefined); |
|
346 do_check_eq(mmi.dialNumber, ""); |
|
347 |
|
348 run_next_test(); |
|
349 }); |
|
350 |
|
351 /** |
|
352 * sendMMI tests. |
|
353 */ |
|
354 |
|
355 add_test(function test_sendMMI_empty() { |
|
356 testSendMMI("", MMI_ERROR_KS_ERROR); |
|
357 |
|
358 run_next_test(); |
|
359 }); |
|
360 |
|
361 add_test(function test_sendMMI_undefined() { |
|
362 testSendMMI({}, MMI_ERROR_KS_ERROR); |
|
363 |
|
364 run_next_test(); |
|
365 }); |
|
366 |
|
367 add_test(function test_sendMMI_invalid() { |
|
368 testSendMMI("11", MMI_ERROR_KS_ERROR); |
|
369 |
|
370 run_next_test(); |
|
371 }); |
|
372 |
|
373 add_test(function test_sendMMI_short_code() { |
|
374 let workerhelper = getWorker(); |
|
375 let worker = workerhelper.worker; |
|
376 let context = worker.ContextPool._contexts[0]; |
|
377 |
|
378 let ussdOptions; |
|
379 |
|
380 context.RIL.sendUSSD = function fakeSendUSSD(options){ |
|
381 ussdOptions = options; |
|
382 context.RIL[REQUEST_SEND_USSD](0, { |
|
383 rilRequestError: ERROR_SUCCESS |
|
384 }); |
|
385 |
|
386 }; |
|
387 |
|
388 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
389 context.RIL.sendMMI({mmi: "**"}); |
|
390 |
|
391 let postedMessage = workerhelper.postedMessage; |
|
392 do_check_eq(ussdOptions.ussd, "**"); |
|
393 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
394 do_check_true(postedMessage.success); |
|
395 do_check_true(context.RIL._ussdSession); |
|
396 |
|
397 run_next_test(); |
|
398 }); |
|
399 |
|
400 add_test(function test_sendMMI_dial_string() { |
|
401 testSendMMI("123", MMI_ERROR_KS_ERROR); |
|
402 |
|
403 run_next_test(); |
|
404 }); |
|
405 |
|
406 function setCallForwardSuccess(mmi) { |
|
407 let workerhelper = getWorker(); |
|
408 let worker = workerhelper.worker; |
|
409 let context = worker.ContextPool._contexts[0]; |
|
410 |
|
411 context.RIL.setCallForward = function fakeSetCallForward(options) { |
|
412 context.RIL[REQUEST_SET_CALL_FORWARD](0, { |
|
413 rilRequestError: ERROR_SUCCESS |
|
414 }); |
|
415 }; |
|
416 |
|
417 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
418 context.RIL.sendMMI({mmi: mmi}); |
|
419 |
|
420 let postedMessage = workerhelper.postedMessage; |
|
421 |
|
422 do_check_eq(postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
423 do_check_true(postedMessage.success); |
|
424 } |
|
425 |
|
426 add_test(function test_sendMMI_call_forwarding_activation() { |
|
427 setCallForwardSuccess("*21*12345*99*10#"); |
|
428 |
|
429 run_next_test(); |
|
430 }); |
|
431 |
|
432 add_test(function test_sendMMI_call_forwarding_deactivation() { |
|
433 setCallForwardSuccess("#21*12345*99*10#"); |
|
434 |
|
435 run_next_test(); |
|
436 }); |
|
437 |
|
438 add_test(function test_sendMMI_call_forwarding_interrogation() { |
|
439 let workerhelper = getWorker(); |
|
440 let worker = workerhelper.worker; |
|
441 let context = worker.ContextPool._contexts[0]; |
|
442 |
|
443 context.Buf.readInt32 = function fakeReadUint32() { |
|
444 return context.Buf.int32Array.pop(); |
|
445 }; |
|
446 |
|
447 context.Buf.readString = function fakeReadString() { |
|
448 return "+34666222333"; |
|
449 }; |
|
450 |
|
451 context.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) { |
|
452 context.Buf.int32Array = [ |
|
453 0, // rules.timeSeconds |
|
454 145, // rules.toa |
|
455 49, // rules.serviceClass |
|
456 Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_UNCONDITIONAL, // rules.reason |
|
457 1, // rules.active |
|
458 1 // rulesLength |
|
459 ]; |
|
460 context.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, { |
|
461 rilRequestError: ERROR_SUCCESS |
|
462 }); |
|
463 }; |
|
464 |
|
465 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
466 context.RIL.sendMMI({mmi: "*#21#"}); |
|
467 |
|
468 let postedMessage = workerhelper.postedMessage; |
|
469 |
|
470 do_check_eq(postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
471 do_check_true(postedMessage.success); |
|
472 do_check_true(Array.isArray(postedMessage.rules)); |
|
473 do_check_eq(postedMessage.rules.length, 1); |
|
474 do_check_true(postedMessage.rules[0].active); |
|
475 do_check_eq(postedMessage.rules[0].reason, |
|
476 Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_UNCONDITIONAL); |
|
477 do_check_eq(postedMessage.rules[0].number, "+34666222333"); |
|
478 run_next_test(); |
|
479 }); |
|
480 |
|
481 add_test(function test_sendMMI_call_forwarding_interrogation_no_rules() { |
|
482 let workerhelper = getWorker(); |
|
483 let worker = workerhelper.worker; |
|
484 let context = worker.ContextPool._contexts[0]; |
|
485 |
|
486 context.Buf.readInt32 = function fakeReadUint32() { |
|
487 return 0; |
|
488 }; |
|
489 |
|
490 context.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) { |
|
491 context.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, { |
|
492 rilRequestError: ERROR_SUCCESS |
|
493 }); |
|
494 }; |
|
495 |
|
496 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
497 context.RIL.sendMMI({mmi: "*#21#"}); |
|
498 |
|
499 let postedMessage = workerhelper.postedMessage; |
|
500 |
|
501 do_check_eq(postedMessage.errorMsg, GECKO_ERROR_GENERIC_FAILURE); |
|
502 do_check_false(postedMessage.success); |
|
503 |
|
504 run_next_test(); |
|
505 }); |
|
506 |
|
507 |
|
508 add_test(function test_sendMMI_call_forwarding_registration() { |
|
509 setCallForwardSuccess("**21*12345*99*10#"); |
|
510 |
|
511 run_next_test(); |
|
512 }); |
|
513 |
|
514 add_test(function test_sendMMI_call_forwarding_erasure() { |
|
515 setCallForwardSuccess("##21*12345*99#"); |
|
516 |
|
517 run_next_test(); |
|
518 }); |
|
519 |
|
520 add_test(function test_sendMMI_call_forwarding_CFB() { |
|
521 setCallForwardSuccess("*67*12345*99*10#"); |
|
522 |
|
523 run_next_test(); |
|
524 }); |
|
525 |
|
526 add_test(function test_sendMMI_call_forwarding_CFNRy() { |
|
527 setCallForwardSuccess("*61*12345*99*10#"); |
|
528 |
|
529 run_next_test(); |
|
530 }); |
|
531 |
|
532 add_test(function test_sendMMI_call_forwarding_CFNRc() { |
|
533 setCallForwardSuccess("*62*12345*99*10#"); |
|
534 |
|
535 run_next_test(); |
|
536 }); |
|
537 |
|
538 add_test(function test_sendMMI_call_forwarding_CFAll() { |
|
539 setCallForwardSuccess("*004*12345*99*10#"); |
|
540 |
|
541 run_next_test(); |
|
542 }); |
|
543 |
|
544 add_test(function test_sendMMI_call_forwarding_CFAllConditional() { |
|
545 setCallForwardSuccess("*002*12345*99*10#"); |
|
546 |
|
547 run_next_test(); |
|
548 }); |
|
549 |
|
550 add_test(function test_sendMMI_change_PIN() { |
|
551 let workerhelper = getWorker(); |
|
552 let worker = workerhelper.worker; |
|
553 let context = worker.ContextPool._contexts[0]; |
|
554 |
|
555 context.RIL.changeICCPIN = function fakeChangeICCPIN(options) { |
|
556 context.RIL[REQUEST_ENTER_SIM_PIN](0, { |
|
557 rilRequestError: ERROR_SUCCESS |
|
558 }); |
|
559 }; |
|
560 |
|
561 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
562 context.RIL.sendMMI({mmi: "**04*1234*4567*4567#"}); |
|
563 |
|
564 let postedMessage = workerhelper.postedMessage; |
|
565 |
|
566 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
567 do_check_true(postedMessage.success); |
|
568 |
|
569 run_next_test(); |
|
570 }); |
|
571 |
|
572 add_test(function test_sendMMI_change_PIN_no_new_PIN() { |
|
573 testSendMMI("**04*1234**4567#", MMI_ERROR_KS_ERROR); |
|
574 |
|
575 run_next_test(); |
|
576 }); |
|
577 |
|
578 add_test(function test_sendMMI_change_PIN_no_old_PIN() { |
|
579 testSendMMI("**04**1234*4567#", MMI_ERROR_KS_ERROR); |
|
580 |
|
581 run_next_test(); |
|
582 }); |
|
583 |
|
584 add_test(function test_sendMMI_change_PIN_wrong_procedure() { |
|
585 testSendMMI("*04*1234*4567*4567#", MMI_ERROR_KS_INVALID_ACTION); |
|
586 |
|
587 run_next_test(); |
|
588 }); |
|
589 |
|
590 add_test(function test_sendMMI_change_PIN_new_PIN_mismatch() { |
|
591 testSendMMI("**04*4567*1234*4567#", MMI_ERROR_KS_MISMATCH_PIN); |
|
592 |
|
593 run_next_test(); |
|
594 }); |
|
595 |
|
596 add_test(function test_sendMMI_change_PIN2() { |
|
597 let workerhelper = getWorker(); |
|
598 let worker = workerhelper.worker; |
|
599 let context = worker.ContextPool._contexts[0]; |
|
600 |
|
601 context.RIL.changeICCPIN2 = function fakeChangeICCPIN2(options){ |
|
602 context.RIL[REQUEST_ENTER_SIM_PIN2](0, { |
|
603 rilRequestError: ERROR_SUCCESS |
|
604 }); |
|
605 }; |
|
606 |
|
607 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
608 context.RIL.sendMMI({mmi: "**042*1234*4567*4567#"}); |
|
609 |
|
610 let postedMessage = workerhelper.postedMessage; |
|
611 |
|
612 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
613 do_check_true(postedMessage.success); |
|
614 |
|
615 run_next_test(); |
|
616 }); |
|
617 |
|
618 add_test(function test_sendMMI_change_PIN2_no_new_PIN2() { |
|
619 testSendMMI("**042*1234**4567#", MMI_ERROR_KS_ERROR); |
|
620 |
|
621 run_next_test(); |
|
622 }); |
|
623 |
|
624 add_test(function test_sendMMI_change_PIN2_no_old_PIN2() { |
|
625 testSendMMI("**042**1234*4567#", MMI_ERROR_KS_ERROR); |
|
626 |
|
627 run_next_test(); |
|
628 }); |
|
629 |
|
630 add_test(function test_sendMMI_change_PIN2_wrong_procedure() { |
|
631 testSendMMI("*042*1234*4567*4567#", MMI_ERROR_KS_INVALID_ACTION); |
|
632 |
|
633 run_next_test(); |
|
634 }); |
|
635 |
|
636 add_test(function test_sendMMI_change_PIN2_new_PIN2_mismatch() { |
|
637 testSendMMI("**042*4567*1234*4567#", MMI_ERROR_KS_MISMATCH_PIN); |
|
638 |
|
639 run_next_test(); |
|
640 }); |
|
641 |
|
642 add_test(function test_sendMMI_unblock_PIN() { |
|
643 let workerhelper = getWorker(); |
|
644 let worker = workerhelper.worker; |
|
645 let context = worker.ContextPool._contexts[0]; |
|
646 |
|
647 context.RIL.enterICCPUK = function fakeEnterICCPUK(options){ |
|
648 context.RIL[REQUEST_ENTER_SIM_PUK](0, { |
|
649 rilRequestError: ERROR_SUCCESS |
|
650 }); |
|
651 }; |
|
652 |
|
653 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
654 context.RIL.sendMMI({mmi: "**05*1234*4567*4567#"}); |
|
655 |
|
656 let postedMessage = workerhelper.postedMessage; |
|
657 |
|
658 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
659 do_check_true(postedMessage.success); |
|
660 |
|
661 run_next_test(); |
|
662 }); |
|
663 |
|
664 add_test(function test_sendMMI_unblock_PIN_no_new_PIN() { |
|
665 testSendMMI("**05*1234**4567#", MMI_ERROR_KS_ERROR); |
|
666 |
|
667 run_next_test(); |
|
668 }); |
|
669 |
|
670 add_test(function test_sendMMI_unblock_PIN_no_PUK() { |
|
671 testSendMMI("**05**1234*4567#", MMI_ERROR_KS_ERROR); |
|
672 |
|
673 run_next_test(); |
|
674 }); |
|
675 |
|
676 add_test(function test_sendMMI_unblock_PIN_wrong_procedure() { |
|
677 testSendMMI("*05*1234*4567*4567#", MMI_ERROR_KS_INVALID_ACTION); |
|
678 |
|
679 run_next_test(); |
|
680 }); |
|
681 |
|
682 add_test(function test_sendMMI_unblock_PIN_new_PIN_mismatch() { |
|
683 testSendMMI("**05*4567*1234*4567#", MMI_ERROR_KS_MISMATCH_PIN); |
|
684 |
|
685 run_next_test(); |
|
686 }); |
|
687 |
|
688 add_test(function test_sendMMI_unblock_PIN2() { |
|
689 let workerhelper = getWorker(); |
|
690 let worker = workerhelper.worker; |
|
691 let context = worker.ContextPool._contexts[0]; |
|
692 |
|
693 context.RIL.enterICCPUK2 = function fakeEnterICCPUK2(options){ |
|
694 context.RIL[REQUEST_ENTER_SIM_PUK2](0, { |
|
695 rilRequestError: ERROR_SUCCESS |
|
696 }); |
|
697 }; |
|
698 |
|
699 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
700 context.RIL.sendMMI({mmi: "**052*1234*4567*4567#"}); |
|
701 |
|
702 let postedMessage = workerhelper.postedMessage; |
|
703 |
|
704 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
705 do_check_true(postedMessage.success); |
|
706 |
|
707 run_next_test(); |
|
708 }); |
|
709 |
|
710 add_test(function test_sendMMI_unblock_PIN2_no_new_PIN2() { |
|
711 testSendMMI("**052*1234**4567#", MMI_ERROR_KS_ERROR); |
|
712 |
|
713 run_next_test(); |
|
714 }); |
|
715 |
|
716 add_test(function test_sendMMI_unblock_PIN2_no_PUK2() { |
|
717 testSendMMI("**052**1234*4567#", MMI_ERROR_KS_ERROR); |
|
718 |
|
719 run_next_test(); |
|
720 }); |
|
721 |
|
722 add_test(function test_sendMMI_unblock_PIN2_wrong_procedure() { |
|
723 testSendMMI("*052*1234*4567*4567#", MMI_ERROR_KS_INVALID_ACTION); |
|
724 |
|
725 run_next_test(); |
|
726 }); |
|
727 |
|
728 add_test(function test_sendMMI_unblock_PIN2_new_PIN_mismatch() { |
|
729 testSendMMI("**052*4567*1234*4567#", MMI_ERROR_KS_MISMATCH_PIN); |
|
730 |
|
731 run_next_test(); |
|
732 }); |
|
733 |
|
734 add_test(function test_sendMMI_get_IMEI() { |
|
735 let workerhelper = getWorker(); |
|
736 let worker = workerhelper.worker; |
|
737 let context = worker.ContextPool._contexts[0]; |
|
738 let mmiOptions; |
|
739 |
|
740 context.RIL.getIMEI = function getIMEI(options){ |
|
741 mmiOptions = options; |
|
742 context.RIL[REQUEST_SEND_USSD](0, { |
|
743 rilRequestError: ERROR_SUCCESS, |
|
744 }); |
|
745 }; |
|
746 |
|
747 context.RIL.sendMMI({mmi: "*#06#"}); |
|
748 |
|
749 let postedMessage = workerhelper.postedMessage; |
|
750 |
|
751 do_check_neq(mmiOptions.mmi, null); |
|
752 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
753 do_check_true(postedMessage.success); |
|
754 |
|
755 run_next_test(); |
|
756 }); |
|
757 |
|
758 add_test(function test_sendMMI_get_IMEI_error() { |
|
759 let workerhelper = getWorker(); |
|
760 let worker = workerhelper.worker; |
|
761 let context = worker.ContextPool._contexts[0]; |
|
762 let mmiOptions; |
|
763 |
|
764 context.RIL.getIMEI = function getIMEI(options){ |
|
765 mmiOptions = options; |
|
766 context.RIL[REQUEST_SEND_USSD](0, { |
|
767 rilRequestError: ERROR_RADIO_NOT_AVAILABLE, |
|
768 }); |
|
769 }; |
|
770 |
|
771 context.RIL.sendMMI({mmi: "*#06#"}); |
|
772 |
|
773 let postedMessage = workerhelper.postedMessage; |
|
774 |
|
775 do_check_neq(mmiOptions.mmi, null); |
|
776 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_RADIO_NOT_AVAILABLE); |
|
777 do_check_false(postedMessage.success); |
|
778 |
|
779 run_next_test(); |
|
780 }); |
|
781 |
|
782 add_test(function test_sendMMI_call_barring_BAIC_interrogation_voice() { |
|
783 let workerhelper = getWorker(); |
|
784 let worker = workerhelper.worker; |
|
785 let context = worker.ContextPool._contexts[0]; |
|
786 |
|
787 context.Buf.readInt32List = function fakeReadUint32List() { |
|
788 return [1]; |
|
789 }; |
|
790 |
|
791 context.RIL.queryICCFacilityLock = |
|
792 function fakeQueryICCFacilityLock(options){ |
|
793 context.RIL[REQUEST_QUERY_FACILITY_LOCK](1, { |
|
794 rilMessageType: "sendMMI", |
|
795 rilRequestError: ERROR_SUCCESS |
|
796 }); |
|
797 }; |
|
798 |
|
799 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
800 context.RIL.sendMMI({mmi: "*#33#"}); |
|
801 |
|
802 let postedMessage = workerhelper.postedMessage; |
|
803 |
|
804 do_check_true(postedMessage.success); |
|
805 do_check_true(postedMessage.enabled); |
|
806 do_check_eq(postedMessage.statusMessage, MMI_SM_KS_SERVICE_ENABLED_FOR); |
|
807 do_check_true(Array.isArray(postedMessage.additionalInformation)); |
|
808 do_check_eq(postedMessage.additionalInformation[0], "serviceClassVoice"); |
|
809 |
|
810 run_next_test(); |
|
811 }); |
|
812 |
|
813 add_test(function test_sendMMI_call_barring_BAIC_activation() { |
|
814 let workerhelper = getWorker(); |
|
815 let worker = workerhelper.worker; |
|
816 let context = worker.ContextPool._contexts[0]; |
|
817 let mmiOptions; |
|
818 |
|
819 context.RIL.setICCFacilityLock = |
|
820 function fakeSetICCFacilityLock(options){ |
|
821 mmiOptions = options; |
|
822 context.RIL[REQUEST_SET_FACILITY_LOCK](0, { |
|
823 rilMessageType: "sendMMI", |
|
824 procedure: MMI_PROCEDURE_ACTIVATION, |
|
825 rilRequestError: ERROR_SUCCESS |
|
826 }); |
|
827 }; |
|
828 |
|
829 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
830 context.RIL.sendMMI({mmi: "*33#"}); |
|
831 |
|
832 let postedMessage = workerhelper.postedMessage; |
|
833 |
|
834 do_check_eq(mmiOptions.procedure, MMI_PROCEDURE_ACTIVATION); |
|
835 do_check_true(postedMessage.success); |
|
836 do_check_eq(postedMessage.statusMessage, MMI_SM_KS_SERVICE_ENABLED); |
|
837 |
|
838 run_next_test(); |
|
839 }); |
|
840 |
|
841 add_test(function test_sendMMI_call_barring_BAIC_deactivation() { |
|
842 let workerhelper = getWorker(); |
|
843 let worker = workerhelper.worker; |
|
844 let context = worker.ContextPool._contexts[0]; |
|
845 let mmiOptions; |
|
846 |
|
847 context.RIL.setICCFacilityLock = |
|
848 function fakeSetICCFacilityLock(options){ |
|
849 mmiOptions = options; |
|
850 context.RIL[REQUEST_SET_FACILITY_LOCK](0, { |
|
851 rilMessageType: "sendMMI", |
|
852 procedure: MMI_PROCEDURE_DEACTIVATION, |
|
853 rilRequestError: ERROR_SUCCESS |
|
854 }); |
|
855 }; |
|
856 |
|
857 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
858 context.RIL.sendMMI({mmi: "#33#"}); |
|
859 |
|
860 let postedMessage = workerhelper.postedMessage; |
|
861 |
|
862 do_check_eq(mmiOptions.procedure, MMI_PROCEDURE_DEACTIVATION); |
|
863 do_check_true(postedMessage.success); |
|
864 do_check_eq(postedMessage.statusMessage, MMI_SM_KS_SERVICE_DISABLED); |
|
865 |
|
866 run_next_test(); |
|
867 }); |
|
868 |
|
869 add_test(function test_sendMMI_call_barring_BAIC_procedure_not_supported() { |
|
870 testSendMMI("**33*0000#", MMI_ERROR_KS_NOT_SUPPORTED); |
|
871 |
|
872 run_next_test(); |
|
873 }); |
|
874 |
|
875 add_test(function test_sendMMI_USSD() { |
|
876 let workerhelper = getWorker(); |
|
877 let worker = workerhelper.worker; |
|
878 let context = worker.ContextPool._contexts[0]; |
|
879 let ussdOptions; |
|
880 |
|
881 context.RIL.sendUSSD = function fakeSendUSSD(options){ |
|
882 ussdOptions = options; |
|
883 context.RIL[REQUEST_SEND_USSD](0, { |
|
884 rilRequestError: ERROR_SUCCESS |
|
885 }); |
|
886 }; |
|
887 |
|
888 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
889 context.RIL.sendMMI({mmi: "*123#"}); |
|
890 |
|
891 let postedMessage = workerhelper.postedMessage; |
|
892 |
|
893 do_check_eq(ussdOptions.ussd, "*123#"); |
|
894 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
895 do_check_true(postedMessage.success); |
|
896 do_check_true(context.RIL._ussdSession); |
|
897 |
|
898 run_next_test(); |
|
899 }); |
|
900 |
|
901 add_test(function test_sendMMI_USSD_error() { |
|
902 let workerhelper = getWorker(); |
|
903 let worker = workerhelper.worker; |
|
904 let context = worker.ContextPool._contexts[0]; |
|
905 let ussdOptions; |
|
906 |
|
907 context.RIL.sendUSSD = function fakeSendUSSD(options){ |
|
908 ussdOptions = options; |
|
909 context.RIL[REQUEST_SEND_USSD](0, { |
|
910 rilRequestError: ERROR_GENERIC_FAILURE |
|
911 }); |
|
912 }; |
|
913 |
|
914 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
915 context.RIL.sendMMI({mmi: "*123#"}); |
|
916 |
|
917 let postedMessage = workerhelper.postedMessage; |
|
918 |
|
919 do_check_eq(ussdOptions.ussd, "*123#"); |
|
920 do_check_eq (postedMessage.errorMsg, GECKO_ERROR_GENERIC_FAILURE); |
|
921 do_check_false(postedMessage.success); |
|
922 do_check_false(context.RIL._ussdSession); |
|
923 |
|
924 run_next_test(); |
|
925 }); |
|
926 |
|
927 function setCallWaitingSuccess(mmi) { |
|
928 let workerhelper = getWorker(); |
|
929 let worker = workerhelper.worker; |
|
930 let context = worker.ContextPool._contexts[0]; |
|
931 |
|
932 context.RIL.setCallWaiting = function fakeSetCallWaiting(options) { |
|
933 context.RIL[REQUEST_SET_CALL_WAITING](0, { |
|
934 rilRequestError: ERROR_SUCCESS |
|
935 }); |
|
936 }; |
|
937 |
|
938 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
939 context.RIL.sendMMI({mmi: mmi}); |
|
940 |
|
941 let postedMessage = workerhelper.postedMessage; |
|
942 |
|
943 do_check_eq(postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
944 do_check_true(postedMessage.success); |
|
945 } |
|
946 |
|
947 add_test(function test_sendMMI_call_waiting_activation() { |
|
948 setCallWaitingSuccess("*43*10#"); |
|
949 |
|
950 run_next_test(); |
|
951 }); |
|
952 |
|
953 add_test(function test_sendMMI_call_waiting_deactivation() { |
|
954 setCallWaitingSuccess("#43#"); |
|
955 |
|
956 run_next_test(); |
|
957 }); |
|
958 |
|
959 add_test(function test_sendMMI_call_waiting_registration() { |
|
960 testSendMMI("**43#", MMI_ERROR_KS_NOT_SUPPORTED); |
|
961 |
|
962 run_next_test(); |
|
963 }); |
|
964 |
|
965 add_test(function test_sendMMI_call_waiting_erasure() { |
|
966 testSendMMI("##43#", MMI_ERROR_KS_NOT_SUPPORTED); |
|
967 |
|
968 run_next_test(); |
|
969 }); |
|
970 |
|
971 add_test(function test_sendMMI_call_waiting_interrogation() { |
|
972 let workerhelper = getWorker(); |
|
973 let worker = workerhelper.worker; |
|
974 let context = worker.ContextPool._contexts[0]; |
|
975 |
|
976 context.Buf.readInt32 = function fakeReadUint32() { |
|
977 return context.Buf.int32Array.pop(); |
|
978 }; |
|
979 |
|
980 context.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) { |
|
981 context.Buf.int32Array = [ |
|
982 7, // serviceClass |
|
983 1, // enabled |
|
984 2 // length |
|
985 ]; |
|
986 context.RIL[REQUEST_QUERY_CALL_WAITING](1, { |
|
987 rilRequestError: ERROR_SUCCESS |
|
988 }); |
|
989 }; |
|
990 |
|
991 context.RIL.radioState = GECKO_RADIOSTATE_READY; |
|
992 context.RIL.sendMMI({mmi: "*#43#"}); |
|
993 |
|
994 let postedMessage = workerhelper.postedMessage; |
|
995 |
|
996 do_check_eq(postedMessage.errorMsg, GECKO_ERROR_SUCCESS); |
|
997 do_check_true(postedMessage.success); |
|
998 do_check_eq(postedMessage.length, 2); |
|
999 do_check_true(postedMessage.enabled); |
|
1000 run_next_test(); |
|
1001 }); |