blob: 888662a0de03e53e889f4b6c7895630b302a64d6 [file] [log] [blame]
andresp@webrtc.org468516c2014-09-02 10:52:54 +00001// 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.
andresp@webrtc.org458c2c32014-10-16 07:36:37 +000013function testOfferAnswer(test, bot1, bot2) {
14 test.wait( [ bot1.createPeerConnection.bind(bot1, null),
15 bot2.createPeerConnection.bind(bot2, null) ],
16 run);
andresp@webrtc.org468516c2014-09-02 10:52:54 +000017
andresp@webrtc.org458c2c32014-10-16 07:36:37 +000018 function run(pc1, pc2) {
andresp@webrtc.org468516c2014-09-02 10:52:54 +000019 test.log("Establishing call.");
20 pc1.createOffer(gotOffer);
21
22 function gotOffer(offer) {
23 test.log("Got offer");
24 expectedCall();
25 pc1.setLocalDescription(offer, expectedCall, test.fail);
26 pc2.setRemoteDescription(offer, expectedCall, test.fail);
27 pc2.createAnswer(gotAnswer, test.fail);
28 }
29
30 function gotAnswer(answer) {
31 test.log("Got answer");
32 expectedCall();
33 pc2.setLocalDescription(answer, expectedCall, test.fail);
34 pc1.setRemoteDescription(answer, expectedCall, test.fail);
35 }
andresp@webrtc.org458c2c32014-10-16 07:36:37 +000036
37 // TODO(andresp): Implement utilities in test to write expectations
38 // that certain methods must be called.
39 var expectedCalls = 0;
40 function expectedCall() {
41 if (++expectedCalls == 6)
42 test.done();
43 }
andresp@webrtc.org468516c2014-09-02 10:52:54 +000044 }
45}
46
houssainy@google.comc221db62014-10-17 09:13:43 +000047registerBotTest('testOfferAnswer/chrome-chrome',
andresp@webrtc.org458c2c32014-10-16 07:36:37 +000048 testOfferAnswer, ['chrome', 'chrome']);