Bug 969218 - Part 2: Modify tests. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-02-27 14:12:30 +08:00
parent 432a5efb24
commit 907dc6ec41
25 changed files with 439 additions and 417 deletions

View File

@ -49,18 +49,19 @@ function dial(number) {
log("Make an outgoing call: " + number);
let deferred = Promise.defer();
let call = telephony.dial(number);
ok(call);
is(call.number, number);
is(call.state, "dialing");
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
call.onalerting = function onalerting(event) {
call.onalerting = null;
log("Received 'onalerting' call event.");
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
call.onalerting = function onalerting(event) {
call.onalerting = null;
log("Received 'onalerting' call event.");
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -106,18 +106,19 @@ function dial(number) {
log("Make an outgoing call: " + number);
let deferred = Promise.defer();
let call = telephony.dial(number);
ok(call);
is(call.number, number);
is(call.state, "dialing");
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
call.onalerting = function onalerting(event) {
call.onalerting = null;
log("Received 'onalerting' call event.");
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
call.onalerting = function onalerting(event) {
call.onalerting = null;
log("Received 'onalerting' call event.");
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -9,12 +9,13 @@ let outgoingCall;
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
answer();
};
telephony.dial(outNumber).then(call => {
outgoingCall = call;
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
answer();
};
});
}
function answer() {

View File

@ -73,19 +73,20 @@ function dial(number, serviceId) {
log("Make an outgoing call: " + number + ", serviceId: " + serviceId);
let deferred = Promise.defer();
let call = telephony.dial(number, serviceId);
ok(call);
is(call.number, number);
is(call.state, "dialing");
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
call.onalerting = function onalerting(event) {
call.onalerting = null;
log("Received 'onalerting' call event.");
is(call.serviceId, serviceId);
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
call.onalerting = function onalerting(event) {
call.onalerting = null;
log("Received 'onalerting' call event.");
is(call.serviceId, serviceId);
checkEventCallState(event, call, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -11,28 +11,31 @@ let calls;
function dial() {
log("Make an emergency call.");
outgoing = telephony.dialEmergency(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dialEmergency(number).then(call => {
outgoing = call;
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);
is(outgoing, telephony.active);
//ok(telephony.calls === calls); // bug 717414
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
is(outgoing.emergency, true);
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -5,37 +5,23 @@ MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
let number = "not a valid emergency number";
let outgoing;
let calls;
function dial() {
log("Make an outgoing call to an invalid number.");
outgoing = telephony.dialEmergency(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dialEmergency(number).then(null, cause => {
log("Received promise 'reject'");
is(outgoing, telephony.active);
//ok(telephony.calls === calls); // bug 717414
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onerror = function onerror(event) {
log("Received 'error' event.");
is(event.call, outgoing);
ok(event.call.error);
is(event.call.error.name, "BadNumberError");
is(telephony.calls.length, 0);
is(telephony.active, null);
is(telephony.calls.length, 0);
is(cause, "BadNumberError");
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
is(result[0], "OK");
cleanUp();
});
};
});
}
function cleanUp() {

View File

@ -26,28 +26,30 @@ function createGoldenCallListResult0(number, state) {
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(call => {
outgoing = call;
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
is(outgoing.emergency, emergency);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
is(outgoing.emergency, emergency);
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], createGoldenCallListResult0(number, "ringing"));
is(result[1], "OK");
answer();
});
};
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], createGoldenCallListResult0(number, "ringing"));
is(result[1], "OK");
answer();
});
};
});
}
function answer() {

View File

@ -12,27 +12,29 @@ let gotOriginalConnected = false;
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -12,27 +12,29 @@ let gotOriginalConnected = false;
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -96,28 +96,30 @@ function holdCall() {
function dial() {
log("Making an outgoing call (while have one call already held).");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 2);
is(telephony.calls[0], incomingCall);
is(telephony.calls[1], outgoingCall);
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 2);
is(telephony.calls[0], incomingCall);
is(telephony.calls[1], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("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();
});
};
emulator.run("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

@ -109,29 +109,31 @@ function holdCall(){
function dial() {
log("Making an outgoing call (while have one call already held).");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 2);
is(telephony.calls[0], incomingCall);
is(telephony.calls[1], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 2);
is(telephony.calls[0], incomingCall);
is(telephony.calls[1], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("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();
});
};
emulator.run("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

@ -11,28 +11,30 @@ let calls;
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(call => {
outgoing = call;
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);
is(outgoing, telephony.active);
//ok(telephony.calls === calls); // bug 717414
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -10,28 +10,30 @@ let outNumber = "5555551111";
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -30,19 +30,19 @@ function dial(number) {
log("Make an outgoing call.");
let deferred = Promise.defer();
let call = telephony.dial(number);
telephony.dial(number).then(call => {
ok(call);
is(call.number, number);
is(call.state, "dialing");
ok(call);
is(call.number, number);
is(call.state, "dialing");
call.onalerting = function(event) {
log("Received 'onalerting' call event.");
call.onalerting = null;
is(call, event.call);
is(call.state, "alerting");
deferred.resolve(call);
};
call.onalerting = function(event) {
log("Received 'onalerting' call event.");
call.onalerting = null;
is(call, event.call);
is(call.state, "alerting");
deferred.resolve(call);
};
});
return deferred.promise;
}

View File

@ -7,30 +7,36 @@ MARIONETTE_HEAD_JS = 'head.js';
let number = "****5555552368****";
let outgoing;
function dial() {
log("Make an outgoing call to an invalid number.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
// Note: The number is valid from the view of phone and the call could be
// dialed out successfully. However, it will later receive the BadNumberError
// from network side.
telephony.dial(number).then(call => {
outgoing = call;
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onerror = function onerror(event) {
log("Received 'error' event.");
is(event.call, outgoing);
ok(event.call.error);
is(event.call.error.name, "BadNumberError");
outgoing.onerror = function onerror(event) {
log("Received 'error' event.");
is(event.call, outgoing);
ok(event.call.error);
is(event.call.error.name, "BadNumberError");
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
is(result[0], "OK");
cleanUp();
});
};
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
is(result[0], "OK");
cleanUp();
});
};
});
}
function cleanUp() {

View File

@ -10,27 +10,29 @@ let outgoing;
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(call => {
outgoing = call;
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
busy();
});
};
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
busy();
});
};
});
}
function busy() {

View File

@ -46,27 +46,29 @@ function setRadioEnabled(enabled, callback) {
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(call => {
outgoing = call;
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -11,25 +11,27 @@ let calls;
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(call => {
outgoing = call;
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);
is(outgoing, telephony.active);
//ok(telephony.calls === calls); // bug 717414
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
hangUp();
});
};
outgoing.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
hangUp();
});
};
});
}
function hangUp() {

View File

@ -11,27 +11,29 @@ let calls;
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
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);
telephony.dial(number).then(call => {
outgoing = call;
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);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -11,27 +11,29 @@ let outgoingCall;
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(number);
ok(outgoingCall);
is(outgoingCall.number, number);
is(outgoingCall.state, "dialing");
telephony.dial(number).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, number);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -10,31 +10,33 @@ let outNumber = "5555551111";
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
outgoingCall.onstatechange = function statechangering(event) {
log("Received 'onstatechange' call event.");
outgoingCall.onstatechange = function statechangering(event) {
log("Received 'onstatechange' call event.");
is(outgoingCall, event.call);
let expectedStates = ["dialing", "alerting"];
ok(expectedStates.indexOf(event.call.state) != -1);
is(outgoingCall, event.call);
let expectedStates = ["dialing", "alerting"];
ok(expectedStates.indexOf(event.call.state) != -1);
if (event.call.state == "alerting") {
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
}
};
if (event.call.state == "alerting") {
emulator.run("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

@ -5,7 +5,6 @@ MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
let connection;
let outgoing;
function receivedPending(received, pending, nextAction) {
let index = pending.indexOf(received);
@ -50,21 +49,13 @@ function dial(number) {
is(telephony.calls.length, 0);
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(null, cause => {
log("Received promise 'reject'");
is(telephony.active, outgoing);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onerror = function onerror(event) {
log("Received 'error' event.");
is(event.call, outgoing);
ok(event.call.error);
is(event.call.error.name, "RadioNotAvailable");
is(telephony.active, null);
is(telephony.calls.length, 0);
is(cause, "RadioNotAvailable");
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
@ -72,7 +63,7 @@ function dial(number) {
setRadioEnabled(true, cleanUp);
});
};
});
}
function cleanUp() {

View File

@ -10,27 +10,29 @@ let outgoing;
function dial() {
log("Make an outgoing call.");
outgoing = telephony.dial(number);
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
telephony.dial(number).then(call => {
outgoing = call;
ok(outgoing);
is(outgoing.number, number);
is(outgoing.state, "dialing");
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
is(outgoing, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoing);
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
outgoing.onalerting = function onalerting(event) {
log("Received 'onalerting' call event.");
is(outgoing, event.call);
is(outgoing.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
reject();
});
};
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + number + " : ringing");
is(result[1], "OK");
reject();
});
};
});
}
function reject() {

View File

@ -9,28 +9,30 @@ let outgoingCall;
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("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

@ -14,27 +14,29 @@ let gotConnected = false;
function dial() {
log("Make an outgoing call.");
outgoingCall = telephony.dial(outNumber);
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
telephony.dial(outNumber).then(call => {
outgoingCall = call;
ok(outgoingCall);
is(outgoingCall.number, outNumber);
is(outgoingCall.state, "dialing");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
outgoingCall.onalerting = function onalerting(event) {
log("Received 'alerting' call event.");
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
is(outgoingCall, event.call);
is(outgoingCall.state, "alerting");
is(outgoingCall, telephony.active);
is(telephony.calls.length, 1);
is(telephony.calls[0], outgoingCall);
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
emulator.run("gsm list", function(result) {
log("Call list is now: " + result);
is(result[0], "outbound to " + outNumber + " : ringing");
is(result[1], "OK");
answer();
});
};
});
}
function answer() {