blob: 9819b538f85c51e66edef33b7b9059a6febf502d [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"
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020016#include "webrtc/test/fake_voice_engine.h"
solenbergc7a8b082015-10-16 14:35:07 -070017
18namespace {
19
20struct CallHelper {
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020021 CallHelper() : voice_engine_(new webrtc::test::FakeVoiceEngine()) {
solenbergc7a8b082015-10-16 14:35:07 -070022 webrtc::Call::Config config;
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020023 config.voice_engine = voice_engine_.get();
solenbergc7a8b082015-10-16 14:35:07 -070024 call_.reset(webrtc::Call::Create(config));
25 }
26
27 webrtc::Call* operator->() { return call_.get(); }
28
29 private:
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020030 rtc::scoped_ptr<webrtc::test::FakeVoiceEngine> voice_engine_;
solenbergc7a8b082015-10-16 14:35:07 -070031 rtc::scoped_ptr<webrtc::Call> call_;
32};
33} // namespace
34
35namespace webrtc {
36
37TEST(CallTest, ConstructDestruct) {
38 CallHelper call;
39}
40
41TEST(CallTest, CreateDestroy_AudioSendStream) {
42 CallHelper call;
43 AudioSendStream::Config config(nullptr);
44 config.rtp.ssrc = 42;
45 config.voe_channel_id = 123;
46 AudioSendStream* stream = call->CreateAudioSendStream(config);
47 EXPECT_NE(stream, nullptr);
48 call->DestroyAudioSendStream(stream);
49}
50
51TEST(CallTest, CreateDestroy_AudioReceiveStream) {
52 CallHelper call;
53 AudioReceiveStream::Config config;
54 config.rtp.remote_ssrc = 42;
55 config.voe_channel_id = 123;
56 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config);
57 EXPECT_NE(stream, nullptr);
58 call->DestroyAudioReceiveStream(stream);
59}
60
61TEST(CallTest, CreateDestroy_AudioSendStreams) {
62 CallHelper call;
63 AudioSendStream::Config config(nullptr);
64 config.voe_channel_id = 123;
65 std::list<AudioSendStream*> streams;
66 for (int i = 0; i < 2; ++i) {
67 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
68 config.rtp.ssrc = ssrc;
69 AudioSendStream* stream = call->CreateAudioSendStream(config);
70 EXPECT_NE(stream, nullptr);
71 if (ssrc & 1) {
72 streams.push_back(stream);
73 } else {
74 streams.push_front(stream);
75 }
76 }
77 for (auto s : streams) {
78 call->DestroyAudioSendStream(s);
79 }
80 streams.clear();
81 }
82}
83
84TEST(CallTest, CreateDestroy_AudioReceiveStreams) {
85 CallHelper call;
86 AudioReceiveStream::Config config;
87 config.voe_channel_id = 123;
88 std::list<AudioReceiveStream*> streams;
89 for (int i = 0; i < 2; ++i) {
90 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
91 config.rtp.remote_ssrc = ssrc;
92 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config);
93 EXPECT_NE(stream, nullptr);
94 if (ssrc & 1) {
95 streams.push_back(stream);
96 } else {
97 streams.push_front(stream);
98 }
99 }
100 for (auto s : streams) {
101 call->DestroyAudioReceiveStream(s);
102 }
103 streams.clear();
104 }
105}
106} // namespace webrtc