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
Родитель 1637825d9b
Коммит 35f5ed906a
19 изменённых файлов: 138 добавлений и 0 удалений

Просмотреть файл

@ -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. * Set radio enabling state and wait for "radiostatechange" event.
* *

Просмотреть файл

@ -121,6 +121,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testBipCommand(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -230,6 +230,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testDisplayText(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -145,6 +145,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testGetInKey(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -186,6 +186,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testGetInput(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -135,6 +135,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testLaunchBrowser(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -53,6 +53,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testLocalInfo(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -30,6 +30,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testPollOff(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -35,6 +35,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testRefresh(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -331,6 +331,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSelectItem(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -97,6 +97,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendDTMF(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -191,6 +191,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSMS(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -119,6 +119,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSS(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -157,6 +157,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendUSSD(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -220,6 +220,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupCall(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -68,6 +68,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupEventList(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -99,6 +99,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupIdleModeText(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -296,6 +296,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupMenu(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));

Просмотреть файл

@ -60,6 +60,12 @@ startTestCommon(function() {
// Wait onstkcommand event. // Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand") promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testTimerManagement(aEvent.command, data.expect))); .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. // Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command)); promises.push(sendEmulatorStkPdu(data.command));