Bug 976182 - Handle initial ICE connection state failed in tests properly. r=bwc

This commit is contained in:
Nils Ohlmeier [:drno] 2014-03-04 13:51:37 -05:00
parent a723213786
commit 28b46667af
2 changed files with 27 additions and 10 deletions

View File

@ -1449,7 +1449,7 @@ PeerConnectionWrapper.prototype = {
/**
* Returns if the ICE the connection state is "connected".
*
* @returns {boolean} True is the connection state is "connected", otherwise false.
* @returns {boolean} True if the connection state is "connected", otherwise false.
*/
isIceConnected : function PCW_isIceConnected() {
info("iceConnectionState: " + this.iceConnectionState);
@ -1459,7 +1459,7 @@ PeerConnectionWrapper.prototype = {
/**
* Returns if the ICE the connection state is "checking".
*
* @returns {boolean} True is the connection state is "checking", otherwise false.
* @returns {boolean} True if the connection state is "checking", otherwise false.
*/
isIceChecking : function PCW_isIceChecking() {
return this.iceConnectionState === "checking";
@ -1468,12 +1468,23 @@ PeerConnectionWrapper.prototype = {
/**
* Returns if the ICE the connection state is "new".
*
* @returns {boolean} True is the connection state is "new", otherwise false.
* @returns {boolean} True if the connection state is "new", otherwise false.
*/
isIceNew : function PCW_isIceNew() {
return this.iceConnectionState === "new";
},
/**
* Checks if the ICE connection state still waits for a connection to get
* established.
*
* @returns {boolean} True if the connection state is "checking" or "new",
* otherwise false.
*/
isIceConnectionPending : function PCW_isIceConnectionPending() {
return (this.isIceChecking() || this.isIceNew());
},
/**
* Registers a callback for the ICE connection state change and
* reports success (=connected) or failure via the callbacks.
@ -1494,7 +1505,7 @@ PeerConnectionWrapper.prototype = {
if (self.isIceConnected()) {
delete self.ice_connection_callbacks["waitForIceConnected"];
mySuccess();
} else if (! (self.isIceChecking() || self.isIceNew())) {
} else if (! self.isIceConnectionPending()) {
delete self.ice_connection_callbacks["waitForIceConnected"];
myFailure();
}

View File

@ -143,19 +143,22 @@ var commandsPeerConnection = [
var myPc = myTest.pcLocal;
function onIceConnectedSuccess () {
ok(true, "pc_local: ICE switched to connected state");
ok(true, "pc_local: ICE switched to 'connected' state");
myTest.next();
};
function onIceConnectedFailed () {
ok(false, "pc_local: ICE failed to switch to connected");
ok(false, "pc_local: ICE failed to switch to 'connected' state: " + myPc.iceConnectionState());
myTest.next();
};
if (myPc.isIceConnected()) {
ok(true, "pc_local: ICE is in connected state");
myTest.next();
} else {
} else if (myPc.isIceConnectionPending()) {
myPc.waitForIceConnected(onIceConnectedSuccess, onIceConnectedFailed);
} else {
ok(false, "pc_local: ICE is already in bad state: " + myPc.iceConnectionState());
myTest.next();
}
}
],
@ -166,19 +169,22 @@ var commandsPeerConnection = [
var myPc = myTest.pcRemote;
function onIceConnectedSuccess () {
ok(true, "pc_remote: ICE switched to connected state");
ok(true, "pc_remote: ICE switched to 'connected' state");
myTest.next();
};
function onIceConnectedFailed () {
ok(false, "pc_remote: ICE failed to switch to connected");
ok(false, "pc_remote: ICE failed to switch to 'connected' state: " + myPc.iceConnectionState());
myTest.next();
};
if (myPc.isIceConnected()) {
ok(true, "pc_remote: ICE is in connected state");
myTest.next();
} else {
} else if (myPc.isIceConnectionPending()) {
myPc.waitForIceConnected(onIceConnectedSuccess, onIceConnectedFailed);
} else {
ok(false, "pc_remote: ICE is already in bad state: " + myPc.iceConnectionState());
myTest.next();
}
}
],