michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_HEAD_JS = "stk_helper.js"; michael@0: michael@0: function testGetInput(command, expect) { michael@0: log("STK CMD " + JSON.stringify(command)); michael@0: is(command.typeOfCommand, iccManager.STK_CMD_GET_INPUT, expect.name); michael@0: is(command.commandQualifier, expect.commandQualifier, expect.name); michael@0: is(command.options.text, expect.text, expect.name); michael@0: is(command.options.minLength, expect.minLength, expect.name); michael@0: is(command.options.maxLength, expect.maxLength, expect.name); michael@0: if (command.options.defaultText) { michael@0: is(command.options.defaultText, expect.defaultText, expect.name); michael@0: } michael@0: if (command.options.isAlphabet) { michael@0: is(command.options.isAlphabet, expect.isAlphabet, expect.name); michael@0: } michael@0: if (command.options.isUCS2) { michael@0: is(command.options.isUCS2, expect.isUCS2, expect.name); michael@0: } michael@0: if (command.options.isPacked) { michael@0: is(command.options.isPacked, expect.isPacked, expect.name); michael@0: } michael@0: if (command.options.hideInput) { michael@0: is(command.options.hideInput, expect.hideInput, expect.name); michael@0: } michael@0: michael@0: runNextTest(); michael@0: } michael@0: michael@0: let tests = [ michael@0: {command: "d01b8103012300820281828d0c04456e74657220313233343591020505", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_1", michael@0: commandQualifier: 0x00, michael@0: text: "Enter 12345", michael@0: minLength: 5, michael@0: maxLength: 5}}, michael@0: {command: "d01a8103012308820281828d0b004537bd2c07d96eaad10a91020505", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_2", michael@0: commandQualifier: 0x08, michael@0: text: "Enter 67*#+", michael@0: minLength: 5, michael@0: maxLength: 5, michael@0: isPacked: true}}, michael@0: {command: "d01b8103012301820281828d0c04456e74657220416243644591020505", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_3", michael@0: commandQualifier: 0x01, michael@0: text: "Enter AbCdE", michael@0: minLength: 5, michael@0: maxLength: 5, michael@0: isAlphabet: true}}, michael@0: {command: "d0278103012304820281828d180450617373776f726420313c53454e443e3233343536373891020408", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_4", michael@0: commandQualifier: 0x04, michael@0: text: "Password 12345678", michael@0: minLength: 4, michael@0: maxLength: 8, michael@0: hideInput: true}}, michael@0: {command: "d0248103012300820281828d1504456e74657220312e2e392c302e2e392c3028312991020114", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_5", michael@0: commandQualifier: 0x00, michael@0: text: "Enter 1..9,0..9,0(1)", michael@0: minLength: 1, michael@0: maxLength: 20}}, michael@0: {command: "d01e8103012300820281828d0f043c474f2d4241434b57415244533e91020008", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_6", michael@0: commandQualifier: 0x00, michael@0: text: "", michael@0: minLength: 0, michael@0: maxLength: 8}}, michael@0: {command: "d0178103012300820281828d08043c41424f52543e91020008", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_7", michael@0: commandQualifier: 0x00, michael@0: text: "", michael@0: minLength: 0, michael@0: maxLength: 8}}, michael@0: {command: "d081b18103012300820281828d81a1042a2a2a313131313131313131312323232a2a2a323232323232323232322323232a2a2a333333333333333333332323232a2a2a343434343434343434342323232a2a2a353535353535353535352323232a2a2a363636363636363636362323232a2a2a373737373737373737372323232a2a2a383838383838383838382323232a2a2a393939393939393939392323232a2a2a303030303030303030302323239102a0a0", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_8", michael@0: commandQualifier: 0x00, michael@0: text: "***1111111111###***2222222222###***3333333333###***4444444444###***5555555555###***6666666666###***7777777777###***8888888888###***9999999999###***0000000000###", michael@0: minLength: 160, michael@0: maxLength: 160}}, michael@0: {command: "d0168103012300820281828d07043c53454e443e91020001", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_9", michael@0: commandQualifier: 0x00, michael@0: text: "", michael@0: minLength: 0, michael@0: maxLength: 1}}, michael@0: {command: "d01a8103012300820281828d0b043c54494d452d4f55543e9102000a", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_10", michael@0: commandQualifier: 0x00, michael@0: text: "", michael@0: minLength: 0, michael@0: maxLength: 10}}, michael@0: {command: "d0288103012301820281828d190804170414042004100412042104220412042304190422041591020505", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_11", michael@0: commandQualifier: 0x01, michael@0: text: "ЗДРАВСТВУЙТЕ", michael@0: minLength: 5, michael@0: maxLength: 5, michael@0: isAlphabet: true}}, michael@0: {command: "d0819d8103012301820281828d818d08041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041991020505", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_12", michael@0: commandQualifier: 0x01, michael@0: text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙ", michael@0: minLength: 5, michael@0: maxLength: 5, michael@0: isAlphabet: true}}, michael@0: {command: "d01b8103012303820281828d0c04456e7465722048656c6c6f91020c0c", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_13", michael@0: commandQualifier: 0x03, michael@0: text: "Enter Hello", michael@0: minLength: 12, michael@0: maxLength: 12, michael@0: isAlphabet: true, michael@0: isUCS2: true}}, michael@0: {command: "d01b8103012303820281828d0c04456e7465722048656c6c6f910205ff", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_14", michael@0: commandQualifier: 0x03, michael@0: text: "Enter Hello", michael@0: minLength: 5, michael@0: maxLength: 0xFF, michael@0: isAlphabet: true, michael@0: isUCS2: true}}, michael@0: {command: "d0238103012300820281828d0c04456e746572203132333435910205051706043132333435", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_15", michael@0: commandQualifier: 0x00, michael@0: text: "Enter 12345", michael@0: minLength: 5, michael@0: maxLength: 5, michael@0: defaultText: "12345"}}, michael@0: {command: "d081ba8103012300820281828d0704456e7465723a9102a0a01781a1042a2a2a313131313131313131312323232a2a2a323232323232323232322323232a2a2a333333333333333333332323232a2a2a343434343434343434342323232a2a2a353535353535353535352323232a2a2a363636363636363636362323232a2a2a373737373737373737372323232a2a2a383838383838383838382323232a2a2a393939393939393939392323232a2a2a30303030303030303030232323", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_16", michael@0: commandQualifier: 0x00, michael@0: text: "Enter:", michael@0: minLength: 160, michael@0: maxLength: 160, michael@0: defaultText: "***1111111111###***2222222222###***3333333333###***4444444444###***5555555555###***6666666666###***7777777777###***8888888888###***9999999999###***0000000000###"}}, michael@0: {command: "d01d8103012300820281828d0a043c4e4f2d49434f4e3e9102000a1e020001", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_17", michael@0: commandQualifier: 0x00, michael@0: text: "", michael@0: minLength: 0, michael@0: maxLength: 10}}, michael@0: {command: "d0208103012300820281828d0d043c42415349432d49434f4e3e9102000a1e020101", michael@0: func: testGetInput, michael@0: expect: {name: "get_input_cmd_18", michael@0: commandQualifier: 0x00, michael@0: text: "", michael@0: minLength: 0, michael@0: maxLength: 10}}, michael@0: ]; michael@0: michael@0: runNextTest();