gecko/dom/icc/tests/marionette/test_stk_refresh.js

40 lines
1.2 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
const TEST_DATA = [
{command: "d0108103010101820281829205013f002fe2",
expect: {commandQualifier: 0x01}},
{command: "d009810301010482028182",
expect: {commandQualifier: 0x04}}
];
function testRefresh(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_REFRESH, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
}
// Start tests
startTestCommon(function() {
let icc = getMozIcc();
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
let data = TEST_DATA[i];
promise = promise.then(() => {
log("refresh_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testRefresh(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});