blob: 9adecc349b313b32beacb29a347b0bb7344a946a [file] [log] [blame]
solenbergc7a8b082015-10-16 14:35:07 -07001/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include <list>
12
13#include "testing/gtest/include/gtest/gtest.h"
14
15#include "webrtc/call.h"
16
17namespace {
18
19struct CallHelper {
20 CallHelper() {
21 webrtc::Call::Config config;
22 // TODO(solenberg): Fill in with VoiceEngine* etc.
23 call_.reset(webrtc::Call::Create(config));
24 }
25
26 webrtc::Call* operator->() { return call_.get(); }
27
28 private:
29 rtc::scoped_ptr<webrtc::Call> call_;
30};
31} // namespace
32
33namespace webrtc {
34
35TEST(CallTest, ConstructDestruct) {
36 CallHelper call;
37}
38
39TEST(CallTest, CreateDestroy_AudioSendStream) {
40 CallHelper call;
41 AudioSendStream::Config config(nullptr);
42 config.rtp.ssrc = 42;
43 config.voe_channel_id = 123;
44 AudioSendStream* stream = call->CreateAudioSendStream(config);
45 EXPECT_NE(stream, nullptr);
46 call->DestroyAudioSendStream(stream);
47}
48
49TEST(CallTest, CreateDestroy_AudioReceiveStream) {
50 CallHelper call;
51 AudioReceiveStream::Config config;
52 config.rtp.remote_ssrc = 42;
53 config.voe_channel_id = 123;
54 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config);
55 EXPECT_NE(stream, nullptr);
56 call->DestroyAudioReceiveStream(stream);
57}
58
59TEST(CallTest, CreateDestroy_AudioSendStreams) {
60 CallHelper call;
61 AudioSendStream::Config config(nullptr);
62 config.voe_channel_id = 123;
63 std::list<AudioSendStream*> streams;
64 for (int i = 0; i < 2; ++i) {
65 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
66 config.rtp.ssrc = ssrc;
67 AudioSendStream* stream = call->CreateAudioSendStream(config);
68 EXPECT_NE(stream, nullptr);
69 if (ssrc & 1) {
70 streams.push_back(stream);
71 } else {
72 streams.push_front(stream);
73 }
74 }
75 for (auto s : streams) {
76 call->DestroyAudioSendStream(s);
77 }
78 streams.clear();
79 }
80}
81
82TEST(CallTest, CreateDestroy_AudioReceiveStreams) {
83 CallHelper call;
84 AudioReceiveStream::Config config;
85 config.voe_channel_id = 123;
86 std::list<AudioReceiveStream*> streams;
87 for (int i = 0; i < 2; ++i) {
88 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
89 config.rtp.remote_ssrc = ssrc;
90 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config);
91 EXPECT_NE(stream, nullptr);
92 if (ssrc & 1) {
93 streams.push_back(stream);
94 } else {
95 streams.push_front(stream);
96 }
97 }
98 for (auto s : streams) {
99 call->DestroyAudioReceiveStream(s);
100 }
101 streams.clear();
102 }
103}
104} // namespace webrtc