Added conformance tests.

BUG=

Review URL: https://webrtc-codereview.appspot.com/929030

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3179 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org
2012-11-28 13:03:17 +00:00
parent 8d334d387b
commit 7d74bdbeac
2 changed files with 446 additions and 0 deletions

View File

@ -0,0 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
To quickly iterate when developing this test, make sure you select
'Always allow this site to use this webcam' option in the dropdown menu of
Chrome when it's requesting access to your webcam.
Notice that this requires the site you're browsing to use HTTPS.
Without that, the test might timeout before you have had the chance to accept
access to the webcam.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PeerConnection Connection Test</title>
<script src="https://w3c-test.org/resources/testharness.js"></script>
<script type="text/javascript">
var test = async_test('Can set up a basic WebRTC call.', {timeout: 5000});
var gFirstConnection = null;
var gSecondConnection = null;
var getUserMediaFailedCallback = test.step_func(function(error) {
assert_unreached('Should not get an error callback');
});
function getUserMediaOkCallback(localStream) {
gFirstConnection = new webkitRTCPeerConnection(null, null);
gFirstConnection.onicecandidate = onIceCandidateToFirst;
gFirstConnection.addStream(localStream);
gFirstConnection.createOffer(onOfferCreated);
};
var onOfferCreated = test.step_func(function(offer) {
gFirstConnection.setLocalDescription(offer);
// This would normally go across the application's signaling solution.
// In our case, the "signaling" is to call this function.
receiveCall(offer.sdp);
});
var receiveCall = test.step_func(function(offerSdp) {
gSecondConnection = new webkitRTCPeerConnection(null, null);
gSecondConnection.onicecandidate = onIceCandidateToSecond;
gSecondConnection.onaddstream = onRemoteStream;
var parsedOffer = new RTCSessionDescription({ type: 'offer',
sdp: offerSdp });
gSecondConnection.setRemoteDescription(parsedOffer);
gSecondConnection.createAnswer(onAnswerCreated);
});
var onAnswerCreated = test.step_func(function(answer) {
gSecondConnection.setLocalDescription(answer);
// Similarly, this would go over the application's signaling solution.
handleAnswer(answer.sdp);
});
var handleAnswer = test.step_func(function(answerSdp) {
var parsedAnswer = new RTCSessionDescription({ type: 'answer',
sdp: answerSdp });
gFirstConnection.setRemoteDescription(parsedAnswer);
});
var onIceCandidateToFirst = test.step_func(function(event) {
// If event.candidate is null = no more candidates.
if (event.candidate) {
var candidate = new RTCIceCandidate(event.candidate);
gSecondConnection.addIceCandidate(candidate);
}
});
var onIceCandidateToSecond = test.step_func(function(event) {
if (event.candidate) {
var candidate = new RTCIceCandidate(event.candidate);
gFirstConnection.addIceCandidate(candidate);
}
});
var onRemoteStream = test.step_func(function(e) {
test.done();
});
test.step(function() {
navigator.webkitGetUserMedia({ video: true, audio: true },
getUserMediaOkCallback,
getUserMediaFailedCallback)
});
</script>
</head>
<body>
</body>
<div id="log"></div>
</body>
</html>