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