Bug 1123624 - Part 2-3: Add tests for stk system message. r=bevis

This commit is contained in:
Edgar Chen 2015-02-02 17:20:57 +08:00
parent 1637825d9b
commit 35f5ed906a
19 changed files with 138 additions and 0 deletions

View File

@ -287,6 +287,36 @@ function waitForTargetEvent(aEventTarget, aEventName, aMatchFun) {
});
}
/**
* Wait for one named system message.
*
* Resolve if that named message is received. Never reject.
*
* Fulfill params: the message passed.
*
* @param aEventName
* A string message name.
* @param aMatchFun [optional]
* A matching function returns true or false to filter the message. If no
* matching function passed the promise is resolved after receiving the
* first message.
*
* @return A deferred promise.
*/
function waitForSystemMessage(aMessageName, aMatchFun) {
let target = workingFrame.contentWindow.navigator;
return new Promise(function(aResolve, aReject) {
target.mozSetMessageHandler(aMessageName, function(aMessage) {
if (!aMatchFun || aMatchFun(aMessage)) {
target.mozSetMessageHandler(aMessageName, null);
ok(true, "System message '" + aMessageName + "' got.");
aResolve(aMessage);
}
});
});
}
/**
* Set radio enabling state and wait for "radiostatechange" event.
*

View File

@ -121,6 +121,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testBipCommand(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testBipCommand(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -230,6 +230,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testDisplayText(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testDisplayText(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -145,6 +145,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testGetInKey(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testGetInKey(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -186,6 +186,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testGetInput(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testGetInput(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -135,6 +135,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testLaunchBrowser(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testLaunchBrowser(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -53,6 +53,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testLocalInfo(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testLocalInfo(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -30,6 +30,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testPollOff(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testPollOff(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -35,6 +35,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testRefresh(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testRefresh(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -331,6 +331,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSelectItem(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSelectItem(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -97,6 +97,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendDTMF(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendDTMF(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -191,6 +191,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSMS(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendSMS(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -119,6 +119,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSS(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendSS(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -157,6 +157,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendUSSD(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendUSSD(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -220,6 +220,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupCall(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSetupCall(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -68,6 +68,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupEventList(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSetupEventList(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -99,6 +99,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupIdleModeText(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSetupIdleModeText(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -296,6 +296,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupMenu(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSetupMenu(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));

View File

@ -60,6 +60,12 @@ startTestCommon(function() {
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testTimerManagement(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testTimerManagement(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));