Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Side by Side Diff: talk/session/media/channelmanager_unittest.cc

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nullptr Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2008 Google Inc. 3 * Copyright 2008 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 12 matching lines...) Expand all
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/media/base/fakecapturemanager.h" 28 #include "talk/media/base/fakecapturemanager.h"
29 #include "talk/media/base/fakemediaengine.h" 29 #include "talk/media/base/fakemediaengine.h"
30 #include "talk/media/base/fakemediaprocessor.h" 30 #include "talk/media/base/fakemediaprocessor.h"
31 #include "talk/media/base/testutils.h" 31 #include "talk/media/base/testutils.h"
32 #include "talk/media/devices/fakedevicemanager.h" 32 #include "talk/media/devices/fakedevicemanager.h"
33 #include "talk/media/webrtc/fakewebrtccall.h"
33 #include "webrtc/p2p/base/fakesession.h" 34 #include "webrtc/p2p/base/fakesession.h"
34 #include "talk/session/media/channelmanager.h" 35 #include "talk/session/media/channelmanager.h"
35 #include "webrtc/base/gunit.h" 36 #include "webrtc/base/gunit.h"
36 #include "webrtc/base/logging.h" 37 #include "webrtc/base/logging.h"
37 #include "webrtc/base/thread.h" 38 #include "webrtc/base/thread.h"
38 39
39 namespace cricket { 40 namespace cricket {
40 41
41 static const AudioCodec kAudioCodecs[] = { 42 static const AudioCodec kAudioCodecs[] = {
42 AudioCodec(97, "voice", 1, 2, 3, 0), 43 AudioCodec(97, "voice", 1, 2, 3, 0),
43 AudioCodec(111, "OPUS", 48000, 32000, 2, 0), 44 AudioCodec(111, "OPUS", 48000, 32000, 2, 0),
44 }; 45 };
45 46
46 static const VideoCodec kVideoCodecs[] = { 47 static const VideoCodec kVideoCodecs[] = {
47 VideoCodec(99, "H264", 100, 200, 300, 0), 48 VideoCodec(99, "H264", 100, 200, 300, 0),
48 VideoCodec(100, "VP8", 100, 200, 300, 0), 49 VideoCodec(100, "VP8", 100, 200, 300, 0),
49 VideoCodec(96, "rtx", 100, 200, 300, 0), 50 VideoCodec(96, "rtx", 100, 200, 300, 0),
50 }; 51 };
51 52
52 class ChannelManagerTest : public testing::Test { 53 class ChannelManagerTest : public testing::Test {
53 protected: 54 protected:
54 ChannelManagerTest() : fme_(NULL), fdm_(NULL), fcm_(NULL), cm_(NULL) { 55 ChannelManagerTest() : fake_call_(webrtc::Call::Config()),
55 } 56 fme_(NULL), fdm_(NULL), fcm_(NULL), cm_(NULL) {}
56 57
57 virtual void SetUp() { 58 virtual void SetUp() {
58 fme_ = new cricket::FakeMediaEngine(); 59 fme_ = new cricket::FakeMediaEngine();
59 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); 60 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs));
60 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); 61 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs));
61 fdme_ = new cricket::FakeDataEngine(); 62 fdme_ = new cricket::FakeDataEngine();
62 fdm_ = new cricket::FakeDeviceManager(); 63 fdm_ = new cricket::FakeDeviceManager();
63 fcm_ = new cricket::FakeCaptureManager(); 64 fcm_ = new cricket::FakeCaptureManager();
64 cm_ = new cricket::ChannelManager( 65 cm_ = new cricket::ChannelManager(
65 fme_, fdme_, fdm_, fcm_, rtc::Thread::Current()); 66 fme_, fdme_, fdm_, fcm_, rtc::Thread::Current());
(...skipping 15 matching lines...) Expand all
81 delete session_; 82 delete session_;
82 delete cm_; 83 delete cm_;
83 cm_ = NULL; 84 cm_ = NULL;
84 fdm_ = NULL; 85 fdm_ = NULL;
85 fcm_ = NULL; 86 fcm_ = NULL;
86 fdme_ = NULL; 87 fdme_ = NULL;
87 fme_ = NULL; 88 fme_ = NULL;
88 } 89 }
89 90
90 rtc::Thread worker_; 91 rtc::Thread worker_;
92 cricket::FakeCall fake_call_;
91 cricket::FakeMediaEngine* fme_; 93 cricket::FakeMediaEngine* fme_;
92 cricket::FakeDataEngine* fdme_; 94 cricket::FakeDataEngine* fdme_;
93 cricket::FakeDeviceManager* fdm_; 95 cricket::FakeDeviceManager* fdm_;
94 cricket::FakeCaptureManager* fcm_; 96 cricket::FakeCaptureManager* fcm_;
95 cricket::ChannelManager* cm_; 97 cricket::ChannelManager* cm_;
96 cricket::FakeSession* session_; 98 cricket::FakeSession* session_;
97 }; 99 };
98 100
99 // Test that we startup/shutdown properly. 101 // Test that we startup/shutdown properly.
100 TEST_F(ChannelManagerTest, StartupShutdown) { 102 TEST_F(ChannelManagerTest, StartupShutdown) {
(...skipping 17 matching lines...) Expand all
118 // Setting the worker thread while initialized should fail. 120 // Setting the worker thread while initialized should fail.
119 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); 121 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current()));
120 cm_->Terminate(); 122 cm_->Terminate();
121 EXPECT_FALSE(cm_->initialized()); 123 EXPECT_FALSE(cm_->initialized());
122 } 124 }
123 125
124 // Test that we can create and destroy a voice and video channel. 126 // Test that we can create and destroy a voice and video channel.
125 TEST_F(ChannelManagerTest, CreateDestroyChannels) { 127 TEST_F(ChannelManagerTest, CreateDestroyChannels) {
126 EXPECT_TRUE(cm_->Init()); 128 EXPECT_TRUE(cm_->Init());
127 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 129 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
128 session_, cricket::CN_AUDIO, false, AudioOptions()); 130 session_, cricket::CN_AUDIO, false, &fake_call_, AudioOptions());
129 EXPECT_TRUE(voice_channel != nullptr); 131 EXPECT_TRUE(voice_channel != nullptr);
130 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 132 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
131 session_, cricket::CN_VIDEO, false, VideoOptions(), voice_channel); 133 session_, cricket::CN_VIDEO, false, &fake_call_, VideoOptions());
132 EXPECT_TRUE(video_channel != nullptr); 134 EXPECT_TRUE(video_channel != nullptr);
133 cricket::DataChannel* data_channel = 135 cricket::DataChannel* data_channel =
134 cm_->CreateDataChannel(session_, cricket::CN_DATA, 136 cm_->CreateDataChannel(session_, cricket::CN_DATA,
135 false, cricket::DCT_RTP); 137 false, cricket::DCT_RTP);
136 EXPECT_TRUE(data_channel != nullptr); 138 EXPECT_TRUE(data_channel != nullptr);
137 cm_->DestroyVideoChannel(video_channel); 139 cm_->DestroyVideoChannel(video_channel);
138 cm_->DestroyVoiceChannel(voice_channel, nullptr); 140 cm_->DestroyVoiceChannel(voice_channel);
139 cm_->DestroyDataChannel(data_channel); 141 cm_->DestroyDataChannel(data_channel);
140 cm_->Terminate(); 142 cm_->Terminate();
141 } 143 }
142 144
143 // Test that we can create and destroy a voice and video channel with a worker. 145 // Test that we can create and destroy a voice and video channel with a worker.
144 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { 146 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
145 worker_.Start(); 147 worker_.Start();
146 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); 148 EXPECT_TRUE(cm_->set_worker_thread(&worker_));
147 EXPECT_TRUE(cm_->Init()); 149 EXPECT_TRUE(cm_->Init());
148 delete session_; 150 delete session_;
149 session_ = new cricket::FakeSession(&worker_, true); 151 session_ = new cricket::FakeSession(&worker_, true);
150 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 152 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
151 session_, cricket::CN_AUDIO, false, AudioOptions()); 153 session_, cricket::CN_AUDIO, false, &fake_call_, AudioOptions());
152 EXPECT_TRUE(voice_channel != nullptr); 154 EXPECT_TRUE(voice_channel != nullptr);
153 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 155 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
154 session_, cricket::CN_VIDEO, false, VideoOptions(), voice_channel); 156 session_, cricket::CN_VIDEO, false, &fake_call_, VideoOptions());
155 EXPECT_TRUE(video_channel != nullptr); 157 EXPECT_TRUE(video_channel != nullptr);
156 cricket::DataChannel* data_channel = 158 cricket::DataChannel* data_channel =
157 cm_->CreateDataChannel(session_, cricket::CN_DATA, 159 cm_->CreateDataChannel(session_, cricket::CN_DATA,
158 false, cricket::DCT_RTP); 160 false, cricket::DCT_RTP);
159 EXPECT_TRUE(data_channel != nullptr); 161 EXPECT_TRUE(data_channel != nullptr);
160 cm_->DestroyVideoChannel(video_channel); 162 cm_->DestroyVideoChannel(video_channel);
161 cm_->DestroyVoiceChannel(voice_channel, nullptr); 163 cm_->DestroyVoiceChannel(voice_channel);
162 cm_->DestroyDataChannel(data_channel); 164 cm_->DestroyDataChannel(data_channel);
163 cm_->Terminate(); 165 cm_->Terminate();
164 } 166 }
165 167
166 // Test that we fail to create a voice/video channel if the session is unable 168 // Test that we fail to create a voice/video channel if the session is unable
167 // to create a cricket::TransportChannel 169 // to create a cricket::TransportChannel
168 TEST_F(ChannelManagerTest, NoTransportChannelTest) { 170 TEST_F(ChannelManagerTest, NoTransportChannelTest) {
169 EXPECT_TRUE(cm_->Init()); 171 EXPECT_TRUE(cm_->Init());
170 session_->set_fail_channel_creation(true); 172 session_->set_fail_channel_creation(true);
171 // The test is useless unless the session does not fail creating 173 // The test is useless unless the session does not fail creating
172 // cricket::TransportChannel. 174 // cricket::TransportChannel.
173 ASSERT_TRUE(session_->CreateChannel( 175 ASSERT_TRUE(session_->CreateChannel(
174 "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr); 176 "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr);
175 177
176 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 178 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
177 session_, cricket::CN_AUDIO, false, AudioOptions()); 179 session_, cricket::CN_AUDIO, false, &fake_call_, AudioOptions());
178 EXPECT_TRUE(voice_channel == nullptr); 180 EXPECT_TRUE(voice_channel == nullptr);
179 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 181 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
180 session_, cricket::CN_VIDEO, false, VideoOptions(), voice_channel); 182 session_, cricket::CN_VIDEO, false, &fake_call_, VideoOptions());
181 EXPECT_TRUE(video_channel == nullptr); 183 EXPECT_TRUE(video_channel == nullptr);
182 cricket::DataChannel* data_channel = 184 cricket::DataChannel* data_channel =
183 cm_->CreateDataChannel(session_, cricket::CN_DATA, 185 cm_->CreateDataChannel(session_, cricket::CN_DATA,
184 false, cricket::DCT_RTP); 186 false, cricket::DCT_RTP);
185 EXPECT_TRUE(data_channel == nullptr); 187 EXPECT_TRUE(data_channel == nullptr);
186 cm_->Terminate(); 188 cm_->Terminate();
187 } 189 }
188 190
189 // Test that SetDefaultVideoCodec passes through the right values. 191 // Test that SetDefaultVideoCodec passes through the right values.
190 TEST_F(ChannelManagerTest, SetDefaultVideoEncoderConfig) { 192 TEST_F(ChannelManagerTest, SetDefaultVideoEncoderConfig) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); 579 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false));
578 580
579 // Can set again after terminate. 581 // Can set again after terminate.
580 cm_->Terminate(); 582 cm_->Terminate();
581 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); 583 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true));
582 cm_->GetSupportedVideoCodecs(&codecs); 584 cm_->GetSupportedVideoCodecs(&codecs);
583 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); 585 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
584 } 586 }
585 587
586 } // namespace cricket 588 } // namespace cricket
OLDNEW
« talk/media/webrtc/webrtcvoiceengine.cc ('K') | « talk/session/media/channelmanager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698