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 | /** |
michael@0 | 11 | * Helper function. |
michael@0 | 12 | */ |
michael@0 | 13 | function newUint8Worker() { |
michael@0 | 14 | let worker = newWorker(); |
michael@0 | 15 | let index = 0; // index for read |
michael@0 | 16 | let buf = []; |
michael@0 | 17 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 18 | |
michael@0 | 19 | context.Buf.writeUint8 = function(value) { |
michael@0 | 20 | buf.push(value); |
michael@0 | 21 | }; |
michael@0 | 22 | |
michael@0 | 23 | context.Buf.readUint8 = function() { |
michael@0 | 24 | return buf[index++]; |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | context.Buf.seekIncoming = function(offset) { |
michael@0 | 28 | index += offset; |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | worker.debug = do_print; |
michael@0 | 32 | |
michael@0 | 33 | return worker; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function newUint8SupportOutgoingIndexWorker() { |
michael@0 | 37 | let worker = newWorker(); |
michael@0 | 38 | let index = 4; // index for read |
michael@0 | 39 | let buf = [0, 0, 0, 0]; // Preserved parcel size |
michael@0 | 40 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 41 | |
michael@0 | 42 | context.Buf.writeUint8 = function(value) { |
michael@0 | 43 | if (context.Buf.outgoingIndex >= buf.length) { |
michael@0 | 44 | buf.push(value); |
michael@0 | 45 | } else { |
michael@0 | 46 | buf[context.Buf.outgoingIndex] = value; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | context.Buf.outgoingIndex++; |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | context.Buf.readUint8 = function() { |
michael@0 | 53 | return buf[index++]; |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | context.Buf.seekIncoming = function(offset) { |
michael@0 | 57 | index += offset; |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | worker.debug = do_print; |
michael@0 | 61 | |
michael@0 | 62 | return worker; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | // Test RIL requests related to STK. |
michael@0 | 66 | /** |
michael@0 | 67 | * Verify if RIL.sendStkTerminalProfile be called. |
michael@0 | 68 | */ |
michael@0 | 69 | add_test(function test_if_send_stk_terminal_profile() { |
michael@0 | 70 | let worker = newUint8Worker(); |
michael@0 | 71 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 72 | let profileSend = false; |
michael@0 | 73 | context.RIL.sendStkTerminalProfile = function(data) { |
michael@0 | 74 | profileSend = true; |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | let iccStatus = { |
michael@0 | 78 | gsmUmtsSubscriptionAppIndex: 0, |
michael@0 | 79 | apps: [{ |
michael@0 | 80 | app_state: CARD_APPSTATE_READY, |
michael@0 | 81 | app_type: CARD_APPTYPE_USIM |
michael@0 | 82 | }], |
michael@0 | 83 | }; |
michael@0 | 84 | worker.RILQUIRKS_SEND_STK_PROFILE_DOWNLOAD = false; |
michael@0 | 85 | |
michael@0 | 86 | context.RIL._processICCStatus(iccStatus); |
michael@0 | 87 | |
michael@0 | 88 | do_check_eq(profileSend, false); |
michael@0 | 89 | |
michael@0 | 90 | run_next_test(); |
michael@0 | 91 | }); |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * Verify RIL.sendStkTerminalProfile |
michael@0 | 95 | */ |
michael@0 | 96 | add_test(function test_send_stk_terminal_profile() { |
michael@0 | 97 | let worker = newUint8Worker(); |
michael@0 | 98 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 99 | let ril = context.RIL; |
michael@0 | 100 | let buf = context.Buf; |
michael@0 | 101 | |
michael@0 | 102 | ril.sendStkTerminalProfile(STK_SUPPORTED_TERMINAL_PROFILE); |
michael@0 | 103 | |
michael@0 | 104 | buf.seekIncoming(8); |
michael@0 | 105 | let profile = buf.readString(); |
michael@0 | 106 | for (let i = 0; i < STK_SUPPORTED_TERMINAL_PROFILE.length; i++) { |
michael@0 | 107 | do_check_eq(parseInt(profile.substring(2 * i, 2 * i + 2), 16), |
michael@0 | 108 | STK_SUPPORTED_TERMINAL_PROFILE[i]); |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | run_next_test(); |
michael@0 | 112 | }); |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Verify STK terminal response |
michael@0 | 116 | */ |
michael@0 | 117 | add_test(function test_stk_terminal_response() { |
michael@0 | 118 | let worker = newUint8SupportOutgoingIndexWorker(); |
michael@0 | 119 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 120 | let buf = context.Buf; |
michael@0 | 121 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 122 | |
michael@0 | 123 | buf.sendParcel = function() { |
michael@0 | 124 | // Type |
michael@0 | 125 | do_check_eq(this.readInt32(), REQUEST_STK_SEND_TERMINAL_RESPONSE); |
michael@0 | 126 | |
michael@0 | 127 | // Token : we don't care |
michael@0 | 128 | this.readInt32(); |
michael@0 | 129 | |
michael@0 | 130 | // Data Size, 44 = 2 * (TLV_COMMAND_DETAILS_SIZE(5) + |
michael@0 | 131 | // TLV_DEVICE_ID_SIZE(4) + |
michael@0 | 132 | // TLV_RESULT_SIZE(3) + |
michael@0 | 133 | // TEXT LENGTH(10)) |
michael@0 | 134 | do_check_eq(this.readInt32(), 44); |
michael@0 | 135 | |
michael@0 | 136 | // Command Details, Type-Length-Value |
michael@0 | 137 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_COMMAND_DETAILS | |
michael@0 | 138 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 139 | do_check_eq(pduHelper.readHexOctet(), 3); |
michael@0 | 140 | do_check_eq(pduHelper.readHexOctet(), 0x01); |
michael@0 | 141 | do_check_eq(pduHelper.readHexOctet(), STK_CMD_PROVIDE_LOCAL_INFO); |
michael@0 | 142 | do_check_eq(pduHelper.readHexOctet(), STK_LOCAL_INFO_NNA); |
michael@0 | 143 | |
michael@0 | 144 | // Device Identifies, Type-Length-Value(Source ID-Destination ID) |
michael@0 | 145 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID); |
michael@0 | 146 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 147 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME); |
michael@0 | 148 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM); |
michael@0 | 149 | |
michael@0 | 150 | // Result |
michael@0 | 151 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_RESULT | |
michael@0 | 152 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 153 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 154 | do_check_eq(pduHelper.readHexOctet(), STK_RESULT_OK); |
michael@0 | 155 | |
michael@0 | 156 | // Text |
michael@0 | 157 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_TEXT_STRING | |
michael@0 | 158 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 159 | do_check_eq(pduHelper.readHexOctet(), 8); |
michael@0 | 160 | do_check_eq(pduHelper.readHexOctet(), STK_TEXT_CODING_GSM_7BIT_PACKED); |
michael@0 | 161 | do_check_eq(pduHelper.readSeptetsToString(7, 0, PDU_NL_IDENTIFIER_DEFAULT, |
michael@0 | 162 | PDU_NL_IDENTIFIER_DEFAULT), "Mozilla"); |
michael@0 | 163 | |
michael@0 | 164 | run_next_test(); |
michael@0 | 165 | }; |
michael@0 | 166 | |
michael@0 | 167 | let response = { |
michael@0 | 168 | command: { |
michael@0 | 169 | commandNumber: 0x01, |
michael@0 | 170 | typeOfCommand: STK_CMD_PROVIDE_LOCAL_INFO, |
michael@0 | 171 | commandQualifier: STK_LOCAL_INFO_NNA, |
michael@0 | 172 | options: { |
michael@0 | 173 | isPacked: true |
michael@0 | 174 | } |
michael@0 | 175 | }, |
michael@0 | 176 | input: "Mozilla", |
michael@0 | 177 | resultCode: STK_RESULT_OK |
michael@0 | 178 | }; |
michael@0 | 179 | context.RIL.sendStkTerminalResponse(response); |
michael@0 | 180 | }); |
michael@0 | 181 | |
michael@0 | 182 | // Test ComprehensionTlvHelper |
michael@0 | 183 | |
michael@0 | 184 | /** |
michael@0 | 185 | * Verify ComprehensionTlvHelper.writeLocationInfoTlv |
michael@0 | 186 | */ |
michael@0 | 187 | add_test(function test_write_location_info_tlv() { |
michael@0 | 188 | let worker = newUint8Worker(); |
michael@0 | 189 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 190 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 191 | let tlvHelper = context.ComprehensionTlvHelper; |
michael@0 | 192 | |
michael@0 | 193 | // Test with 2-digit mnc, and gsmCellId obtained from UMTS network. |
michael@0 | 194 | let loc = { |
michael@0 | 195 | mcc: "466", |
michael@0 | 196 | mnc: "92", |
michael@0 | 197 | gsmLocationAreaCode : 10291, |
michael@0 | 198 | gsmCellId: 19072823 |
michael@0 | 199 | }; |
michael@0 | 200 | tlvHelper.writeLocationInfoTlv(loc); |
michael@0 | 201 | |
michael@0 | 202 | let tag = pduHelper.readHexOctet(); |
michael@0 | 203 | do_check_eq(tag, COMPREHENSIONTLV_TAG_LOCATION_INFO | |
michael@0 | 204 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 205 | |
michael@0 | 206 | let length = pduHelper.readHexOctet(); |
michael@0 | 207 | do_check_eq(length, 9); |
michael@0 | 208 | |
michael@0 | 209 | let mcc_mnc = pduHelper.readSwappedNibbleBcdString(3); |
michael@0 | 210 | do_check_eq(mcc_mnc, "46692"); |
michael@0 | 211 | |
michael@0 | 212 | let lac = (pduHelper.readHexOctet() << 8) | pduHelper.readHexOctet(); |
michael@0 | 213 | do_check_eq(lac, 10291); |
michael@0 | 214 | |
michael@0 | 215 | let cellId = (pduHelper.readHexOctet() << 24) | |
michael@0 | 216 | (pduHelper.readHexOctet() << 16) | |
michael@0 | 217 | (pduHelper.readHexOctet() << 8) | |
michael@0 | 218 | (pduHelper.readHexOctet()); |
michael@0 | 219 | do_check_eq(cellId, 19072823); |
michael@0 | 220 | |
michael@0 | 221 | // Test with 1-digit mnc, and gsmCellId obtained from GSM network. |
michael@0 | 222 | loc = { |
michael@0 | 223 | mcc: "466", |
michael@0 | 224 | mnc: "02", |
michael@0 | 225 | gsmLocationAreaCode : 10291, |
michael@0 | 226 | gsmCellId: 65534 |
michael@0 | 227 | }; |
michael@0 | 228 | tlvHelper.writeLocationInfoTlv(loc); |
michael@0 | 229 | |
michael@0 | 230 | tag = pduHelper.readHexOctet(); |
michael@0 | 231 | do_check_eq(tag, COMPREHENSIONTLV_TAG_LOCATION_INFO | |
michael@0 | 232 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 233 | |
michael@0 | 234 | length = pduHelper.readHexOctet(); |
michael@0 | 235 | do_check_eq(length, 7); |
michael@0 | 236 | |
michael@0 | 237 | mcc_mnc = pduHelper.readSwappedNibbleBcdString(3); |
michael@0 | 238 | do_check_eq(mcc_mnc, "46602"); |
michael@0 | 239 | |
michael@0 | 240 | lac = (pduHelper.readHexOctet() << 8) | pduHelper.readHexOctet(); |
michael@0 | 241 | do_check_eq(lac, 10291); |
michael@0 | 242 | |
michael@0 | 243 | cellId = (pduHelper.readHexOctet() << 8) | (pduHelper.readHexOctet()); |
michael@0 | 244 | do_check_eq(cellId, 65534); |
michael@0 | 245 | |
michael@0 | 246 | // Test with 3-digit mnc, and gsmCellId obtained from GSM network. |
michael@0 | 247 | loc = { |
michael@0 | 248 | mcc: "466", |
michael@0 | 249 | mnc: "222", |
michael@0 | 250 | gsmLocationAreaCode : 10291, |
michael@0 | 251 | gsmCellId: 65534 |
michael@0 | 252 | }; |
michael@0 | 253 | tlvHelper.writeLocationInfoTlv(loc); |
michael@0 | 254 | |
michael@0 | 255 | tag = pduHelper.readHexOctet(); |
michael@0 | 256 | do_check_eq(tag, COMPREHENSIONTLV_TAG_LOCATION_INFO | |
michael@0 | 257 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 258 | |
michael@0 | 259 | length = pduHelper.readHexOctet(); |
michael@0 | 260 | do_check_eq(length, 7); |
michael@0 | 261 | |
michael@0 | 262 | mcc_mnc = pduHelper.readSwappedNibbleBcdString(3); |
michael@0 | 263 | do_check_eq(mcc_mnc, "466222"); |
michael@0 | 264 | |
michael@0 | 265 | lac = (pduHelper.readHexOctet() << 8) | pduHelper.readHexOctet(); |
michael@0 | 266 | do_check_eq(lac, 10291); |
michael@0 | 267 | |
michael@0 | 268 | cellId = (pduHelper.readHexOctet() << 8) | (pduHelper.readHexOctet()); |
michael@0 | 269 | do_check_eq(cellId, 65534); |
michael@0 | 270 | |
michael@0 | 271 | run_next_test(); |
michael@0 | 272 | }); |
michael@0 | 273 | |
michael@0 | 274 | /** |
michael@0 | 275 | * Verify ComprehensionTlvHelper.writeErrorNumber |
michael@0 | 276 | */ |
michael@0 | 277 | add_test(function test_write_disconnecting_cause() { |
michael@0 | 278 | let worker = newUint8Worker(); |
michael@0 | 279 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 280 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 281 | let tlvHelper = context.ComprehensionTlvHelper; |
michael@0 | 282 | |
michael@0 | 283 | tlvHelper.writeCauseTlv(RIL_ERROR_TO_GECKO_ERROR[ERROR_GENERIC_FAILURE]); |
michael@0 | 284 | let tag = pduHelper.readHexOctet(); |
michael@0 | 285 | do_check_eq(tag, COMPREHENSIONTLV_TAG_CAUSE | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 286 | let len = pduHelper.readHexOctet(); |
michael@0 | 287 | do_check_eq(len, 2); // We have one cause. |
michael@0 | 288 | let standard = pduHelper.readHexOctet(); |
michael@0 | 289 | do_check_eq(standard, 0x60); |
michael@0 | 290 | let cause = pduHelper.readHexOctet(); |
michael@0 | 291 | do_check_eq(cause, 0x80 | ERROR_GENERIC_FAILURE); |
michael@0 | 292 | |
michael@0 | 293 | run_next_test(); |
michael@0 | 294 | }); |
michael@0 | 295 | |
michael@0 | 296 | /** |
michael@0 | 297 | * Verify ComprehensionTlvHelper.getSizeOfLengthOctets |
michael@0 | 298 | */ |
michael@0 | 299 | add_test(function test_get_size_of_length_octets() { |
michael@0 | 300 | let worker = newUint8Worker(); |
michael@0 | 301 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 302 | let tlvHelper = context.ComprehensionTlvHelper; |
michael@0 | 303 | |
michael@0 | 304 | let length = 0x70; |
michael@0 | 305 | do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 1); |
michael@0 | 306 | |
michael@0 | 307 | length = 0x80; |
michael@0 | 308 | do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 2); |
michael@0 | 309 | |
michael@0 | 310 | length = 0x180; |
michael@0 | 311 | do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 3); |
michael@0 | 312 | |
michael@0 | 313 | length = 0x18000; |
michael@0 | 314 | do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 4); |
michael@0 | 315 | |
michael@0 | 316 | run_next_test(); |
michael@0 | 317 | }); |
michael@0 | 318 | |
michael@0 | 319 | /** |
michael@0 | 320 | * Verify ComprehensionTlvHelper.writeLength |
michael@0 | 321 | */ |
michael@0 | 322 | add_test(function test_write_length() { |
michael@0 | 323 | let worker = newUint8Worker(); |
michael@0 | 324 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 325 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 326 | let tlvHelper = context.ComprehensionTlvHelper; |
michael@0 | 327 | |
michael@0 | 328 | let length = 0x70; |
michael@0 | 329 | tlvHelper.writeLength(length); |
michael@0 | 330 | do_check_eq(pduHelper.readHexOctet(), length); |
michael@0 | 331 | |
michael@0 | 332 | length = 0x80; |
michael@0 | 333 | tlvHelper.writeLength(length); |
michael@0 | 334 | do_check_eq(pduHelper.readHexOctet(), 0x81); |
michael@0 | 335 | do_check_eq(pduHelper.readHexOctet(), length); |
michael@0 | 336 | |
michael@0 | 337 | length = 0x180; |
michael@0 | 338 | tlvHelper.writeLength(length); |
michael@0 | 339 | do_check_eq(pduHelper.readHexOctet(), 0x82); |
michael@0 | 340 | do_check_eq(pduHelper.readHexOctet(), (length >> 8) & 0xff); |
michael@0 | 341 | do_check_eq(pduHelper.readHexOctet(), length & 0xff); |
michael@0 | 342 | |
michael@0 | 343 | length = 0x18000; |
michael@0 | 344 | tlvHelper.writeLength(length); |
michael@0 | 345 | do_check_eq(pduHelper.readHexOctet(), 0x83); |
michael@0 | 346 | do_check_eq(pduHelper.readHexOctet(), (length >> 16) & 0xff); |
michael@0 | 347 | do_check_eq(pduHelper.readHexOctet(), (length >> 8) & 0xff); |
michael@0 | 348 | do_check_eq(pduHelper.readHexOctet(), length & 0xff); |
michael@0 | 349 | |
michael@0 | 350 | run_next_test(); |
michael@0 | 351 | }); |
michael@0 | 352 | |
michael@0 | 353 | // Test Proactive commands. |
michael@0 | 354 | /** |
michael@0 | 355 | * Verify Proactive command helper : searchForNextTag |
michael@0 | 356 | */ |
michael@0 | 357 | add_test(function test_stk_proactive_command_search_next_tag() { |
michael@0 | 358 | let worker = newUint8Worker(); |
michael@0 | 359 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 360 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 361 | let berHelper = context.BerTlvHelper; |
michael@0 | 362 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 363 | |
michael@0 | 364 | let tag_test = [ |
michael@0 | 365 | 0xD0, |
michael@0 | 366 | 0x3C, |
michael@0 | 367 | 0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x31, |
michael@0 | 368 | 0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x32, |
michael@0 | 369 | 0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x33, |
michael@0 | 370 | 0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x34, |
michael@0 | 371 | 0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x35]; |
michael@0 | 372 | |
michael@0 | 373 | for (let i = 0; i < tag_test.length; i++) { |
michael@0 | 374 | pduHelper.writeHexOctet(tag_test[i]); |
michael@0 | 375 | } |
michael@0 | 376 | |
michael@0 | 377 | let berTlv = berHelper.decode(tag_test.length); |
michael@0 | 378 | let iter = Iterator(berTlv.value); |
michael@0 | 379 | let tlv = stkHelper.searchForNextTag(COMPREHENSIONTLV_TAG_ALPHA_ID, iter); |
michael@0 | 380 | do_check_eq(tlv.value.identifier, "alpha id 1"); |
michael@0 | 381 | |
michael@0 | 382 | tlv = stkHelper.searchForNextTag(COMPREHENSIONTLV_TAG_ALPHA_ID, iter); |
michael@0 | 383 | do_check_eq(tlv.value.identifier, "alpha id 2"); |
michael@0 | 384 | |
michael@0 | 385 | tlv = stkHelper.searchForNextTag(COMPREHENSIONTLV_TAG_ALPHA_ID, iter); |
michael@0 | 386 | do_check_eq(tlv.value.identifier, "alpha id 3"); |
michael@0 | 387 | |
michael@0 | 388 | tlv = stkHelper.searchForNextTag(COMPREHENSIONTLV_TAG_ALPHA_ID, iter); |
michael@0 | 389 | do_check_eq(tlv.value.identifier, "alpha id 4"); |
michael@0 | 390 | |
michael@0 | 391 | tlv = stkHelper.searchForNextTag(COMPREHENSIONTLV_TAG_ALPHA_ID, iter); |
michael@0 | 392 | do_check_eq(tlv.value.identifier, "alpha id 5"); |
michael@0 | 393 | |
michael@0 | 394 | run_next_test(); |
michael@0 | 395 | }); |
michael@0 | 396 | |
michael@0 | 397 | /** |
michael@0 | 398 | * Verify Proactive Command : Refresh |
michael@0 | 399 | */ |
michael@0 | 400 | add_test(function test_stk_proactive_command_refresh() { |
michael@0 | 401 | let worker = newUint8Worker(); |
michael@0 | 402 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 403 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 404 | let berHelper = context.BerTlvHelper; |
michael@0 | 405 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 406 | |
michael@0 | 407 | let refresh_1 = [ |
michael@0 | 408 | 0xD0, |
michael@0 | 409 | 0x10, |
michael@0 | 410 | 0x81, 0x03, 0x01, 0x01, 0x01, |
michael@0 | 411 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 412 | 0x92, 0x05, 0x01, 0x3F, 0x00, 0x2F, 0xE2]; |
michael@0 | 413 | |
michael@0 | 414 | for (let i = 0; i < refresh_1.length; i++) { |
michael@0 | 415 | pduHelper.writeHexOctet(refresh_1[i]); |
michael@0 | 416 | } |
michael@0 | 417 | |
michael@0 | 418 | let berTlv = berHelper.decode(refresh_1.length); |
michael@0 | 419 | let ctlvs = berTlv.value; |
michael@0 | 420 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 421 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 422 | do_check_eq(tlv.value.typeOfCommand, 0x01); |
michael@0 | 423 | do_check_eq(tlv.value.commandQualifier, 0x01); |
michael@0 | 424 | |
michael@0 | 425 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_FILE_LIST, ctlvs); |
michael@0 | 426 | do_check_eq(tlv.value.fileList, "3F002FE2"); |
michael@0 | 427 | |
michael@0 | 428 | run_next_test(); |
michael@0 | 429 | }); |
michael@0 | 430 | |
michael@0 | 431 | /** |
michael@0 | 432 | * Verify Proactive Command : Play Tone |
michael@0 | 433 | */ |
michael@0 | 434 | add_test(function test_stk_proactive_command_play_tone() { |
michael@0 | 435 | let worker = newUint8Worker(); |
michael@0 | 436 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 437 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 438 | let berHelper = context.BerTlvHelper; |
michael@0 | 439 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 440 | |
michael@0 | 441 | let tone_1 = [ |
michael@0 | 442 | 0xD0, |
michael@0 | 443 | 0x1B, |
michael@0 | 444 | 0x81, 0x03, 0x01, 0x20, 0x00, |
michael@0 | 445 | 0x82, 0x02, 0x81, 0x03, |
michael@0 | 446 | 0x85, 0x09, 0x44, 0x69, 0x61, 0x6C, 0x20, 0x54, 0x6F, 0x6E, 0x65, |
michael@0 | 447 | 0x8E, 0x01, 0x01, |
michael@0 | 448 | 0x84, 0x02, 0x01, 0x05]; |
michael@0 | 449 | |
michael@0 | 450 | for (let i = 0; i < tone_1.length; i++) { |
michael@0 | 451 | pduHelper.writeHexOctet(tone_1[i]); |
michael@0 | 452 | } |
michael@0 | 453 | |
michael@0 | 454 | let berTlv = berHelper.decode(tone_1.length); |
michael@0 | 455 | let ctlvs = berTlv.value; |
michael@0 | 456 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 457 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 458 | do_check_eq(tlv.value.typeOfCommand, 0x20); |
michael@0 | 459 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 460 | |
michael@0 | 461 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs); |
michael@0 | 462 | do_check_eq(tlv.value.identifier, "Dial Tone"); |
michael@0 | 463 | |
michael@0 | 464 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_TONE, ctlvs); |
michael@0 | 465 | do_check_eq(tlv.value.tone, STK_TONE_TYPE_DIAL_TONE); |
michael@0 | 466 | |
michael@0 | 467 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_DURATION, ctlvs); |
michael@0 | 468 | do_check_eq(tlv.value.timeUnit, STK_TIME_UNIT_SECOND); |
michael@0 | 469 | do_check_eq(tlv.value.timeInterval, 5); |
michael@0 | 470 | |
michael@0 | 471 | run_next_test(); |
michael@0 | 472 | }); |
michael@0 | 473 | |
michael@0 | 474 | /** |
michael@0 | 475 | * Verify Proactive Command : Poll Interval |
michael@0 | 476 | */ |
michael@0 | 477 | add_test(function test_stk_proactive_command_poll_interval() { |
michael@0 | 478 | let worker = newUint8Worker(); |
michael@0 | 479 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 480 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 481 | let berHelper = context.BerTlvHelper; |
michael@0 | 482 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 483 | |
michael@0 | 484 | let poll_1 = [ |
michael@0 | 485 | 0xD0, |
michael@0 | 486 | 0x0D, |
michael@0 | 487 | 0x81, 0x03, 0x01, 0x03, 0x00, |
michael@0 | 488 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 489 | 0x84, 0x02, 0x01, 0x14]; |
michael@0 | 490 | |
michael@0 | 491 | for (let i = 0; i < poll_1.length; i++) { |
michael@0 | 492 | pduHelper.writeHexOctet(poll_1[i]); |
michael@0 | 493 | } |
michael@0 | 494 | |
michael@0 | 495 | let berTlv = berHelper.decode(poll_1.length); |
michael@0 | 496 | let ctlvs = berTlv.value; |
michael@0 | 497 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 498 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 499 | do_check_eq(tlv.value.typeOfCommand, 0x03); |
michael@0 | 500 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 501 | |
michael@0 | 502 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_DURATION, ctlvs); |
michael@0 | 503 | do_check_eq(tlv.value.timeUnit, STK_TIME_UNIT_SECOND); |
michael@0 | 504 | do_check_eq(tlv.value.timeInterval, 0x14); |
michael@0 | 505 | |
michael@0 | 506 | run_next_test(); |
michael@0 | 507 | }); |
michael@0 | 508 | |
michael@0 | 509 | /** |
michael@0 | 510 | * Verify Proactive Command: Display Text |
michael@0 | 511 | */ |
michael@0 | 512 | add_test(function test_read_septets_to_string() { |
michael@0 | 513 | let worker = newUint8Worker(); |
michael@0 | 514 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 515 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 516 | let berHelper = context.BerTlvHelper; |
michael@0 | 517 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 518 | |
michael@0 | 519 | let display_text_1 = [ |
michael@0 | 520 | 0xd0, |
michael@0 | 521 | 0x28, |
michael@0 | 522 | 0x81, 0x03, 0x01, 0x21, 0x80, |
michael@0 | 523 | 0x82, 0x02, 0x81, 0x02, |
michael@0 | 524 | 0x0d, 0x1d, 0x00, 0xd3, 0x30, 0x9b, 0xfc, 0x06, 0xc9, 0x5c, 0x30, 0x1a, |
michael@0 | 525 | 0xa8, 0xe8, 0x02, 0x59, 0xc3, 0xec, 0x34, 0xb9, 0xac, 0x07, 0xc9, 0x60, |
michael@0 | 526 | 0x2f, 0x58, 0xed, 0x15, 0x9b, 0xb9, 0x40, |
michael@0 | 527 | ]; |
michael@0 | 528 | |
michael@0 | 529 | for (let i = 0; i < display_text_1.length; i++) { |
michael@0 | 530 | pduHelper.writeHexOctet(display_text_1[i]); |
michael@0 | 531 | } |
michael@0 | 532 | |
michael@0 | 533 | let berTlv = berHelper.decode(display_text_1.length); |
michael@0 | 534 | let ctlvs = berTlv.value; |
michael@0 | 535 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_TEXT_STRING, ctlvs); |
michael@0 | 536 | do_check_eq(tlv.value.textString, "Saldo 2.04 E. Validez 20/05/13. "); |
michael@0 | 537 | |
michael@0 | 538 | run_next_test(); |
michael@0 | 539 | }); |
michael@0 | 540 | |
michael@0 | 541 | /** |
michael@0 | 542 | * Verify Proactive Command: Set Up Event List. |
michael@0 | 543 | */ |
michael@0 | 544 | add_test(function test_stk_proactive_command_event_list() { |
michael@0 | 545 | let worker = newUint8Worker(); |
michael@0 | 546 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 547 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 548 | let berHelper = context.BerTlvHelper; |
michael@0 | 549 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 550 | |
michael@0 | 551 | let event_1 = [ |
michael@0 | 552 | 0xD0, |
michael@0 | 553 | 0x0F, |
michael@0 | 554 | 0x81, 0x03, 0x01, 0x05, 0x00, |
michael@0 | 555 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 556 | 0x99, 0x04, 0x00, 0x01, 0x02, 0x03]; |
michael@0 | 557 | |
michael@0 | 558 | for (let i = 0; i < event_1.length; i++) { |
michael@0 | 559 | pduHelper.writeHexOctet(event_1[i]); |
michael@0 | 560 | } |
michael@0 | 561 | |
michael@0 | 562 | let berTlv = berHelper.decode(event_1.length); |
michael@0 | 563 | let ctlvs = berTlv.value; |
michael@0 | 564 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 565 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 566 | do_check_eq(tlv.value.typeOfCommand, 0x05); |
michael@0 | 567 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 568 | |
michael@0 | 569 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_EVENT_LIST, ctlvs); |
michael@0 | 570 | do_check_eq(Array.isArray(tlv.value.eventList), true); |
michael@0 | 571 | for (let i = 0; i < tlv.value.eventList.length; i++) { |
michael@0 | 572 | do_check_eq(tlv.value.eventList[i], i); |
michael@0 | 573 | } |
michael@0 | 574 | |
michael@0 | 575 | run_next_test(); |
michael@0 | 576 | }); |
michael@0 | 577 | |
michael@0 | 578 | /** |
michael@0 | 579 | * Verify Proactive Command : Get Input |
michael@0 | 580 | */ |
michael@0 | 581 | add_test(function test_stk_proactive_command_get_input() { |
michael@0 | 582 | let worker = newUint8Worker(); |
michael@0 | 583 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 584 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 585 | let berHelper = context.BerTlvHelper; |
michael@0 | 586 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 587 | let stkCmdHelper = context.StkCommandParamsFactory; |
michael@0 | 588 | |
michael@0 | 589 | let get_input_1 = [ |
michael@0 | 590 | 0xD0, |
michael@0 | 591 | 0x1E, |
michael@0 | 592 | 0x81, 0x03, 0x01, 0x23, 0x8F, |
michael@0 | 593 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 594 | 0x8D, 0x05, 0x04, 0x54, 0x65, 0x78, 0x74, |
michael@0 | 595 | 0x91, 0x02, 0x01, 0x10, |
michael@0 | 596 | 0x17, 0x08, 0x04, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74]; |
michael@0 | 597 | |
michael@0 | 598 | for (let i = 0; i < get_input_1.length; i++) { |
michael@0 | 599 | pduHelper.writeHexOctet(get_input_1[i]); |
michael@0 | 600 | } |
michael@0 | 601 | |
michael@0 | 602 | let berTlv = berHelper.decode(get_input_1.length); |
michael@0 | 603 | let ctlvs = berTlv.value; |
michael@0 | 604 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 605 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 606 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_GET_INPUT); |
michael@0 | 607 | |
michael@0 | 608 | let input = stkCmdHelper.createParam(tlv.value, ctlvs); |
michael@0 | 609 | do_check_eq(input.text, "Text"); |
michael@0 | 610 | do_check_eq(input.isAlphabet, true); |
michael@0 | 611 | do_check_eq(input.isUCS2, true); |
michael@0 | 612 | do_check_eq(input.hideInput, true); |
michael@0 | 613 | do_check_eq(input.isPacked, true); |
michael@0 | 614 | do_check_eq(input.isHelpAvailable, true); |
michael@0 | 615 | do_check_eq(input.minLength, 0x01); |
michael@0 | 616 | do_check_eq(input.maxLength, 0x10); |
michael@0 | 617 | do_check_eq(input.defaultText, "Default"); |
michael@0 | 618 | |
michael@0 | 619 | let get_input_2 = [ |
michael@0 | 620 | 0xD0, |
michael@0 | 621 | 0x11, |
michael@0 | 622 | 0x81, 0x03, 0x01, 0x23, 0x00, |
michael@0 | 623 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 624 | 0x8D, 0x00, |
michael@0 | 625 | 0x91, 0x02, 0x01, 0x10, |
michael@0 | 626 | 0x17, 0x00]; |
michael@0 | 627 | |
michael@0 | 628 | for (let i = 0; i < get_input_2.length; i++) { |
michael@0 | 629 | pduHelper.writeHexOctet(get_input_2[i]); |
michael@0 | 630 | } |
michael@0 | 631 | |
michael@0 | 632 | berTlv = berHelper.decode(get_input_2.length); |
michael@0 | 633 | ctlvs = berTlv.value; |
michael@0 | 634 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 635 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 636 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_GET_INPUT); |
michael@0 | 637 | |
michael@0 | 638 | input = stkCmdHelper.createParam(tlv.value, ctlvs); |
michael@0 | 639 | do_check_eq(input.text, null); |
michael@0 | 640 | do_check_eq(input.minLength, 0x01); |
michael@0 | 641 | do_check_eq(input.maxLength, 0x10); |
michael@0 | 642 | do_check_eq(input.defaultText, null); |
michael@0 | 643 | |
michael@0 | 644 | run_next_test(); |
michael@0 | 645 | }); |
michael@0 | 646 | |
michael@0 | 647 | /** |
michael@0 | 648 | * Verify Proactive Command : More Time |
michael@0 | 649 | */ |
michael@0 | 650 | add_test(function test_stk_proactive_command_more_time() { |
michael@0 | 651 | let worker = newUint8Worker(); |
michael@0 | 652 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 653 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 654 | let berHelper = context.BerTlvHelper; |
michael@0 | 655 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 656 | |
michael@0 | 657 | let more_time_1 = [ |
michael@0 | 658 | 0xD0, |
michael@0 | 659 | 0x09, |
michael@0 | 660 | 0x81, 0x03, 0x01, 0x02, 0x00, |
michael@0 | 661 | 0x82, 0x02, 0x81, 0x82]; |
michael@0 | 662 | |
michael@0 | 663 | for(let i = 0 ; i < more_time_1.length; i++) { |
michael@0 | 664 | pduHelper.writeHexOctet(more_time_1[i]); |
michael@0 | 665 | } |
michael@0 | 666 | |
michael@0 | 667 | let berTlv = berHelper.decode(more_time_1.length); |
michael@0 | 668 | let ctlvs = berTlv.value; |
michael@0 | 669 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 670 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 671 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_MORE_TIME); |
michael@0 | 672 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 673 | |
michael@0 | 674 | run_next_test(); |
michael@0 | 675 | }); |
michael@0 | 676 | |
michael@0 | 677 | /** |
michael@0 | 678 | * Verify Proactive Command : Select Item |
michael@0 | 679 | */ |
michael@0 | 680 | add_test(function test_stk_proactive_command_select_item() { |
michael@0 | 681 | let worker = newUint8Worker(); |
michael@0 | 682 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 683 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 684 | let berHelper = context.BerTlvHelper; |
michael@0 | 685 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 686 | let stkFactory = context.StkCommandParamsFactory; |
michael@0 | 687 | |
michael@0 | 688 | let select_item_1 = [ |
michael@0 | 689 | 0xD0, |
michael@0 | 690 | 0x33, |
michael@0 | 691 | 0x81, 0x03, 0x01, 0x24, 0x00, |
michael@0 | 692 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 693 | 0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65, |
michael@0 | 694 | 0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31, |
michael@0 | 695 | 0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32, |
michael@0 | 696 | 0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33, |
michael@0 | 697 | 0x18, 0x03, 0x10, 0x15, 0x20, |
michael@0 | 698 | 0x90, 0x01, 0x01 |
michael@0 | 699 | ]; |
michael@0 | 700 | |
michael@0 | 701 | for(let i = 0 ; i < select_item_1.length; i++) { |
michael@0 | 702 | pduHelper.writeHexOctet(select_item_1[i]); |
michael@0 | 703 | } |
michael@0 | 704 | |
michael@0 | 705 | let berTlv = berHelper.decode(select_item_1.length); |
michael@0 | 706 | let ctlvs = berTlv.value; |
michael@0 | 707 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 708 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 709 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_SELECT_ITEM); |
michael@0 | 710 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 711 | |
michael@0 | 712 | let menu = stkFactory.createParam(tlv.value, ctlvs); |
michael@0 | 713 | do_check_eq(menu.title, "Title"); |
michael@0 | 714 | do_check_eq(menu.items[0].identifier, 1); |
michael@0 | 715 | do_check_eq(menu.items[0].text, "item 1"); |
michael@0 | 716 | do_check_eq(menu.items[1].identifier, 2); |
michael@0 | 717 | do_check_eq(menu.items[1].text, "item 2"); |
michael@0 | 718 | do_check_eq(menu.items[2].identifier, 3); |
michael@0 | 719 | do_check_eq(menu.items[2].text, "item 3"); |
michael@0 | 720 | do_check_eq(menu.nextActionList[0], STK_CMD_SET_UP_CALL); |
michael@0 | 721 | do_check_eq(menu.nextActionList[1], STK_CMD_LAUNCH_BROWSER); |
michael@0 | 722 | do_check_eq(menu.nextActionList[2], STK_CMD_PLAY_TONE); |
michael@0 | 723 | do_check_eq(menu.defaultItem, 0x00); |
michael@0 | 724 | |
michael@0 | 725 | let select_item_2 = [ |
michael@0 | 726 | 0xD0, |
michael@0 | 727 | 0x33, |
michael@0 | 728 | 0x81, 0x03, 0x01, 0x24, 0x00, |
michael@0 | 729 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 730 | 0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65, |
michael@0 | 731 | 0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31, |
michael@0 | 732 | 0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32, |
michael@0 | 733 | 0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33, |
michael@0 | 734 | 0x18, 0x03, 0x00, 0x15, 0x81, |
michael@0 | 735 | 0x90, 0x01, 0x03 |
michael@0 | 736 | ]; |
michael@0 | 737 | |
michael@0 | 738 | for(let i = 0 ; i < select_item_2.length; i++) { |
michael@0 | 739 | pduHelper.writeHexOctet(select_item_2[i]); |
michael@0 | 740 | } |
michael@0 | 741 | |
michael@0 | 742 | berTlv = berHelper.decode(select_item_2.length); |
michael@0 | 743 | ctlvs = berTlv.value; |
michael@0 | 744 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 745 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 746 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_SELECT_ITEM); |
michael@0 | 747 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 748 | |
michael@0 | 749 | menu = stkFactory.createParam(tlv.value, ctlvs); |
michael@0 | 750 | do_check_eq(menu.title, "Title"); |
michael@0 | 751 | do_check_eq(menu.items[0].identifier, 1); |
michael@0 | 752 | do_check_eq(menu.items[0].text, "item 1"); |
michael@0 | 753 | do_check_eq(menu.items[1].identifier, 2); |
michael@0 | 754 | do_check_eq(menu.items[1].text, "item 2"); |
michael@0 | 755 | do_check_eq(menu.items[2].identifier, 3); |
michael@0 | 756 | do_check_eq(menu.items[2].text, "item 3"); |
michael@0 | 757 | do_check_eq(menu.nextActionList[0], STK_NEXT_ACTION_NULL); |
michael@0 | 758 | do_check_eq(menu.nextActionList[1], STK_CMD_LAUNCH_BROWSER); |
michael@0 | 759 | do_check_eq(menu.nextActionList[2], STK_NEXT_ACTION_END_PROACTIVE_SESSION); |
michael@0 | 760 | do_check_eq(menu.defaultItem, 0x02); |
michael@0 | 761 | |
michael@0 | 762 | run_next_test(); |
michael@0 | 763 | }); |
michael@0 | 764 | |
michael@0 | 765 | /** |
michael@0 | 766 | * Verify Proactive Command : Set Up Menu |
michael@0 | 767 | */ |
michael@0 | 768 | add_test(function test_stk_proactive_command_set_up_menu() { |
michael@0 | 769 | let worker = newUint8Worker(); |
michael@0 | 770 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 771 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 772 | let berHelper = context.BerTlvHelper; |
michael@0 | 773 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 774 | let stkFactory = context.StkCommandParamsFactory; |
michael@0 | 775 | |
michael@0 | 776 | let set_up_menu_1 = [ |
michael@0 | 777 | 0xD0, |
michael@0 | 778 | 0x30, |
michael@0 | 779 | 0x81, 0x03, 0x01, 0x25, 0x00, |
michael@0 | 780 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 781 | 0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65, |
michael@0 | 782 | 0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31, |
michael@0 | 783 | 0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32, |
michael@0 | 784 | 0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33, |
michael@0 | 785 | 0x18, 0x03, 0x10, 0x15, 0x20 |
michael@0 | 786 | ]; |
michael@0 | 787 | |
michael@0 | 788 | for(let i = 0 ; i < set_up_menu_1.length; i++) { |
michael@0 | 789 | pduHelper.writeHexOctet(set_up_menu_1[i]); |
michael@0 | 790 | } |
michael@0 | 791 | |
michael@0 | 792 | let berTlv = berHelper.decode(set_up_menu_1.length); |
michael@0 | 793 | let ctlvs = berTlv.value; |
michael@0 | 794 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 795 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 796 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_SET_UP_MENU); |
michael@0 | 797 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 798 | |
michael@0 | 799 | let menu = stkFactory.createParam(tlv.value, ctlvs); |
michael@0 | 800 | do_check_eq(menu.title, "Title"); |
michael@0 | 801 | do_check_eq(menu.items[0].identifier, 1); |
michael@0 | 802 | do_check_eq(menu.items[0].text, "item 1"); |
michael@0 | 803 | do_check_eq(menu.items[1].identifier, 2); |
michael@0 | 804 | do_check_eq(menu.items[1].text, "item 2"); |
michael@0 | 805 | do_check_eq(menu.items[2].identifier, 3); |
michael@0 | 806 | do_check_eq(menu.items[2].text, "item 3"); |
michael@0 | 807 | do_check_eq(menu.nextActionList[0], STK_CMD_SET_UP_CALL); |
michael@0 | 808 | do_check_eq(menu.nextActionList[1], STK_CMD_LAUNCH_BROWSER); |
michael@0 | 809 | do_check_eq(menu.nextActionList[2], STK_CMD_PLAY_TONE); |
michael@0 | 810 | |
michael@0 | 811 | let set_up_menu_2 = [ |
michael@0 | 812 | 0xD0, |
michael@0 | 813 | 0x30, |
michael@0 | 814 | 0x81, 0x03, 0x01, 0x25, 0x00, |
michael@0 | 815 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 816 | 0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65, |
michael@0 | 817 | 0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31, |
michael@0 | 818 | 0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32, |
michael@0 | 819 | 0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33, |
michael@0 | 820 | 0x18, 0x03, 0x81, 0x00, 0x00 |
michael@0 | 821 | ]; |
michael@0 | 822 | |
michael@0 | 823 | for(let i = 0 ; i < set_up_menu_2.length; i++) { |
michael@0 | 824 | pduHelper.writeHexOctet(set_up_menu_2[i]); |
michael@0 | 825 | } |
michael@0 | 826 | |
michael@0 | 827 | berTlv = berHelper.decode(set_up_menu_2.length); |
michael@0 | 828 | ctlvs = berTlv.value; |
michael@0 | 829 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 830 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 831 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_SET_UP_MENU); |
michael@0 | 832 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 833 | |
michael@0 | 834 | let menu = stkFactory.createParam(tlv.value, ctlvs); |
michael@0 | 835 | do_check_eq(menu.title, "Title"); |
michael@0 | 836 | do_check_eq(menu.items[0].identifier, 1); |
michael@0 | 837 | do_check_eq(menu.items[0].text, "item 1"); |
michael@0 | 838 | do_check_eq(menu.items[1].identifier, 2); |
michael@0 | 839 | do_check_eq(menu.items[1].text, "item 2"); |
michael@0 | 840 | do_check_eq(menu.items[2].identifier, 3); |
michael@0 | 841 | do_check_eq(menu.items[2].text, "item 3"); |
michael@0 | 842 | do_check_eq(menu.nextActionList[0], STK_NEXT_ACTION_END_PROACTIVE_SESSION); |
michael@0 | 843 | do_check_eq(menu.nextActionList[1], STK_NEXT_ACTION_NULL); |
michael@0 | 844 | do_check_eq(menu.nextActionList[2], STK_NEXT_ACTION_NULL); |
michael@0 | 845 | |
michael@0 | 846 | run_next_test(); |
michael@0 | 847 | }); |
michael@0 | 848 | |
michael@0 | 849 | /** |
michael@0 | 850 | * Verify Proactive Command : Set Up Call |
michael@0 | 851 | */ |
michael@0 | 852 | add_test(function test_stk_proactive_command_set_up_call() { |
michael@0 | 853 | let worker = newUint8Worker(); |
michael@0 | 854 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 855 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 856 | let berHelper = context.BerTlvHelper; |
michael@0 | 857 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 858 | let cmdFactory = context.StkCommandParamsFactory; |
michael@0 | 859 | |
michael@0 | 860 | let set_up_call_1 = [ |
michael@0 | 861 | 0xD0, |
michael@0 | 862 | 0x29, |
michael@0 | 863 | 0x81, 0x03, 0x01, 0x10, 0x04, |
michael@0 | 864 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 865 | 0x05, 0x0A, 0x44, 0x69, 0x73, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, |
michael@0 | 866 | 0x86, 0x09, 0x81, 0x10, 0x32, 0x04, 0x21, 0x43, 0x65, 0x1C, 0x2C, |
michael@0 | 867 | 0x05, 0x07, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65]; |
michael@0 | 868 | |
michael@0 | 869 | for (let i = 0 ; i < set_up_call_1.length; i++) { |
michael@0 | 870 | pduHelper.writeHexOctet(set_up_call_1[i]); |
michael@0 | 871 | } |
michael@0 | 872 | |
michael@0 | 873 | let berTlv = berHelper.decode(set_up_call_1.length); |
michael@0 | 874 | let ctlvs = berTlv.value; |
michael@0 | 875 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 876 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 877 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_SET_UP_CALL); |
michael@0 | 878 | |
michael@0 | 879 | let setupCall = cmdFactory.createParam(tlv.value, ctlvs); |
michael@0 | 880 | do_check_eq(setupCall.address, "012340123456,1,2"); |
michael@0 | 881 | do_check_eq(setupCall.confirmMessage, "Disconnect"); |
michael@0 | 882 | do_check_eq(setupCall.callMessage, "Message"); |
michael@0 | 883 | |
michael@0 | 884 | run_next_test(); |
michael@0 | 885 | }); |
michael@0 | 886 | |
michael@0 | 887 | /** |
michael@0 | 888 | * Verify Proactive Command : Timer Management |
michael@0 | 889 | */ |
michael@0 | 890 | add_test(function test_stk_proactive_command_timer_management() { |
michael@0 | 891 | let worker = newUint8Worker(); |
michael@0 | 892 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 893 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 894 | let berHelper = context.BerTlvHelper; |
michael@0 | 895 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 896 | |
michael@0 | 897 | // Timer Management - Start |
michael@0 | 898 | let timer_management_1 = [ |
michael@0 | 899 | 0xD0, |
michael@0 | 900 | 0x11, |
michael@0 | 901 | 0x81, 0x03, 0x01, 0x27, 0x00, |
michael@0 | 902 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 903 | 0xA4, 0x01, 0x01, |
michael@0 | 904 | 0xA5, 0x03, 0x10, 0x20, 0x30 |
michael@0 | 905 | ]; |
michael@0 | 906 | |
michael@0 | 907 | for(let i = 0 ; i < timer_management_1.length; i++) { |
michael@0 | 908 | pduHelper.writeHexOctet(timer_management_1[i]); |
michael@0 | 909 | } |
michael@0 | 910 | |
michael@0 | 911 | let berTlv = berHelper.decode(timer_management_1.length); |
michael@0 | 912 | let ctlvs = berTlv.value; |
michael@0 | 913 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 914 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 915 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_TIMER_MANAGEMENT); |
michael@0 | 916 | do_check_eq(tlv.value.commandQualifier, STK_TIMER_START); |
michael@0 | 917 | |
michael@0 | 918 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_TIMER_IDENTIFIER, ctlvs); |
michael@0 | 919 | do_check_eq(tlv.value.timerId, 0x01); |
michael@0 | 920 | |
michael@0 | 921 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_TIMER_VALUE, ctlvs); |
michael@0 | 922 | do_check_eq(tlv.value.timerValue, (0x01 * 60 * 60) + (0x02 * 60) + 0x03); |
michael@0 | 923 | |
michael@0 | 924 | // Timer Management - Deactivate |
michael@0 | 925 | let timer_management_2 = [ |
michael@0 | 926 | 0xD0, |
michael@0 | 927 | 0x0C, |
michael@0 | 928 | 0x81, 0x03, 0x01, 0x27, 0x01, |
michael@0 | 929 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 930 | 0xA4, 0x01, 0x01 |
michael@0 | 931 | ]; |
michael@0 | 932 | |
michael@0 | 933 | for(let i = 0 ; i < timer_management_2.length; i++) { |
michael@0 | 934 | pduHelper.writeHexOctet(timer_management_2[i]); |
michael@0 | 935 | } |
michael@0 | 936 | |
michael@0 | 937 | berTlv = berHelper.decode(timer_management_2.length); |
michael@0 | 938 | ctlvs = berTlv.value; |
michael@0 | 939 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 940 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 941 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_TIMER_MANAGEMENT); |
michael@0 | 942 | do_check_eq(tlv.value.commandQualifier, STK_TIMER_DEACTIVATE); |
michael@0 | 943 | |
michael@0 | 944 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_TIMER_IDENTIFIER, ctlvs); |
michael@0 | 945 | do_check_eq(tlv.value.timerId, 0x01); |
michael@0 | 946 | |
michael@0 | 947 | run_next_test(); |
michael@0 | 948 | }); |
michael@0 | 949 | |
michael@0 | 950 | /** |
michael@0 | 951 | * Verify Proactive Command : Provide Local Information |
michael@0 | 952 | */ |
michael@0 | 953 | add_test(function test_stk_proactive_command_provide_local_information() { |
michael@0 | 954 | let worker = newUint8Worker(); |
michael@0 | 955 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 956 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 957 | let berHelper = context.BerTlvHelper; |
michael@0 | 958 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 959 | |
michael@0 | 960 | // Verify IMEI |
michael@0 | 961 | let local_info_1 = [ |
michael@0 | 962 | 0xD0, |
michael@0 | 963 | 0x09, |
michael@0 | 964 | 0x81, 0x03, 0x01, 0x26, 0x01, |
michael@0 | 965 | 0x82, 0x02, 0x81, 0x82]; |
michael@0 | 966 | |
michael@0 | 967 | for (let i = 0; i < local_info_1.length; i++) { |
michael@0 | 968 | pduHelper.writeHexOctet(local_info_1[i]); |
michael@0 | 969 | } |
michael@0 | 970 | |
michael@0 | 971 | let berTlv = berHelper.decode(local_info_1.length); |
michael@0 | 972 | let ctlvs = berTlv.value; |
michael@0 | 973 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 974 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 975 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_PROVIDE_LOCAL_INFO); |
michael@0 | 976 | do_check_eq(tlv.value.commandQualifier, STK_LOCAL_INFO_IMEI); |
michael@0 | 977 | |
michael@0 | 978 | // Verify Date and Time Zone |
michael@0 | 979 | let local_info_2 = [ |
michael@0 | 980 | 0xD0, |
michael@0 | 981 | 0x09, |
michael@0 | 982 | 0x81, 0x03, 0x01, 0x26, 0x03, |
michael@0 | 983 | 0x82, 0x02, 0x81, 0x82]; |
michael@0 | 984 | |
michael@0 | 985 | for (let i = 0; i < local_info_2.length; i++) { |
michael@0 | 986 | pduHelper.writeHexOctet(local_info_2[i]); |
michael@0 | 987 | } |
michael@0 | 988 | |
michael@0 | 989 | berTlv = berHelper.decode(local_info_2.length); |
michael@0 | 990 | ctlvs = berTlv.value; |
michael@0 | 991 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 992 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 993 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_PROVIDE_LOCAL_INFO); |
michael@0 | 994 | do_check_eq(tlv.value.commandQualifier, STK_LOCAL_INFO_DATE_TIME_ZONE); |
michael@0 | 995 | |
michael@0 | 996 | run_next_test(); |
michael@0 | 997 | }); |
michael@0 | 998 | |
michael@0 | 999 | /** |
michael@0 | 1000 | * Verify Proactive command : BIP Messages |
michael@0 | 1001 | */ |
michael@0 | 1002 | add_test(function test_stk_proactive_command_open_channel() { |
michael@0 | 1003 | let worker = newUint8Worker(); |
michael@0 | 1004 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 1005 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 1006 | let berHelper = context.BerTlvHelper; |
michael@0 | 1007 | let stkHelper = context.StkProactiveCmdHelper; |
michael@0 | 1008 | |
michael@0 | 1009 | // Open Channel |
michael@0 | 1010 | let open_channel = [ |
michael@0 | 1011 | 0xD0, |
michael@0 | 1012 | 0x0F, |
michael@0 | 1013 | 0x81, 0x03, 0x01, 0x40, 0x00, |
michael@0 | 1014 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 1015 | 0x85, 0x04, 0x4F, 0x70, 0x65, 0x6E //alpha id: "Open" |
michael@0 | 1016 | ]; |
michael@0 | 1017 | |
michael@0 | 1018 | for (let i = 0; i < open_channel.length; i++) { |
michael@0 | 1019 | pduHelper.writeHexOctet(open_channel[i]); |
michael@0 | 1020 | } |
michael@0 | 1021 | |
michael@0 | 1022 | let berTlv = berHelper.decode(open_channel.length); |
michael@0 | 1023 | let ctlvs = berTlv.value; |
michael@0 | 1024 | let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 1025 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 1026 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_OPEN_CHANNEL); |
michael@0 | 1027 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 1028 | |
michael@0 | 1029 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs); |
michael@0 | 1030 | do_check_eq(tlv.value.identifier, "Open"); |
michael@0 | 1031 | |
michael@0 | 1032 | // Close Channel |
michael@0 | 1033 | let close_channel = [ |
michael@0 | 1034 | 0xD0, |
michael@0 | 1035 | 0x10, |
michael@0 | 1036 | 0x81, 0x03, 0x01, 0x41, 0x00, |
michael@0 | 1037 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 1038 | 0x85, 0x05, 0x43, 0x6C, 0x6F, 0x73, 0x65 //alpha id: "Close" |
michael@0 | 1039 | ]; |
michael@0 | 1040 | |
michael@0 | 1041 | for (let i = 0; i < close_channel.length; i++) { |
michael@0 | 1042 | pduHelper.writeHexOctet(close_channel[i]); |
michael@0 | 1043 | } |
michael@0 | 1044 | |
michael@0 | 1045 | berTlv = berHelper.decode(close_channel.length); |
michael@0 | 1046 | ctlvs = berTlv.value; |
michael@0 | 1047 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 1048 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 1049 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_CLOSE_CHANNEL); |
michael@0 | 1050 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 1051 | |
michael@0 | 1052 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs); |
michael@0 | 1053 | do_check_eq(tlv.value.identifier, "Close"); |
michael@0 | 1054 | |
michael@0 | 1055 | // Receive Data |
michael@0 | 1056 | let receive_data = [ |
michael@0 | 1057 | 0XD0, |
michael@0 | 1058 | 0X12, |
michael@0 | 1059 | 0x81, 0x03, 0x01, 0x42, 0x00, |
michael@0 | 1060 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 1061 | 0x85, 0x07, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65 //alpha id: "Receive" |
michael@0 | 1062 | ]; |
michael@0 | 1063 | |
michael@0 | 1064 | for (let i = 0; i < receive_data.length; i++) { |
michael@0 | 1065 | pduHelper.writeHexOctet(receive_data[i]); |
michael@0 | 1066 | } |
michael@0 | 1067 | |
michael@0 | 1068 | berTlv = berHelper.decode(receive_data.length); |
michael@0 | 1069 | ctlvs = berTlv.value; |
michael@0 | 1070 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 1071 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 1072 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_RECEIVE_DATA); |
michael@0 | 1073 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 1074 | |
michael@0 | 1075 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs); |
michael@0 | 1076 | do_check_eq(tlv.value.identifier, "Receive"); |
michael@0 | 1077 | |
michael@0 | 1078 | // Send Data |
michael@0 | 1079 | let send_data = [ |
michael@0 | 1080 | 0xD0, |
michael@0 | 1081 | 0x0F, |
michael@0 | 1082 | 0x81, 0x03, 0x01, 0x43, 0x00, |
michael@0 | 1083 | 0x82, 0x02, 0x81, 0x82, |
michael@0 | 1084 | 0x85, 0x04, 0x53, 0x65, 0x6E, 0x64 //alpha id: "Send" |
michael@0 | 1085 | ]; |
michael@0 | 1086 | |
michael@0 | 1087 | for (let i = 0; i < send_data.length; i++) { |
michael@0 | 1088 | pduHelper.writeHexOctet(send_data[i]); |
michael@0 | 1089 | } |
michael@0 | 1090 | |
michael@0 | 1091 | berTlv = berHelper.decode(send_data.length); |
michael@0 | 1092 | ctlvs = berTlv.value; |
michael@0 | 1093 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs); |
michael@0 | 1094 | do_check_eq(tlv.value.commandNumber, 0x01); |
michael@0 | 1095 | do_check_eq(tlv.value.typeOfCommand, STK_CMD_SEND_DATA); |
michael@0 | 1096 | do_check_eq(tlv.value.commandQualifier, 0x00); |
michael@0 | 1097 | |
michael@0 | 1098 | tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs); |
michael@0 | 1099 | do_check_eq(tlv.value.identifier, "Send"); |
michael@0 | 1100 | |
michael@0 | 1101 | run_next_test(); |
michael@0 | 1102 | }); |
michael@0 | 1103 | |
michael@0 | 1104 | /** |
michael@0 | 1105 | * Verify Event Download Command : Location Status |
michael@0 | 1106 | */ |
michael@0 | 1107 | add_test(function test_stk_event_download_location_status() { |
michael@0 | 1108 | let worker = newUint8SupportOutgoingIndexWorker(); |
michael@0 | 1109 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 1110 | let buf = context.Buf; |
michael@0 | 1111 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 1112 | |
michael@0 | 1113 | buf.sendParcel = function() { |
michael@0 | 1114 | // Type |
michael@0 | 1115 | do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND); |
michael@0 | 1116 | |
michael@0 | 1117 | // Token : we don't care |
michael@0 | 1118 | this.readInt32(); |
michael@0 | 1119 | |
michael@0 | 1120 | // Data Size, 42 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) + |
michael@0 | 1121 | // TLV_EVENT_LIST_SIZE(3) + |
michael@0 | 1122 | // TLV_LOCATION_STATUS_SIZE(3) + |
michael@0 | 1123 | // TLV_LOCATION_INFO_GSM_SIZE(9)) |
michael@0 | 1124 | do_check_eq(this.readInt32(), 42); |
michael@0 | 1125 | |
michael@0 | 1126 | // BER tag |
michael@0 | 1127 | do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG); |
michael@0 | 1128 | |
michael@0 | 1129 | // BER length, 19 = TLV_DEVICE_ID_SIZE(4) + |
michael@0 | 1130 | // TLV_EVENT_LIST_SIZE(3) + |
michael@0 | 1131 | // TLV_LOCATION_STATUS_SIZE(3) + |
michael@0 | 1132 | // TLV_LOCATION_INFO_GSM_SIZE(9) |
michael@0 | 1133 | do_check_eq(pduHelper.readHexOctet(), 19); |
michael@0 | 1134 | |
michael@0 | 1135 | // Device Identifies, Type-Length-Value(Source ID-Destination ID) |
michael@0 | 1136 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID | |
michael@0 | 1137 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1138 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 1139 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME); |
michael@0 | 1140 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM); |
michael@0 | 1141 | |
michael@0 | 1142 | // Event List, Type-Length-Value |
michael@0 | 1143 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_EVENT_LIST | |
michael@0 | 1144 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1145 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1146 | do_check_eq(pduHelper.readHexOctet(), STK_EVENT_TYPE_LOCATION_STATUS); |
michael@0 | 1147 | |
michael@0 | 1148 | // Location Status, Type-Length-Value |
michael@0 | 1149 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_LOCATION_STATUS | |
michael@0 | 1150 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1151 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1152 | do_check_eq(pduHelper.readHexOctet(), STK_SERVICE_STATE_NORMAL); |
michael@0 | 1153 | |
michael@0 | 1154 | // Location Info, Type-Length-Value |
michael@0 | 1155 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_LOCATION_INFO | |
michael@0 | 1156 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1157 | do_check_eq(pduHelper.readHexOctet(), 7); |
michael@0 | 1158 | |
michael@0 | 1159 | do_check_eq(pduHelper.readHexOctet(), 0x21); // MCC + MNC |
michael@0 | 1160 | do_check_eq(pduHelper.readHexOctet(), 0x63); |
michael@0 | 1161 | do_check_eq(pduHelper.readHexOctet(), 0x54); |
michael@0 | 1162 | do_check_eq(pduHelper.readHexOctet(), 0); // LAC |
michael@0 | 1163 | do_check_eq(pduHelper.readHexOctet(), 0); |
michael@0 | 1164 | do_check_eq(pduHelper.readHexOctet(), 0); // Cell ID |
michael@0 | 1165 | do_check_eq(pduHelper.readHexOctet(), 0); |
michael@0 | 1166 | |
michael@0 | 1167 | run_next_test(); |
michael@0 | 1168 | }; |
michael@0 | 1169 | |
michael@0 | 1170 | let event = { |
michael@0 | 1171 | eventType: STK_EVENT_TYPE_LOCATION_STATUS, |
michael@0 | 1172 | locationStatus: STK_SERVICE_STATE_NORMAL, |
michael@0 | 1173 | locationInfo: { |
michael@0 | 1174 | mcc: "123", |
michael@0 | 1175 | mnc: "456", |
michael@0 | 1176 | gsmLocationAreaCode: 0, |
michael@0 | 1177 | gsmCellId: 0 |
michael@0 | 1178 | } |
michael@0 | 1179 | }; |
michael@0 | 1180 | context.RIL.sendStkEventDownload({ |
michael@0 | 1181 | event: event |
michael@0 | 1182 | }); |
michael@0 | 1183 | }); |
michael@0 | 1184 | |
michael@0 | 1185 | // Test Event Download commands. |
michael@0 | 1186 | |
michael@0 | 1187 | /** |
michael@0 | 1188 | * Verify Event Download Command : Language Selection |
michael@0 | 1189 | */ |
michael@0 | 1190 | add_test(function test_stk_event_download_language_selection() { |
michael@0 | 1191 | let worker = newUint8SupportOutgoingIndexWorker(); |
michael@0 | 1192 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 1193 | let buf = context.Buf; |
michael@0 | 1194 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 1195 | let iccHelper = context.ICCPDUHelper; |
michael@0 | 1196 | |
michael@0 | 1197 | buf.sendParcel = function() { |
michael@0 | 1198 | // Type |
michael@0 | 1199 | do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND); |
michael@0 | 1200 | |
michael@0 | 1201 | // Token : we don't care |
michael@0 | 1202 | this.readInt32(); |
michael@0 | 1203 | |
michael@0 | 1204 | // Data Size, 26 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) + |
michael@0 | 1205 | // TLV_EVENT_LIST_SIZE(3) + |
michael@0 | 1206 | // TLV_LANGUAGE(4)) |
michael@0 | 1207 | do_check_eq(this.readInt32(), 26); |
michael@0 | 1208 | |
michael@0 | 1209 | // BER tag |
michael@0 | 1210 | do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG); |
michael@0 | 1211 | |
michael@0 | 1212 | // BER length, 19 = TLV_DEVICE_ID_SIZE(4) + |
michael@0 | 1213 | // TLV_EVENT_LIST_SIZE(3) + |
michael@0 | 1214 | // TLV_LANGUAGE(4) |
michael@0 | 1215 | do_check_eq(pduHelper.readHexOctet(), 11); |
michael@0 | 1216 | |
michael@0 | 1217 | // Device Identifies, Type-Length-Value(Source ID-Destination ID) |
michael@0 | 1218 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID | |
michael@0 | 1219 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1220 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 1221 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME); |
michael@0 | 1222 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM); |
michael@0 | 1223 | |
michael@0 | 1224 | // Event List, Type-Length-Value |
michael@0 | 1225 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_EVENT_LIST | |
michael@0 | 1226 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1227 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1228 | do_check_eq(pduHelper.readHexOctet(), STK_EVENT_TYPE_LANGUAGE_SELECTION); |
michael@0 | 1229 | |
michael@0 | 1230 | // Language, Type-Length-Value |
michael@0 | 1231 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_LANGUAGE); |
michael@0 | 1232 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 1233 | do_check_eq(iccHelper.read8BitUnpackedToString(2), "zh"); |
michael@0 | 1234 | |
michael@0 | 1235 | run_next_test(); |
michael@0 | 1236 | }; |
michael@0 | 1237 | |
michael@0 | 1238 | let event = { |
michael@0 | 1239 | eventType: STK_EVENT_TYPE_LANGUAGE_SELECTION, |
michael@0 | 1240 | language: "zh" |
michael@0 | 1241 | }; |
michael@0 | 1242 | context.RIL.sendStkEventDownload({ |
michael@0 | 1243 | event: event |
michael@0 | 1244 | }); |
michael@0 | 1245 | }); |
michael@0 | 1246 | |
michael@0 | 1247 | /** |
michael@0 | 1248 | * Verify Event Download Command : User Activity |
michael@0 | 1249 | */ |
michael@0 | 1250 | add_test(function test_stk_event_download_user_activity() { |
michael@0 | 1251 | let worker = newUint8SupportOutgoingIndexWorker(); |
michael@0 | 1252 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 1253 | let buf = context.Buf; |
michael@0 | 1254 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 1255 | |
michael@0 | 1256 | buf.sendParcel = function() { |
michael@0 | 1257 | // Type |
michael@0 | 1258 | do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND); |
michael@0 | 1259 | |
michael@0 | 1260 | // Token : we don't care |
michael@0 | 1261 | this.readInt32(); |
michael@0 | 1262 | |
michael@0 | 1263 | // Data Size, 18 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3)) |
michael@0 | 1264 | do_check_eq(this.readInt32(), 18); |
michael@0 | 1265 | |
michael@0 | 1266 | // BER tag |
michael@0 | 1267 | do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG); |
michael@0 | 1268 | |
michael@0 | 1269 | // BER length, 7 = TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3) |
michael@0 | 1270 | do_check_eq(pduHelper.readHexOctet(), 7); |
michael@0 | 1271 | |
michael@0 | 1272 | // Device Identities, Type-Length-Value(Source ID-Destination ID) |
michael@0 | 1273 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID | |
michael@0 | 1274 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1275 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 1276 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME); |
michael@0 | 1277 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM); |
michael@0 | 1278 | |
michael@0 | 1279 | // Event List, Type-Length-Value |
michael@0 | 1280 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_EVENT_LIST | |
michael@0 | 1281 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1282 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1283 | do_check_eq(pduHelper.readHexOctet(), STK_EVENT_TYPE_USER_ACTIVITY); |
michael@0 | 1284 | |
michael@0 | 1285 | run_next_test(); |
michael@0 | 1286 | }; |
michael@0 | 1287 | |
michael@0 | 1288 | let event = { |
michael@0 | 1289 | eventType: STK_EVENT_TYPE_USER_ACTIVITY |
michael@0 | 1290 | }; |
michael@0 | 1291 | context.RIL.sendStkEventDownload({ |
michael@0 | 1292 | event: event |
michael@0 | 1293 | }); |
michael@0 | 1294 | }); |
michael@0 | 1295 | |
michael@0 | 1296 | /** |
michael@0 | 1297 | * Verify Event Download Command : Idle Screen Available |
michael@0 | 1298 | */ |
michael@0 | 1299 | add_test(function test_stk_event_download_idle_screen_available() { |
michael@0 | 1300 | let worker = newUint8SupportOutgoingIndexWorker(); |
michael@0 | 1301 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 1302 | let buf = context.Buf; |
michael@0 | 1303 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 1304 | |
michael@0 | 1305 | buf.sendParcel = function() { |
michael@0 | 1306 | // Type |
michael@0 | 1307 | do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND); |
michael@0 | 1308 | |
michael@0 | 1309 | // Token : we don't care |
michael@0 | 1310 | this.readInt32(); |
michael@0 | 1311 | |
michael@0 | 1312 | // Data Size, 18 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3)) |
michael@0 | 1313 | do_check_eq(this.readInt32(), 18); |
michael@0 | 1314 | |
michael@0 | 1315 | // BER tag |
michael@0 | 1316 | do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG); |
michael@0 | 1317 | |
michael@0 | 1318 | // BER length, 7 = TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3) |
michael@0 | 1319 | do_check_eq(pduHelper.readHexOctet(), 7); |
michael@0 | 1320 | |
michael@0 | 1321 | // Device Identities, Type-Length-Value(Source ID-Destination ID) |
michael@0 | 1322 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID | |
michael@0 | 1323 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1324 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 1325 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_DISPLAY); |
michael@0 | 1326 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM); |
michael@0 | 1327 | |
michael@0 | 1328 | // Event List, Type-Length-Value |
michael@0 | 1329 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_EVENT_LIST | |
michael@0 | 1330 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1331 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1332 | do_check_eq(pduHelper.readHexOctet(), STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE); |
michael@0 | 1333 | |
michael@0 | 1334 | run_next_test(); |
michael@0 | 1335 | }; |
michael@0 | 1336 | |
michael@0 | 1337 | let event = { |
michael@0 | 1338 | eventType: STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE |
michael@0 | 1339 | }; |
michael@0 | 1340 | context.RIL.sendStkEventDownload({ |
michael@0 | 1341 | event: event |
michael@0 | 1342 | }); |
michael@0 | 1343 | }); |
michael@0 | 1344 | |
michael@0 | 1345 | /** |
michael@0 | 1346 | * Verify Event Downloaded Command :Browser Termination |
michael@0 | 1347 | */ |
michael@0 | 1348 | add_test(function test_stk_event_download_browser_termination() { |
michael@0 | 1349 | let worker = newUint8SupportOutgoingIndexWorker(); |
michael@0 | 1350 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 1351 | let buf = context.Buf; |
michael@0 | 1352 | let pduHelper = context.GsmPDUHelper; |
michael@0 | 1353 | |
michael@0 | 1354 | buf.sendParcel = function() { |
michael@0 | 1355 | // Type |
michael@0 | 1356 | do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND); |
michael@0 | 1357 | |
michael@0 | 1358 | // Token : we don't care |
michael@0 | 1359 | this.readInt32(); |
michael@0 | 1360 | |
michael@0 | 1361 | // Data Size, 24 = 2 * ( 2+TLV_DEVICE_ID(4)+TLV_EVENT_LIST_SIZE(3) |
michael@0 | 1362 | // +TLV_BROWSER_TERMINATION_CAUSE(3) ) |
michael@0 | 1363 | do_check_eq(this.readInt32(), 24); |
michael@0 | 1364 | |
michael@0 | 1365 | // BER tag |
michael@0 | 1366 | do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG); |
michael@0 | 1367 | |
michael@0 | 1368 | // BER length, 10 = TLV_DEVICE_ID(4)+TLV_EVENT_LIST_SIZE(3) |
michael@0 | 1369 | // ++TLV_BROWSER_TERMINATION_CAUSE(3) |
michael@0 | 1370 | do_check_eq(pduHelper.readHexOctet(), 10); |
michael@0 | 1371 | |
michael@0 | 1372 | // Device Identities, Type-Length-Value(Source ID-Destination ID) |
michael@0 | 1373 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID | |
michael@0 | 1374 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1375 | do_check_eq(pduHelper.readHexOctet(), 2); |
michael@0 | 1376 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME); |
michael@0 | 1377 | do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM); |
michael@0 | 1378 | |
michael@0 | 1379 | // Event List, Type-Length-Value |
michael@0 | 1380 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_EVENT_LIST | |
michael@0 | 1381 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1382 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1383 | do_check_eq(pduHelper.readHexOctet(), STK_EVENT_TYPE_BROWSER_TERMINATION); |
michael@0 | 1384 | |
michael@0 | 1385 | // Browser Termination Case, Type-Length-Value |
michael@0 | 1386 | do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_BROWSER_TERMINATION_CAUSE | |
michael@0 | 1387 | COMPREHENSIONTLV_FLAG_CR); |
michael@0 | 1388 | do_check_eq(pduHelper.readHexOctet(), 1); |
michael@0 | 1389 | do_check_eq(pduHelper.readHexOctet(), STK_BROWSER_TERMINATION_CAUSE_USER); |
michael@0 | 1390 | |
michael@0 | 1391 | run_next_test(); |
michael@0 | 1392 | }; |
michael@0 | 1393 | |
michael@0 | 1394 | let event = { |
michael@0 | 1395 | eventType: STK_EVENT_TYPE_BROWSER_TERMINATION, |
michael@0 | 1396 | terminationCause: STK_BROWSER_TERMINATION_CAUSE_USER |
michael@0 | 1397 | }; |
michael@0 | 1398 | context.RIL.sendStkEventDownload({ |
michael@0 | 1399 | event: event |
michael@0 | 1400 | }); |
michael@0 | 1401 | }); |