andresp@webrtc.org | 468516c | 2014-09-02 10:52:54 +0000 | [diff] [blame] | 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. |
andresp@webrtc.org | 458c2c3 | 2014-10-16 07:36:37 +0000 | [diff] [blame] | 13 | function testOfferAnswer(test, bot1, bot2) { |
| 14 | test.wait( [ bot1.createPeerConnection.bind(bot1, null), |
| 15 | bot2.createPeerConnection.bind(bot2, null) ], |
| 16 | run); |
andresp@webrtc.org | 468516c | 2014-09-02 10:52:54 +0000 | [diff] [blame] | 17 | |
andresp@webrtc.org | 458c2c3 | 2014-10-16 07:36:37 +0000 | [diff] [blame] | 18 | function run(pc1, pc2) { |
andresp@webrtc.org | 468516c | 2014-09-02 10:52:54 +0000 | [diff] [blame] | 19 | 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.org | 458c2c3 | 2014-10-16 07:36:37 +0000 | [diff] [blame] | 36 | |
| 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.org | 468516c | 2014-09-02 10:52:54 +0000 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
houssainy@google.com | c221db6 | 2014-10-17 09:13:43 +0000 | [diff] [blame] | 47 | registerBotTest('testOfferAnswer/chrome-chrome', |
andresp@webrtc.org | 458c2c3 | 2014-10-16 07:36:37 +0000 | [diff] [blame] | 48 | testOfferAnswer, ['chrome', 'chrome']); |