mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 756607 - Rewrite telephony tests. r=jgriffin
This commit is contained in:
parent
76819c05f9
commit
3154432d88
@ -3,7 +3,13 @@ b2g = true
|
||||
browser = false
|
||||
qemu = true
|
||||
|
||||
[test_dial_answer.py]
|
||||
[test_dial_between_emulators.py]
|
||||
[test_dial_listeners.py]
|
||||
|
||||
[test_incoming_answer_hangup.js]
|
||||
[test_incoming_reject.js]
|
||||
[test_outgoing_answer_hangup.js]
|
||||
# Bug 759521
|
||||
#[test_outgoing_badNumber.js]
|
||||
#expectedfailure = true
|
||||
#[test_outgoing_busy.js]
|
||||
#expectedfailure = true
|
||||
#[test_outgoing_reject.js]
|
||||
#expectedfailure = true
|
||||
|
@ -1,90 +0,0 @@
|
||||
from marionette_test import *
|
||||
|
||||
|
||||
class MultiEmulatorDialTest(MarionetteTestCase):
|
||||
"""A simple test which verifies the ability of one emulator to dial
|
||||
another and to detect an incoming call.
|
||||
"""
|
||||
|
||||
def test_dial_answer(self):
|
||||
# Tests always have one emulator available as self.marionette; we'll
|
||||
# use this for the receiving emulator. We'll also launch a second
|
||||
# emulator to use as the sender.
|
||||
sender = self.get_new_emulator()
|
||||
receiver = self.marionette
|
||||
|
||||
self.set_up_test_page(sender, "test.html", ["dom.telephony.app.phone.url"])
|
||||
self.set_up_test_page(receiver, "test.html", ["dom.telephony.app.phone.url"])
|
||||
|
||||
# Setup the event listsener on the receiver, which should store
|
||||
# a global variable when an incoming call is received.
|
||||
self.assertTrue(receiver.execute_script("""
|
||||
return window.navigator.mozTelephony != null
|
||||
"""))
|
||||
receiver.execute_script("""
|
||||
global.incoming = null;
|
||||
window.navigator.mozTelephony.addEventListener("incoming", function test_incoming(e) {
|
||||
window.navigator.mozTelephony.removeEventListener("incoming", test_incoming);
|
||||
global.incoming = e.call;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
|
||||
# Dial the receiver from the sender.
|
||||
toPhoneNumber = "1555521%d" % receiver.emulator.port
|
||||
fromPhoneNumber = "1555521%d" % sender.emulator.port
|
||||
sender.execute_script("""
|
||||
global.call = window.navigator.mozTelephony.dial("%s");
|
||||
""" % toPhoneNumber, new_sandbox=False)
|
||||
|
||||
# On the receiver, wait up to 30s for an incoming call to be
|
||||
# detected, by checking the value of the global var that the
|
||||
# listener will change.
|
||||
receiver.set_script_timeout(30000)
|
||||
received = receiver.execute_async_script("""
|
||||
global.callstate = null;
|
||||
waitFor(function() {
|
||||
let call = global.incoming;
|
||||
call.addEventListener("connected", function test_connected(e) {
|
||||
call.removeEventListener("connected", test_connected);
|
||||
global.callstate = e.call.state;
|
||||
});
|
||||
marionetteScriptFinished(call.number);
|
||||
},
|
||||
function() {
|
||||
return global.incoming != null;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
# Verify the phone number of the incoming call.
|
||||
self.assertEqual(received, fromPhoneNumber)
|
||||
|
||||
# On the sender, add a listener to verify that the call changes
|
||||
# state to connected when it's answered.
|
||||
sender.execute_script("""
|
||||
let call = global.call;
|
||||
global.callstate = null;
|
||||
call.addEventListener("connected", function test_connected(e) {
|
||||
call.removeEventListener("connected", test_connected);
|
||||
global.callstate = e.call.state;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
|
||||
# Answer the call and verify that the callstate changes to
|
||||
# connected.
|
||||
receiver.execute_async_script("""
|
||||
global.incoming.answer();
|
||||
waitFor(function() {
|
||||
marionetteScriptFinished(true);
|
||||
}, function() {
|
||||
return global.callstate == "connected";
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
|
||||
# Verify that the callstate changes to connected on the caller as well.
|
||||
self.assertTrue(receiver.execute_async_script("""
|
||||
waitFor(function() {
|
||||
global.incoming.hangUp();
|
||||
marionetteScriptFinished(true);
|
||||
}, function() {
|
||||
return global.callstate == "connected";
|
||||
});
|
||||
""", new_sandbox=False))
|
@ -1,53 +0,0 @@
|
||||
from marionette_test import *
|
||||
|
||||
|
||||
class MultiEmulatorDialTest(MarionetteTestCase):
|
||||
"""A simple test which verifies the ability of one emulator to dial
|
||||
another and to detect an incoming call.
|
||||
"""
|
||||
|
||||
def test_dial_between_emulators(self):
|
||||
# Tests always have one emulator available as self.marionette; we'll
|
||||
# use this for the receiving emulator. We'll also launch a second
|
||||
# emulator to use as the sender.
|
||||
sender = self.get_new_emulator()
|
||||
receiver = self.marionette
|
||||
|
||||
self.set_up_test_page(sender, "test.html", ["dom.telephony.app.phone.url"])
|
||||
self.set_up_test_page(receiver, "test.html", ["dom.telephony.app.phone.url"])
|
||||
|
||||
# Setup the event listsener on the receiver, which should store
|
||||
# a global variable when an incoming call is received.
|
||||
self.assertTrue(receiver.execute_script("""
|
||||
return window.navigator.mozTelephony != undefined && window.navigator.mozTelephony != null;
|
||||
""", new_sandbox=False))
|
||||
receiver.execute_script("""
|
||||
global.incoming = null;
|
||||
window.navigator.mozTelephony.addEventListener("incoming", function(e) {
|
||||
global.incoming = e.call.number;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
|
||||
# Dial the receiver from the sender.
|
||||
toPhoneNumber = "1555521%d" % receiver.emulator.port
|
||||
fromPhoneNumber = "1555521%d" % sender.emulator.port
|
||||
sender.execute_script("""
|
||||
window.navigator.mozTelephony.dial("%s");
|
||||
""" % toPhoneNumber, new_sandbox=False)
|
||||
|
||||
# On the receiver, wait up to 10s for an incoming call to be
|
||||
# detected, by checking the value of the global var that the
|
||||
# listener will change.
|
||||
receiver.set_script_timeout(10000)
|
||||
received = receiver.execute_async_script("""
|
||||
waitFor(function () {
|
||||
marionetteScriptFinished(global.incoming);
|
||||
}, function () {
|
||||
return global.incoming;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
# Verify the phone number of the incoming call.
|
||||
self.assertEqual(received, fromPhoneNumber)
|
||||
|
||||
sender.execute_script("window.navigator.mozTelephony.calls[0].hangUp();", new_sandbox=False)
|
||||
receiver.execute_script("window.navigator.mozTelephony.calls[0].hangUp();", new_sandbox=False)
|
@ -1,150 +0,0 @@
|
||||
from marionette_test import *
|
||||
|
||||
|
||||
class DialListenerTest(MarionetteTestCase):
|
||||
"""A test of some of the different listeners for nsIDOMTelephonyCall.
|
||||
"""
|
||||
|
||||
def test_dial_listeners(self):
|
||||
# Tests always have one emulator available as self.marionette; we'll
|
||||
# use this for the receiving emulator. We'll also launch a second
|
||||
# emulator to use as the sender.
|
||||
sender = self.get_new_emulator()
|
||||
receiver = self.marionette
|
||||
|
||||
self.set_up_test_page(sender, "test.html", ["dom.telephony.app.phone.url"])
|
||||
self.set_up_test_page(receiver, "test.html", ["dom.telephony.app.phone.url"])
|
||||
|
||||
receiver.set_script_timeout(10000)
|
||||
sender.set_script_timeout(10000)
|
||||
|
||||
toPhoneNumber = "1555521%d" % receiver.emulator.port
|
||||
fromPhoneNumber = "1555521%d" % sender.emulator.port
|
||||
|
||||
# Setup the event listsener on the receiver, which should store
|
||||
# a global variable when an incoming call is received.
|
||||
self.assertTrue(receiver.execute_script("""
|
||||
return window.navigator.mozTelephony != undefined && window.navigator.mozTelephony != null;
|
||||
""", new_sandbox=False))
|
||||
receiver.execute_script("""
|
||||
global.incoming = null;
|
||||
window.navigator.mozTelephony.addEventListener("incoming", function test_incoming(e) {
|
||||
window.navigator.mozTelephony.removeEventListener("incoming", test_incoming);
|
||||
global.incoming = e.call;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
|
||||
# dial the receiver from the sender
|
||||
sender.execute_script("""
|
||||
global.sender_state = [];
|
||||
global.sender_call = window.navigator.mozTelephony.dial("%s");
|
||||
global.sender_call.addEventListener("statechange", function test_sender_statechange(e) {
|
||||
if (e.call.state == 'disconnected')
|
||||
global.sender_call.removeEventListener("statechange", test_sender_statechange);
|
||||
global.sender_state.push(e.call.state);
|
||||
});
|
||||
global.sender_alerting = false;
|
||||
global.sender_call.addEventListener("alerting", function test_sender_alerting(e) {
|
||||
global.sender_call.removeEventListener("alerting", test_sender_alerting);
|
||||
global.sender_alerting = e.call.state == 'alerting';
|
||||
});
|
||||
""" % toPhoneNumber, new_sandbox=False)
|
||||
|
||||
# On the receiver, wait up to 30s for an incoming call to be
|
||||
# detected, by checking the value of the global var that the
|
||||
# listener will change.
|
||||
received = receiver.execute_async_script("""
|
||||
global.receiver_state = [];
|
||||
waitFor(function() {
|
||||
let call = global.incoming;
|
||||
call.addEventListener("statechange", function test_statechange(e) {
|
||||
if (e.call.state == 'disconnected')
|
||||
call.removeEventListener("statechange", test_statechange);
|
||||
global.receiver_state.push(e.call.state);
|
||||
});
|
||||
call.addEventListener("connected", function test_connected(e) {
|
||||
call.removeEventListener("connected", test_connected);
|
||||
global.receiver_connected = e.call.state == 'connected';
|
||||
});
|
||||
marionetteScriptFinished(call.number);
|
||||
},
|
||||
function() {
|
||||
return global.incoming != null;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
# Verify the phone number of the incoming call.
|
||||
self.assertEqual(received, fromPhoneNumber)
|
||||
|
||||
# At this point, the sender's call should be in a 'alerting' state,
|
||||
# as reflected by both 'statechange' and 'alerting' listeners.
|
||||
self.assertTrue('alerting' in sender.execute_script("return global.sender_state;", new_sandbox=False))
|
||||
self.assertTrue(sender.execute_script("return global.sender_alerting;", new_sandbox=False))
|
||||
|
||||
# Answer the call and verify that the callstate changes to
|
||||
# connected.
|
||||
receiver.execute_async_script("""
|
||||
global.incoming.answer();
|
||||
waitFor(function() {
|
||||
marionetteScriptFinished(true);
|
||||
}, function() {
|
||||
return global.receiver_connected;
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
state = receiver.execute_script("return global.receiver_state;", new_sandbox=False)
|
||||
self.assertTrue('connecting' in state)
|
||||
self.assertTrue('connected' in state)
|
||||
|
||||
# verify that the callstate changes to connected on the caller as well
|
||||
self.assertTrue('connected' in sender.execute_async_script("""
|
||||
waitFor(function() {
|
||||
marionetteScriptFinished(global.sender_state);
|
||||
}, function() {
|
||||
return global.sender_call.state == "connected";
|
||||
});
|
||||
""", new_sandbox=False))
|
||||
|
||||
# setup listeners to detect the 'disconnected event'
|
||||
sender.execute_script("""
|
||||
global.sender_disconnected = null;
|
||||
global.sender_call.addEventListener("disconnected", function test_disconnected(e) {
|
||||
global.sender_call.removeEventListener("disconnected", test_disconnected);
|
||||
global.sender_disconnected = e.call.state == 'disconnected';
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
receiver.execute_script("""
|
||||
global.receiver_disconnected = null;
|
||||
global.incoming.addEventListener("disconnected", function test_disconnected(e) {
|
||||
global.incoming.removeEventListener("disconnected", test_disconnected);
|
||||
global.receiver_disconnected = e.call.state == 'disconnected';
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
|
||||
# hang up from the receiver's side
|
||||
receiver.execute_script("""
|
||||
global.incoming.hangUp();
|
||||
""", new_sandbox=False)
|
||||
|
||||
# Verify that the call state on the sender is 'disconnected', as
|
||||
# notified by both the 'statechange' and 'disconnected' listeners.
|
||||
sender_state = sender.execute_async_script("""
|
||||
waitFor(function() {
|
||||
marionetteScriptFinished(global.sender_state);
|
||||
}, function () {
|
||||
return global.sender_call.state == 'disconnected';
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
self.assertTrue('disconnected' in sender_state)
|
||||
self.assertTrue(sender.execute_script("return global.sender_disconnected;", new_sandbox=False))
|
||||
|
||||
# Verify that the call state on the receiver is 'disconnected', as
|
||||
# notified by both the 'statechange' and 'disconnected' listeners.
|
||||
state = receiver.execute_async_script("""
|
||||
waitFor(function() {
|
||||
marionetteScriptFinished(global.receiver_state);
|
||||
}, function () {
|
||||
return global.incoming.state == 'disconnected';
|
||||
});
|
||||
""", new_sandbox=False)
|
||||
self.assertTrue('disconnected' in state)
|
||||
self.assertTrue('disconnecting' in state)
|
||||
self.assertTrue(receiver.execute_script("return global.receiver_disconnected;", new_sandbox=False))
|
117
dom/telephony/test/marionette/test_incoming_answer_hangup.js
Normal file
117
dom/telephony/test/marionette/test_incoming_answer_hangup.js
Normal file
@ -0,0 +1,117 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
const WHITELIST_PREF = "dom.telephony.app.phone.url";
|
||||
SpecialPowers.setCharPref(WHITELIST_PREF, window.location.href);
|
||||
|
||||
let telephony = window.navigator.mozTelephony;
|
||||
let number = "5555552368";
|
||||
let incoming;
|
||||
let calls;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
ok(telephony);
|
||||
is(telephony.active, null);
|
||||
ok(telephony.calls);
|
||||
is(telephony.calls.length, 0);
|
||||
calls = telephony.calls;
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
simulateIncoming();
|
||||
});
|
||||
}
|
||||
|
||||
function simulateIncoming() {
|
||||
log("Simulating an incoming call.");
|
||||
|
||||
telephony.onincoming = function onincoming(event) {
|
||||
log("Received 'incoming' call event.");
|
||||
incoming = event.call;
|
||||
ok(incoming);
|
||||
is(incoming.number, number);
|
||||
is(incoming.state, "incoming");
|
||||
|
||||
//is(incoming, telephony.active); // bug 757587
|
||||
//ok(telephony.calls === calls); // bug 757587
|
||||
//is(calls.length, 1); // bug 757587
|
||||
//is(calls[0], incoming); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "inbound from " + number + " : incoming");
|
||||
is(result[1], "OK");
|
||||
answer();
|
||||
});
|
||||
};
|
||||
runEmulatorCmd("gsm call " + number);
|
||||
}
|
||||
|
||||
function answer() {
|
||||
log("Answering the incoming call.");
|
||||
|
||||
let gotConnecting = false;
|
||||
incoming.onconnecting = function onconnecting(event) {
|
||||
log("Received 'connecting' call event.");
|
||||
is(incoming, event.call);
|
||||
is(incoming.state, "connecting");
|
||||
gotConnecting = true;
|
||||
};
|
||||
|
||||
incoming.onconnected = function onconnected(event) {
|
||||
log("Received 'connected' call event.");
|
||||
is(incoming, event.call);
|
||||
is(incoming.state, "connected");
|
||||
ok(gotConnecting);
|
||||
|
||||
//is(incoming, telephony.active); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "inbound from " + number + " : active");
|
||||
is(result[1], "OK");
|
||||
hangUp();
|
||||
});
|
||||
};
|
||||
incoming.answer();
|
||||
};
|
||||
|
||||
function hangUp() {
|
||||
log("Hanging up the incoming call.");
|
||||
|
||||
let gotDisconnecting = false;
|
||||
incoming.ondisconnecting = function ondisconnecting(event) {
|
||||
log("Received 'disconnecting' call event.");
|
||||
is(incoming, event.call);
|
||||
is(incoming.state, "disconnecting");
|
||||
gotDisconnecting = true;
|
||||
};
|
||||
|
||||
incoming.ondisconnected = function ondisconnected(event) {
|
||||
log("Received 'disconnected' call event.");
|
||||
is(incoming, event.call);
|
||||
is(incoming.state, "disconnected");
|
||||
ok(gotDisconnecting);
|
||||
|
||||
//is(telephony.active, null); // bug 757587
|
||||
is(telephony.calls.length, 0);
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "OK");
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
incoming.hangUp();
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.clearUserPref(WHITELIST_PREF);
|
||||
finish();
|
||||
}
|
||||
|
||||
verifyInitialState();
|
88
dom/telephony/test/marionette/test_incoming_reject.js
Normal file
88
dom/telephony/test/marionette/test_incoming_reject.js
Normal file
@ -0,0 +1,88 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
const WHITELIST_PREF = "dom.telephony.app.phone.url";
|
||||
SpecialPowers.setCharPref(WHITELIST_PREF, window.location.href);
|
||||
|
||||
let telephony = window.navigator.mozTelephony;
|
||||
let number = "5555552368";
|
||||
let incoming;
|
||||
let calls;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
ok(telephony);
|
||||
is(telephony.active, null);
|
||||
ok(telephony.calls);
|
||||
is(telephony.calls.length, 0);
|
||||
calls = telephony.calls;
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
simulateIncoming();
|
||||
});
|
||||
}
|
||||
|
||||
function simulateIncoming() {
|
||||
log("Simulating an incoming call.");
|
||||
|
||||
telephony.onincoming = function onincoming(event) {
|
||||
log("Received 'incoming' call event.");
|
||||
incoming = event.call;
|
||||
ok(incoming);
|
||||
is(incoming.number, number);
|
||||
is(incoming.state, "incoming");
|
||||
|
||||
//is(incoming, telephony.active); // bug 757587
|
||||
//ok(telephony.calls === calls); // bug 757587
|
||||
//is(calls.length, 1); // bug 757587
|
||||
//is(calls[0], incoming); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "inbound from " + number + " : incoming");
|
||||
is(result[1], "OK");
|
||||
reject();
|
||||
});
|
||||
};
|
||||
runEmulatorCmd("gsm call " + number);
|
||||
}
|
||||
|
||||
function reject() {
|
||||
log("Reject the incoming call.");
|
||||
|
||||
let gotDisconnecting = false;
|
||||
incoming.ondisconnecting = function ondisconnecting(event) {
|
||||
log("Received 'disconnecting' call event.");
|
||||
is(incoming, event.call);
|
||||
is(incoming.state, "disconnecting");
|
||||
gotDisconnecting = true;
|
||||
};
|
||||
|
||||
incoming.ondisconnected = function ondisconnected(event) {
|
||||
log("Received 'disconnected' call event.");
|
||||
is(incoming, event.call);
|
||||
is(incoming.state, "disconnected");
|
||||
ok(gotDisconnecting);
|
||||
|
||||
//is(telephony.active, null); // bug 757587
|
||||
is(telephony.calls.length, 0);
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "OK");
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
incoming.hangUp();
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.clearUserPref(WHITELIST_PREF);
|
||||
finish();
|
||||
}
|
||||
|
||||
verifyInitialState();
|
99
dom/telephony/test/marionette/test_outgoing_answer_hangup.js
Normal file
99
dom/telephony/test/marionette/test_outgoing_answer_hangup.js
Normal file
@ -0,0 +1,99 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
const WHITELIST_PREF = "dom.telephony.app.phone.url";
|
||||
SpecialPowers.setCharPref(WHITELIST_PREF, window.location.href);
|
||||
|
||||
let telephony = window.navigator.mozTelephony;
|
||||
let number = "5555552368";
|
||||
let outgoing;
|
||||
let calls;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
ok(telephony);
|
||||
is(telephony.active, null);
|
||||
ok(telephony.calls);
|
||||
is(telephony.calls.length, 0);
|
||||
calls = telephony.calls;
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
dial();
|
||||
});
|
||||
}
|
||||
|
||||
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); // bug 757587
|
||||
//ok(telephony.calls === calls); // bug 757587
|
||||
//is(calls.length, 1); // bug 757587
|
||||
//is(calls[0], outgoing); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "outbound to " + number + " : unknown");
|
||||
is(result[1], "OK");
|
||||
answer();
|
||||
});
|
||||
}
|
||||
|
||||
function answer() {
|
||||
log("Answering the outgoing call.");
|
||||
|
||||
// We get no "connecting" event when the remote party answers the call.
|
||||
|
||||
outgoing.onconnected = function onconnected(event) {
|
||||
log("Received 'connected' call event.");
|
||||
is(outgoing, event.call);
|
||||
is(outgoing.state, "connected");
|
||||
|
||||
//is(outgoing, telephony.active); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "outbound to " + number + " : active");
|
||||
is(result[1], "OK");
|
||||
hangUp();
|
||||
});
|
||||
};
|
||||
runEmulatorCmd("gsm accept " + number);
|
||||
};
|
||||
|
||||
function hangUp() {
|
||||
log("Hanging up the outgoing call.");
|
||||
|
||||
// We get no "disconnecting" event when the remote party terminates the call.
|
||||
|
||||
outgoing.ondisconnected = function ondisconnected(event) {
|
||||
log("Received 'disconnected' call event.");
|
||||
is(outgoing, event.call);
|
||||
is(outgoing.state, "disconnected");
|
||||
|
||||
//is(telephony.active, null); // bug 757587
|
||||
is(telephony.calls.length, 0);
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "OK");
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
runEmulatorCmd("gsm cancel " + number);
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.clearUserPref(WHITELIST_PREF);
|
||||
finish();
|
||||
}
|
||||
|
||||
verifyInitialState();
|
61
dom/telephony/test/marionette/test_outgoing_badNumber.js
Normal file
61
dom/telephony/test/marionette/test_outgoing_badNumber.js
Normal file
@ -0,0 +1,61 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
const WHITELIST_PREF = "dom.telephony.app.phone.url";
|
||||
SpecialPowers.setCharPref(WHITELIST_PREF, window.location.href);
|
||||
|
||||
let telephony = window.navigator.mozTelephony;
|
||||
let number = "not a valid phone number";
|
||||
let outgoing;
|
||||
let calls;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
ok(telephony);
|
||||
is(telephony.active, null);
|
||||
ok(telephony.calls);
|
||||
is(telephony.calls.length, 0);
|
||||
calls = telephony.calls;
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
dial();
|
||||
});
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
//is(outgoing, telephony.active); // bug 757587
|
||||
//ok(telephony.calls === calls); // bug 757587
|
||||
//is(calls.length, 1); // bug 757587
|
||||
//is(calls[0], outgoing); // bug 757587
|
||||
|
||||
outgoing.onerror = function onerror(event) {
|
||||
log("Received 'error' event.");
|
||||
is(event.call, outgoing);
|
||||
ok(call.error);
|
||||
is(call.error.name, "BadNumberError");
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.clearUserPref(WHITELIST_PREF);
|
||||
finish();
|
||||
}
|
||||
|
||||
verifyInitialState();
|
78
dom/telephony/test/marionette/test_outgoing_busy.js
Normal file
78
dom/telephony/test/marionette/test_outgoing_busy.js
Normal file
@ -0,0 +1,78 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
const WHITELIST_PREF = "dom.telephony.app.phone.url";
|
||||
SpecialPowers.setCharPref(WHITELIST_PREF, window.location.href);
|
||||
|
||||
let telephony = window.navigator.mozTelephony;
|
||||
let number = "5555552368";
|
||||
let outgoing;
|
||||
let calls;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
ok(telephony);
|
||||
is(telephony.active, null);
|
||||
ok(telephony.calls);
|
||||
is(telephony.calls.length, 0);
|
||||
calls = telephony.calls;
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
dial();
|
||||
});
|
||||
}
|
||||
|
||||
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); // bug 757587
|
||||
//ok(telephony.calls === calls); // bug 757587
|
||||
//is(calls.length, 1); // bug 757587
|
||||
//is(calls[0], outgoing); // bug 757587
|
||||
|
||||
outgoing.onstatechange = function onstatechange(event) {
|
||||
log("outgoing call state: " + outgoing.state);
|
||||
};
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "outbound to " + number + " : unknown");
|
||||
is(result[1], "OK");
|
||||
busy();
|
||||
});
|
||||
}
|
||||
|
||||
function busy() {
|
||||
log("The receiver is busy.");
|
||||
|
||||
outgoing.onbusy = function onbusy(event) {
|
||||
log("Received 'busy' call event.");
|
||||
is(outgoing, event.call);
|
||||
is(outgoing.state, "busy");
|
||||
|
||||
//is(outgoing, telephony.active); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "OK");
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
runEmulatorCmd("gsm busy " + number);
|
||||
};
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.clearUserPref(WHITELIST_PREF);
|
||||
finish();
|
||||
}
|
||||
|
||||
verifyInitialState();
|
77
dom/telephony/test/marionette/test_outgoing_reject.js
Normal file
77
dom/telephony/test/marionette/test_outgoing_reject.js
Normal file
@ -0,0 +1,77 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
const WHITELIST_PREF = "dom.telephony.app.phone.url";
|
||||
SpecialPowers.setCharPref(WHITELIST_PREF, window.location.href);
|
||||
|
||||
let telephony = window.navigator.mozTelephony;
|
||||
let number = "5555552368";
|
||||
let outgoing;
|
||||
let calls;
|
||||
|
||||
function verifyInitialState() {
|
||||
log("Verifying initial state.");
|
||||
ok(telephony);
|
||||
is(telephony.active, null);
|
||||
ok(telephony.calls);
|
||||
is(telephony.calls.length, 0);
|
||||
calls = telephony.calls;
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Initial call list: " + result);
|
||||
is(result[0], "OK");
|
||||
dial();
|
||||
});
|
||||
}
|
||||
|
||||
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); // bug 757587
|
||||
//ok(telephony.calls === calls); // bug 757587
|
||||
//is(calls.length, 1); // bug 757587
|
||||
//is(calls[0], outgoing); // bug 757587
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "outbound to " + number + " : unknown");
|
||||
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) {
|
||||
log("Received 'disconnected' call event.");
|
||||
is(outgoing, event.call);
|
||||
is(outgoing.state, "disconnected");
|
||||
|
||||
//is(telephony.active, null); // bug 757587
|
||||
is(telephony.calls.length, 0);
|
||||
|
||||
runEmulatorCmd("gsm list", function(result) {
|
||||
log("Call list is now: " + result);
|
||||
is(result[0], "OK");
|
||||
cleanUp();
|
||||
});
|
||||
};
|
||||
runEmulatorCmd("gsm cancel " + number);
|
||||
};
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.clearUserPref(WHITELIST_PREF);
|
||||
finish();
|
||||
}
|
||||
|
||||
verifyInitialState();
|
Loading…
Reference in New Issue
Block a user