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

Side by Side Diff: webrtc/pc/channelmanager_unittest.cc

Issue 2537343003: Removing "crypto_required" from MediaContentDescription. (Closed)
Patch Set: Created 4 years 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 * Copyright 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2008 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/fakemediacontroller.h" 11 #include "webrtc/api/fakemediacontroller.h"
12 #include "webrtc/base/gunit.h" 12 #include "webrtc/base/gunit.h"
13 #include "webrtc/base/logging.h" 13 #include "webrtc/base/logging.h"
14 #include "webrtc/base/thread.h" 14 #include "webrtc/base/thread.h"
15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
16 #include "webrtc/media/base/fakemediaengine.h" 16 #include "webrtc/media/base/fakemediaengine.h"
17 #include "webrtc/media/base/fakevideocapturer.h" 17 #include "webrtc/media/base/fakevideocapturer.h"
18 #include "webrtc/media/base/testutils.h" 18 #include "webrtc/media/base/testutils.h"
19 #include "webrtc/media/engine/fakewebrtccall.h" 19 #include "webrtc/media/engine/fakewebrtccall.h"
20 #include "webrtc/p2p/base/faketransportcontroller.h" 20 #include "webrtc/p2p/base/faketransportcontroller.h"
21 #include "webrtc/pc/channelmanager.h" 21 #include "webrtc/pc/channelmanager.h"
22 22
23 namespace cricket { 23 namespace cricket {
24 const bool kDefaultUseRtcpChannel = false;
25 const bool kDefaultSecureRequired = true;
26 }
27
28 namespace cricket {
24 29
25 static const AudioCodec kAudioCodecs[] = { 30 static const AudioCodec kAudioCodecs[] = {
26 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), 31 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2),
27 }; 32 };
28 33
29 static const VideoCodec kVideoCodecs[] = { 34 static const VideoCodec kVideoCodecs[] = {
30 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"), 35 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"),
31 }; 36 };
32 37
33 class ChannelManagerTest : public testing::Test { 38 class ChannelManagerTest : public testing::Test {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); 96 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current()));
92 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); 97 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current()));
93 cm_->Terminate(); 98 cm_->Terminate();
94 EXPECT_FALSE(cm_->initialized()); 99 EXPECT_FALSE(cm_->initialized());
95 } 100 }
96 101
97 // Test that we can create and destroy a voice and video channel. 102 // Test that we can create and destroy a voice and video channel.
98 TEST_F(ChannelManagerTest, CreateDestroyChannels) { 103 TEST_F(ChannelManagerTest, CreateDestroyChannels) {
99 EXPECT_TRUE(cm_->Init()); 104 EXPECT_TRUE(cm_->Init());
100 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 105 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
101 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, 106 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr,
102 AudioOptions()); 107 kDefaultUseRtcpChannel, kDefaultSecureRequired, AudioOptions());
103 EXPECT_TRUE(voice_channel != nullptr); 108 EXPECT_TRUE(voice_channel != nullptr);
104 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 109 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
105 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, 110 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr,
106 VideoOptions()); 111 kDefaultUseRtcpChannel, kDefaultSecureRequired, VideoOptions());
107 EXPECT_TRUE(video_channel != nullptr); 112 EXPECT_TRUE(video_channel != nullptr);
108 cricket::DataChannel* data_channel = 113 cricket::DataChannel* data_channel = cm_->CreateDataChannel(
109 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, 114 transport_controller_, cricket::CN_DATA, nullptr, kDefaultUseRtcpChannel,
110 false, cricket::DCT_RTP); 115 kDefaultSecureRequired, cricket::DCT_RTP);
111 EXPECT_TRUE(data_channel != nullptr); 116 EXPECT_TRUE(data_channel != nullptr);
112 cm_->DestroyVideoChannel(video_channel); 117 cm_->DestroyVideoChannel(video_channel);
113 cm_->DestroyVoiceChannel(voice_channel); 118 cm_->DestroyVoiceChannel(voice_channel);
114 cm_->DestroyDataChannel(data_channel); 119 cm_->DestroyDataChannel(data_channel);
115 cm_->Terminate(); 120 cm_->Terminate();
116 } 121 }
117 122
118 // Test that we can create and destroy a voice and video channel with a worker. 123 // Test that we can create and destroy a voice and video channel with a worker.
119 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { 124 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
120 network_.Start(); 125 network_.Start();
121 worker_.Start(); 126 worker_.Start();
122 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); 127 EXPECT_TRUE(cm_->set_worker_thread(&worker_));
123 EXPECT_TRUE(cm_->set_network_thread(&network_)); 128 EXPECT_TRUE(cm_->set_network_thread(&network_));
124 EXPECT_TRUE(cm_->Init()); 129 EXPECT_TRUE(cm_->Init());
125 delete transport_controller_; 130 delete transport_controller_;
126 transport_controller_ = 131 transport_controller_ =
127 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); 132 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING);
128 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 133 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
129 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, 134 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr,
130 AudioOptions()); 135 kDefaultUseRtcpChannel, kDefaultSecureRequired, AudioOptions());
131 EXPECT_TRUE(voice_channel != nullptr); 136 EXPECT_TRUE(voice_channel != nullptr);
132 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 137 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
133 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, 138 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr,
134 VideoOptions()); 139 kDefaultUseRtcpChannel, kDefaultSecureRequired, VideoOptions());
135 EXPECT_TRUE(video_channel != nullptr); 140 EXPECT_TRUE(video_channel != nullptr);
136 cricket::DataChannel* data_channel = 141 cricket::DataChannel* data_channel = cm_->CreateDataChannel(
137 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, 142 transport_controller_, cricket::CN_DATA, nullptr, kDefaultUseRtcpChannel,
138 false, cricket::DCT_RTP); 143 kDefaultSecureRequired, cricket::DCT_RTP);
139 EXPECT_TRUE(data_channel != nullptr); 144 EXPECT_TRUE(data_channel != nullptr);
140 cm_->DestroyVideoChannel(video_channel); 145 cm_->DestroyVideoChannel(video_channel);
141 cm_->DestroyVoiceChannel(voice_channel); 146 cm_->DestroyVoiceChannel(voice_channel);
142 cm_->DestroyDataChannel(data_channel); 147 cm_->DestroyDataChannel(data_channel);
143 cm_->Terminate(); 148 cm_->Terminate();
144 } 149 }
145 150
146 // Test that we fail to create a voice/video channel if the session is unable 151 // Test that we fail to create a voice/video channel if the session is unable
147 // to create a cricket::TransportChannel 152 // to create a cricket::TransportChannel
148 TEST_F(ChannelManagerTest, NoTransportChannelTest) { 153 TEST_F(ChannelManagerTest, NoTransportChannelTest) {
149 EXPECT_TRUE(cm_->Init()); 154 EXPECT_TRUE(cm_->Init());
150 transport_controller_->set_fail_channel_creation(true); 155 transport_controller_->set_fail_channel_creation(true);
151 // The test is useless unless the session does not fail creating 156 // The test is useless unless the session does not fail creating
152 // cricket::TransportChannel. 157 // cricket::TransportChannel.
153 ASSERT_TRUE(transport_controller_->CreateTransportChannel_n( 158 ASSERT_TRUE(transport_controller_->CreateTransportChannel_n(
154 "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr); 159 "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr);
155 160
156 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 161 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
157 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, 162 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr,
158 AudioOptions()); 163 kDefaultUseRtcpChannel, kDefaultSecureRequired, AudioOptions());
159 EXPECT_TRUE(voice_channel == nullptr); 164 EXPECT_TRUE(voice_channel == nullptr);
160 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 165 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
161 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, 166 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr,
162 VideoOptions()); 167 kDefaultUseRtcpChannel, kDefaultSecureRequired, VideoOptions());
163 EXPECT_TRUE(video_channel == nullptr); 168 EXPECT_TRUE(video_channel == nullptr);
164 cricket::DataChannel* data_channel = 169 cricket::DataChannel* data_channel = cm_->CreateDataChannel(
165 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, 170 transport_controller_, cricket::CN_DATA, nullptr, kDefaultUseRtcpChannel,
166 false, cricket::DCT_RTP); 171 kDefaultSecureRequired, cricket::DCT_RTP);
167 EXPECT_TRUE(data_channel == nullptr); 172 EXPECT_TRUE(data_channel == nullptr);
168 cm_->Terminate(); 173 cm_->Terminate();
169 } 174 }
170 175
171 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { 176 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) {
172 std::vector<VideoCodec> codecs; 177 std::vector<VideoCodec> codecs;
173 const VideoCodec rtx_codec(96, "rtx"); 178 const VideoCodec rtx_codec(96, "rtx");
174 179
175 // By default RTX is disabled. 180 // By default RTX is disabled.
176 cm_->GetSupportedVideoCodecs(&codecs); 181 cm_->GetSupportedVideoCodecs(&codecs);
(...skipping 15 matching lines...) Expand all
192 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); 197 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false));
193 198
194 // Can set again after terminate. 199 // Can set again after terminate.
195 cm_->Terminate(); 200 cm_->Terminate();
196 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); 201 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true));
197 cm_->GetSupportedVideoCodecs(&codecs); 202 cm_->GetSupportedVideoCodecs(&codecs);
198 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); 203 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
199 } 204 }
200 205
201 } // namespace cricket 206 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698