Bug 803861 - Tests should wait for 'onalerting' event when making outgoing calls; r=jgriffin, DONTBUILD(NPOTB)

This commit is contained in:
Rob Wood 2012-10-20 17:33:42 -04:00
parent cc5389f360
commit b0939c3fae
8 changed files with 99 additions and 82 deletions

View File

@ -38,12 +38,18 @@ function dial() {
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : unknown");
is(result[1], "OK");
answer();
});
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
}
function answer() {

View File

@ -37,12 +37,18 @@ function dial() {
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : unknown");
is(result[1], "OK");
answer();
});
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
}
function answer() {

View File

@ -37,12 +37,18 @@ function dial() {
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : unknown");
is(result[1], "OK");
answer();
});
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
}
function answer() {

View File

@ -112,7 +112,7 @@ function holdCall(){
// With one call on hold, make outgoing call
function dial() {
log("Making an outgoing call (while have one call already held).");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
@ -123,13 +123,19 @@ function dial() {
is(telephony.calls[0], incomingCall);
is(telephony.calls[1], outgoingCall);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "inbound from " + inNumber + " : held");
is(result[1], "outbound to " + outNumber + " : unknown");
is(result[2], "OK");
answerOutgoing();
});
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "inbound from " + inNumber + " : held");
is(result[1], "outbound to " + outNumber + " : ringing");
is(result[2], "OK");
answerOutgoing();
});
};
}
// Have the outgoing call answered

View File

@ -38,12 +38,18 @@ function dial() {
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : unknown");
is(result[1], "OK");
answer();
});
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
}
function answer() {

View File

@ -32,14 +32,23 @@ function dial() {
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
//ok(telephony.calls === calls); // bug 717414
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
// Get call list. Answer a call if the connection is established.
runEmulatorCmd("gsm list", cmdCallback);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
}
function answer() {
@ -123,26 +132,6 @@ function hangUp() {
outgoing.hangUp();
}
function cmdCallback(result) {
let unknownState = "outbound to " + number + " : unknown";
let alertingState = "outbound to " + number + " : alerting";
log("Call list is now: " + result);
switch (result[0]) {
// Gsm list is empty. Wait until the connection is established.
case "OK":
runEmulatorCmd("gsm list", cmdCallback);
break;
// Answer the call now since the connection is established.
case unknownState: // Fall through ...
case alertingState:
is(result[1], "OK");
answer();
break;
}
}
function cleanUp() {
SpecialPowers.removePermission("telephony", document);
finish();

View File

@ -36,12 +36,18 @@ function dial() {
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : unknown");
is(result[1], "OK");
answer();
});
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
}
function answer() {

View File

@ -38,17 +38,22 @@ function dial() {
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : unknown");
is(result[1], "OK");
reject();
});
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
runEmulatorCmd("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
reject();
});
};
}
function reject() {
log("Reject the outgoing call on the other end.");
// We get no "disconnecting" event when the remote party rejects the call.
outgoing.ondisconnected = function ondisconnected(event) {
@ -65,22 +70,9 @@ function reject() {
cleanUp();
});
};
runEmulatorCmd("gsm list", cmdCallback);
runEmulatorCmd("gsm cancel " + number);
};
function cmdCallback(result) {
let state = "outbound to " + number + " : unknown";
log("Call list is now: " + result);
// The outgoing call cannot be canceled when call state is unknown.
// Wait until the call connection is established.
if (result[0] == state) {
runEmulatorCmd("gsm list", cmdCallback);
} else {
runEmulatorCmd("gsm cancel " + number);
}
}
function cleanUp() {
SpecialPowers.removePermission("telephony", document);
finish();