1// Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2// 3// Use of this source code is governed by a BSD-style license 4// that can be found in the LICENSE file in the root of the source 5// tree. An additional intellectual property rights grant can be found 6// in the file PATENTS. All contributing project authors may 7// be found in the AUTHORS file in the root of the source tree. 8// 9// Test that offer/answer between 2 peers completes successfully. 10// 11// Note: This test does not performs ice candidate exchange and 12// does not verifies that media can flow between the peers. 13function testOfferAnswer(peer1, peer2) { 14 test.wait([ 15 createPeerConnection.bind(peer1), 16 createPeerConnection.bind(peer2) ], 17 establishCall); 18 19 function createPeerConnection(done) { 20 this.createPeerConnection(done, test.fail); 21 } 22 23 function establishCall(pc1, pc2) { 24 test.log("Establishing call."); 25 pc1.createOffer(gotOffer); 26 27 function gotOffer(offer) { 28 test.log("Got offer"); 29 expectedCall(); 30 pc1.setLocalDescription(offer, expectedCall, test.fail); 31 pc2.setRemoteDescription(offer, expectedCall, test.fail); 32 pc2.createAnswer(gotAnswer, test.fail); 33 } 34 35 function gotAnswer(answer) { 36 test.log("Got answer"); 37 expectedCall(); 38 pc2.setLocalDescription(answer, expectedCall, test.fail); 39 pc1.setRemoteDescription(answer, expectedCall, test.fail); 40 } 41 } 42} 43 44// TODO(andresp): Implement utilities in test to write expectations that certain 45// methods must be called. 46var expectedCalls = 0; 47function expectedCall() { 48 if (++expectedCalls == 6) 49 test.done(); 50} 51 52test.wait( [ test.spawnBot.bind(test, "alice"), 53 test.spawnBot.bind(test, "bob") ], 54 testOfferAnswer); 55