зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1010641 - verify signaling state transitions. r=bwc
This commit is contained in:
Родитель
8ae7798ac7
Коммит
cb92ecddc0
|
@ -18,6 +18,15 @@ const iceStateTransitions = {
|
|||
"closed": []
|
||||
}
|
||||
|
||||
const signalingStateTransitions = {
|
||||
"stable": ["have-local-offer", "have-remote-offer", "closed"],
|
||||
"have-local-offer": ["have-remote-pranswer", "stable", "closed", "have-local-offer"],
|
||||
"have-remote-pranswer": ["stable", "closed", "have-remote-pranswer"],
|
||||
"have-remote-offer": ["have-local-pranswer", "stable", "closed", "have-remote-offer"],
|
||||
"have-local-pranswer": ["stable", "closed", "have-local-pranswer"],
|
||||
"closed": []
|
||||
}
|
||||
|
||||
/**
|
||||
* This class mimics a state machine and handles a list of commands by
|
||||
* executing them synchronously.
|
||||
|
@ -1319,7 +1328,6 @@ function PeerConnectionWrapper(label, configuration) {
|
|||
|
||||
info("Creating " + this);
|
||||
this._pc = new mozRTCPeerConnection(this.configuration);
|
||||
is(this._pc.iceConnectionState, "new", "iceConnectionState starts at 'new'");
|
||||
|
||||
/**
|
||||
* Setup callback handlers
|
||||
|
@ -1342,8 +1350,6 @@ function PeerConnectionWrapper(label, configuration) {
|
|||
self.next_ice_state = "";
|
||||
}
|
||||
};
|
||||
this.ondatachannel = unexpectedEventAndFinish(this, 'ondatachannel');
|
||||
this.onsignalingstatechange = unexpectedEventAndFinish(this, 'onsignalingstatechange');
|
||||
|
||||
/**
|
||||
* Callback for native peer connection 'onaddstream' events.
|
||||
|
@ -1371,6 +1377,8 @@ function PeerConnectionWrapper(label, configuration) {
|
|||
});
|
||||
};
|
||||
|
||||
this.ondatachannel = unexpectedEventAndFinish(this, 'ondatachannel');
|
||||
|
||||
/**
|
||||
* Callback for native peer connection 'ondatachannel' events. If no custom handler
|
||||
* has been specified via 'this.ondatachannel', a failure will be raised if an
|
||||
|
@ -1386,6 +1394,9 @@ function PeerConnectionWrapper(label, configuration) {
|
|||
self.ondatachannel = unexpectedEventAndFinish(self, 'ondatachannel');
|
||||
};
|
||||
|
||||
this.onsignalingstatechange = unexpectedEventAndFinish(this, 'onsignalingstatechange');
|
||||
this.signalingStateCallbacks = {};
|
||||
|
||||
/**
|
||||
* Callback for native peer connection 'onsignalingstatechange' events. If no
|
||||
* custom handler has been specified via 'this.onsignalingstatechange', a
|
||||
|
@ -1394,12 +1405,15 @@ function PeerConnectionWrapper(label, configuration) {
|
|||
* @param {Object} aEvent
|
||||
* Event data which includes the newly created data channel
|
||||
*/
|
||||
this._pc.onsignalingstatechange = function (aEvent) {
|
||||
this._pc.onsignalingstatechange = function (anEvent) {
|
||||
info(self + ": 'onsignalingstatechange' event fired");
|
||||
|
||||
Object.keys(self.signalingStateCallbacks).forEach(function(name) {
|
||||
self.signalingStateCallbacks[name](anEvent);
|
||||
});
|
||||
// this calls the eventhandler only once and then overwrites it with the
|
||||
// default unexpectedEvent handler
|
||||
self.onsignalingstatechange(aEvent);
|
||||
self.onsignalingstatechange(anEvent);
|
||||
self.onsignalingstatechange = unexpectedEventAndFinish(self, 'onsignalingstatechange');
|
||||
};
|
||||
}
|
||||
|
@ -1661,6 +1675,28 @@ PeerConnectionWrapper.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers a callback for the signaling state change and
|
||||
* appends the new state to an array for logging it later.
|
||||
*/
|
||||
logSignalingState: function PCW_logSignalingState() {
|
||||
var self = this;
|
||||
|
||||
function _logSignalingState(state) {
|
||||
var newstate = self._pc.signalingState;
|
||||
var oldstate = self.signalingStateLog[self.signalingStateLog.length - 1]
|
||||
if (Object.keys(signalingStateTransitions).indexOf(oldstate) != -1) {
|
||||
ok(signalingStateTransitions[oldstate].indexOf(newstate) != -1, self + ": legal signaling state transition from " + oldstate + " to " + newstate);
|
||||
} else {
|
||||
ok(false, self + ": old signaling state " + oldstate + " missing in signaling transition array");
|
||||
}
|
||||
self.signalingStateLog.push(newstate);
|
||||
}
|
||||
|
||||
self.signalingStateLog = [self._pc.signalingState];
|
||||
self.signalingStateCallbacks.logSignalingStatus = _logSignalingState;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an ICE candidate and automatically handles the failure case.
|
||||
*
|
||||
|
@ -1748,11 +1784,11 @@ PeerConnectionWrapper.prototype = {
|
|||
var newstate = self._pc.iceConnectionState;
|
||||
var oldstate = self.iceConnectionLog[self.iceConnectionLog.length - 1]
|
||||
if (Object.keys(iceStateTransitions).indexOf(oldstate) != -1) {
|
||||
ok(iceStateTransitions[oldstate].indexOf(newstate) != -1, "Legal ICE state transition from " + oldstate + " to " + newstate);
|
||||
ok(iceStateTransitions[oldstate].indexOf(newstate) != -1, self + ": legal ICE state transition from " + oldstate + " to " + newstate);
|
||||
} else {
|
||||
ok(false, "Old ICE state " + oldstate + " missing in ICE transition array");
|
||||
ok(false, self + ": old ICE state " + oldstate + " missing in ICE transition array");
|
||||
}
|
||||
self.iceConnectionLog.push(self._pc.iceConnectionState);
|
||||
self.iceConnectionLog.push(newstate);
|
||||
}
|
||||
|
||||
self.iceConnectionLog = [self._pc.iceConnectionState];
|
||||
|
|
|
@ -7,6 +7,8 @@ var HAVE_LOCAL_OFFER = "have-local-offer";
|
|||
var HAVE_REMOTE_OFFER = "have-remote-offer";
|
||||
var CLOSED = "closed";
|
||||
|
||||
const ICE_NEW = "new";
|
||||
|
||||
function deltaSeconds(date1, date2) {
|
||||
return (date2.getTime() - date1.getTime())/1000;
|
||||
}
|
||||
|
@ -44,6 +46,34 @@ function dumpSdp(test) {
|
|||
}
|
||||
|
||||
var commandsPeerConnection = [
|
||||
[
|
||||
'PC_LOCAL_SETUP_ICE_LOGGER',
|
||||
function (test) {
|
||||
test.pcLocal.logIceConnectionState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_ICE_LOGGER',
|
||||
function (test) {
|
||||
test.pcRemote.logIceConnectionState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SETUP_SIGNALING_LOGGER',
|
||||
function (test) {
|
||||
test.pcLocal.logSignalingState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_SIGNALING_LOGGER',
|
||||
function (test) {
|
||||
test.pcRemote.logSignalingState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_GUM',
|
||||
function (test) {
|
||||
|
@ -77,16 +107,18 @@ var commandsPeerConnection = [
|
|||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SETUP_ICE_LOGGER',
|
||||
'PC_LOCAL_CHECK_INITIAL_ICE_STATE',
|
||||
function (test) {
|
||||
test.pcLocal.logIceConnectionState();
|
||||
is(test.pcLocal.iceConnectionState, ICE_NEW,
|
||||
"Initial local ICE connection state is 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_ICE_LOGGER',
|
||||
'PC_REMOTE_CHECK_INITIAL_ICE_STATE',
|
||||
function (test) {
|
||||
test.pcRemote.logIceConnectionState();
|
||||
is(test.pcRemote.iceConnectionState, ICE_NEW,
|
||||
"Initial remote ICE connection state is 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
|
@ -309,6 +341,34 @@ var commandsPeerConnection = [
|
|||
* Default list of commands to execute for a Datachannel test.
|
||||
*/
|
||||
var commandsDataChannel = [
|
||||
[
|
||||
'PC_LOCAL_SETUP_ICE_LOGGER',
|
||||
function (test) {
|
||||
test.pcLocal.logIceConnectionState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_ICE_LOGGER',
|
||||
function (test) {
|
||||
test.pcRemote.logIceConnectionState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SETUP_SIGNALING_LOGGER',
|
||||
function (test) {
|
||||
test.pcLocal.logSignalingState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_SIGNALING_LOGGER',
|
||||
function (test) {
|
||||
test.pcRemote.logSignalingState();
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_GUM',
|
||||
function (test) {
|
||||
|
@ -326,9 +386,10 @@ var commandsDataChannel = [
|
|||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SETUP_ICE_LOGGER',
|
||||
'PC_LOCAL_CHECK_INITIAL_ICE_STATE',
|
||||
function (test) {
|
||||
test.pcLocal.logIceConnectionState();
|
||||
is(test.pcLocal.iceConnectionState, ICE_NEW,
|
||||
"Initial local ICE connection state is 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
|
@ -349,9 +410,10 @@ var commandsDataChannel = [
|
|||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_ICE_LOGGER',
|
||||
'PC_REMOTE_CHECK_INITIAL_ICE_STATE',
|
||||
function (test) {
|
||||
test.pcRemote.logIceConnectionState();
|
||||
is(test.pcRemote.iceConnectionState, ICE_NEW,
|
||||
"Initial remote ICE connection state is 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
|
|
Загрузка…
Ссылка в новой задаче