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

Side by Side Diff: webrtc/api/webrtcsession_unittest.cc

Issue 2614813003: Revert of Separating SCTP code from BaseChannel/MediaChannel. (Closed)
Patch Set: Also reverting https://codereview.webrtc.org/2612963002 Created 3 years, 11 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
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/api/webrtcsessiondescriptionfactory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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
(...skipping 22 matching lines...) Expand all
33 #include "webrtc/base/sslidentity.h" 33 #include "webrtc/base/sslidentity.h"
34 #include "webrtc/base/sslstreamadapter.h" 34 #include "webrtc/base/sslstreamadapter.h"
35 #include "webrtc/base/stringutils.h" 35 #include "webrtc/base/stringutils.h"
36 #include "webrtc/base/thread.h" 36 #include "webrtc/base/thread.h"
37 #include "webrtc/base/virtualsocketserver.h" 37 #include "webrtc/base/virtualsocketserver.h"
38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
39 #include "webrtc/media/base/fakemediaengine.h" 39 #include "webrtc/media/base/fakemediaengine.h"
40 #include "webrtc/media/base/fakevideorenderer.h" 40 #include "webrtc/media/base/fakevideorenderer.h"
41 #include "webrtc/media/base/mediachannel.h" 41 #include "webrtc/media/base/mediachannel.h"
42 #include "webrtc/media/engine/fakewebrtccall.h" 42 #include "webrtc/media/engine/fakewebrtccall.h"
43 #include "webrtc/media/sctp/sctptransportinternal.h"
44 #include "webrtc/p2p/base/packettransportinterface.h" 43 #include "webrtc/p2p/base/packettransportinterface.h"
45 #include "webrtc/p2p/base/stunserver.h" 44 #include "webrtc/p2p/base/stunserver.h"
46 #include "webrtc/p2p/base/teststunserver.h" 45 #include "webrtc/p2p/base/teststunserver.h"
47 #include "webrtc/p2p/base/testturnserver.h" 46 #include "webrtc/p2p/base/testturnserver.h"
48 #include "webrtc/p2p/base/transportchannel.h" 47 #include "webrtc/p2p/base/transportchannel.h"
49 #include "webrtc/p2p/client/basicportallocator.h" 48 #include "webrtc/p2p/client/basicportallocator.h"
50 #include "webrtc/pc/channelmanager.h" 49 #include "webrtc/pc/channelmanager.h"
51 #include "webrtc/pc/mediasession.h" 50 #include "webrtc/pc/mediasession.h"
52 51
53 #define MAYBE_SKIP_TEST(feature) \ 52 #define MAYBE_SKIP_TEST(feature) \
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 static const char kSessionVersion[] = "1"; 102 static const char kSessionVersion[] = "1";
104 103
105 // Media index of candidates belonging to the first media content. 104 // Media index of candidates belonging to the first media content.
106 static const int kMediaContentIndex0 = 0; 105 static const int kMediaContentIndex0 = 0;
107 static const char kMediaContentName0[] = "audio"; 106 static const char kMediaContentName0[] = "audio";
108 107
109 // Media index of candidates belonging to the second media content. 108 // Media index of candidates belonging to the second media content.
110 static const int kMediaContentIndex1 = 1; 109 static const int kMediaContentIndex1 = 1;
111 static const char kMediaContentName1[] = "video"; 110 static const char kMediaContentName1[] = "video";
112 111
113 static const int kDefaultTimeout = 10000; // 10 seconds.
114 static const int kIceCandidatesTimeout = 10000; 112 static const int kIceCandidatesTimeout = 10000;
115 // STUN timeout with all retransmissions is a total of 9500ms. 113 // STUN timeout with all retransmissions is a total of 9500ms.
116 static const int kStunTimeout = 9500; 114 static const int kStunTimeout = 9500;
117 115
118 static const char kFakeDtlsFingerprint[] = 116 static const char kFakeDtlsFingerprint[] =
119 "BB:CD:72:F7:2F:D0:BA:43:F3:68:B1:0C:23:72:B6:4A:" 117 "BB:CD:72:F7:2F:D0:BA:43:F3:68:B1:0C:23:72:B6:4A:"
120 "0F:DE:34:06:BC:E0:FE:01:BC:73:C8:6D:F4:65:D5:24"; 118 "0F:DE:34:06:BC:E0:FE:01:BC:73:C8:6D:F4:65:D5:24";
121 119
122 static const char kTooLongIceUfragPwd[] = 120 static const char kTooLongIceUfragPwd[] =
123 "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag" 121 "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool oncandidatesready_; 204 bool oncandidatesready_;
207 std::vector<cricket::Candidate> mline_0_candidates_; 205 std::vector<cricket::Candidate> mline_0_candidates_;
208 std::vector<cricket::Candidate> mline_1_candidates_; 206 std::vector<cricket::Candidate> mline_1_candidates_;
209 PeerConnectionInterface::IceConnectionState ice_connection_state_; 207 PeerConnectionInterface::IceConnectionState ice_connection_state_;
210 PeerConnectionInterface::IceGatheringState ice_gathering_state_; 208 PeerConnectionInterface::IceGatheringState ice_gathering_state_;
211 std::vector<PeerConnectionInterface::IceConnectionState> 209 std::vector<PeerConnectionInterface::IceConnectionState>
212 ice_connection_state_history_; 210 ice_connection_state_history_;
213 size_t num_candidates_removed_ = 0; 211 size_t num_candidates_removed_ = 0;
214 }; 212 };
215 213
216 // Used for tests in this file to verify that WebRtcSession responds to signals
217 // from the SctpTransport correctly, and calls Start with the correct
218 // local/remote ports.
219 class FakeSctpTransport : public cricket::SctpTransportInternal {
220 public:
221 void SetTransportChannel(cricket::TransportChannel* channel) override {}
222 bool Start(int local_port, int remote_port) override {
223 local_port_ = local_port;
224 remote_port_ = remote_port;
225 return true;
226 }
227 bool OpenStream(int sid) override { return true; }
228 bool ResetStream(int sid) override { return true; }
229 bool SendData(const cricket::SendDataParams& params,
230 const rtc::CopyOnWriteBuffer& payload,
231 cricket::SendDataResult* result = nullptr) override {
232 return true;
233 }
234 bool ReadyToSendData() override { return true; }
235 void set_debug_name_for_testing(const char* debug_name) override {}
236
237 int local_port() const { return local_port_; }
238 int remote_port() const { return remote_port_; }
239
240 private:
241 int local_port_ = -1;
242 int remote_port_ = -1;
243 };
244
245 class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory {
246 public:
247 std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport(
248 cricket::TransportChannel*) override {
249 last_fake_sctp_transport_ = new FakeSctpTransport();
250 return std::unique_ptr<cricket::SctpTransportInternal>(
251 last_fake_sctp_transport_);
252 }
253
254 FakeSctpTransport* last_fake_sctp_transport() {
255 return last_fake_sctp_transport_;
256 }
257
258 private:
259 FakeSctpTransport* last_fake_sctp_transport_ = nullptr;
260 };
261
262 class WebRtcSessionForTest : public webrtc::WebRtcSession { 214 class WebRtcSessionForTest : public webrtc::WebRtcSession {
263 public: 215 public:
264 WebRtcSessionForTest( 216 WebRtcSessionForTest(
265 webrtc::MediaControllerInterface* media_controller, 217 webrtc::MediaControllerInterface* media_controller,
266 rtc::Thread* network_thread, 218 rtc::Thread* network_thread,
267 rtc::Thread* worker_thread, 219 rtc::Thread* worker_thread,
268 rtc::Thread* signaling_thread, 220 rtc::Thread* signaling_thread,
269 cricket::PortAllocator* port_allocator, 221 cricket::PortAllocator* port_allocator,
270 webrtc::IceObserver* ice_observer, 222 webrtc::IceObserver* ice_observer,
271 std::unique_ptr<cricket::TransportController> transport_controller, 223 std::unique_ptr<cricket::TransportController> transport_controller)
272 std::unique_ptr<FakeSctpTransportFactory> sctp_factory)
273 : WebRtcSession(media_controller, 224 : WebRtcSession(media_controller,
274 network_thread, 225 network_thread,
275 worker_thread, 226 worker_thread,
276 signaling_thread, 227 signaling_thread,
277 port_allocator, 228 port_allocator,
278 std::move(transport_controller), 229 std::move(transport_controller)) {
279 std::move(sctp_factory)) {
280 RegisterIceObserver(ice_observer); 230 RegisterIceObserver(ice_observer);
281 } 231 }
282 virtual ~WebRtcSessionForTest() {} 232 virtual ~WebRtcSessionForTest() {}
283 233
284 // Note that these methods are only safe to use if the signaling thread 234 // Note that these methods are only safe to use if the signaling thread
285 // is the same as the worker thread 235 // is the same as the worker thread
286 rtc::PacketTransportInterface* voice_rtp_transport_channel() { 236 rtc::PacketTransportInterface* voice_rtp_transport_channel() {
287 return rtp_transport_channel(voice_channel()); 237 return rtp_transport_channel(voice_channel());
288 } 238 }
289 239
290 rtc::PacketTransportInterface* voice_rtcp_transport_channel() { 240 rtc::PacketTransportInterface* voice_rtcp_transport_channel() {
291 return rtcp_transport_channel(voice_channel()); 241 return rtcp_transport_channel(voice_channel());
292 } 242 }
293 243
294 rtc::PacketTransportInterface* video_rtp_transport_channel() { 244 rtc::PacketTransportInterface* video_rtp_transport_channel() {
295 return rtp_transport_channel(video_channel()); 245 return rtp_transport_channel(video_channel());
296 } 246 }
297 247
298 rtc::PacketTransportInterface* video_rtcp_transport_channel() { 248 rtc::PacketTransportInterface* video_rtcp_transport_channel() {
299 return rtcp_transport_channel(video_channel()); 249 return rtcp_transport_channel(video_channel());
300 } 250 }
301 251
252 rtc::PacketTransportInterface* data_rtp_transport_channel() {
253 return rtp_transport_channel(data_channel());
254 }
255
256 rtc::PacketTransportInterface* data_rtcp_transport_channel() {
257 return rtcp_transport_channel(data_channel());
258 }
259
302 private: 260 private:
303 rtc::PacketTransportInterface* rtp_transport_channel( 261 rtc::PacketTransportInterface* rtp_transport_channel(
304 cricket::BaseChannel* ch) { 262 cricket::BaseChannel* ch) {
305 if (!ch) { 263 if (!ch) {
306 return nullptr; 264 return nullptr;
307 } 265 }
308 return ch->transport_channel(); 266 return ch->transport_channel();
309 } 267 }
310 268
311 rtc::PacketTransportInterface* rtcp_transport_channel( 269 rtc::PacketTransportInterface* rtcp_transport_channel(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 379 }
422 380
423 // If |cert_generator| != null or |rtc_configuration| contains |certificates| 381 // If |cert_generator| != null or |rtc_configuration| contains |certificates|
424 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| 382 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration|
425 // options. When DTLS is enabled a certificate will be used if provided, 383 // options. When DTLS is enabled a certificate will be used if provided,
426 // otherwise one will be generated using the |cert_generator|. 384 // otherwise one will be generated using the |cert_generator|.
427 void Init( 385 void Init(
428 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, 386 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
429 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { 387 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
430 ASSERT_TRUE(session_.get() == NULL); 388 ASSERT_TRUE(session_.get() == NULL);
431 fake_sctp_transport_factory_ = new FakeSctpTransportFactory();
432 session_.reset(new WebRtcSessionForTest( 389 session_.reset(new WebRtcSessionForTest(
433 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), 390 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
434 rtc::Thread::Current(), allocator_.get(), &observer_, 391 rtc::Thread::Current(), allocator_.get(), &observer_,
435 std::unique_ptr<cricket::TransportController>( 392 std::unique_ptr<cricket::TransportController>(
436 new cricket::TransportController(rtc::Thread::Current(), 393 new cricket::TransportController(rtc::Thread::Current(),
437 rtc::Thread::Current(), 394 rtc::Thread::Current(),
438 allocator_.get())), 395 allocator_.get()))));
439 std::unique_ptr<FakeSctpTransportFactory>(
440 fake_sctp_transport_factory_)));
441 session_->SignalDataChannelOpenMessage.connect( 396 session_->SignalDataChannelOpenMessage.connect(
442 this, &WebRtcSessionTest::OnDataChannelOpenMessage); 397 this, &WebRtcSessionTest::OnDataChannelOpenMessage);
443 session_->GetOnDestroyedSignal()->connect( 398 session_->GetOnDestroyedSignal()->connect(
444 this, &WebRtcSessionTest::OnSessionDestroyed); 399 this, &WebRtcSessionTest::OnSessionDestroyed);
445 400
446 configuration_.rtcp_mux_policy = rtcp_mux_policy; 401 configuration_.rtcp_mux_policy = rtcp_mux_policy;
447 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, 402 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
448 observer_.ice_connection_state_); 403 observer_.ice_connection_state_);
449 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, 404 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew,
450 observer_.ice_gathering_state_); 405 observer_.ice_gathering_state_);
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 turn_server.ports.push_back( 1489 turn_server.ports.push_back(
1535 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP)); 1490 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP));
1536 allocator_->AddTurnServer(turn_server); 1491 allocator_->AddTurnServer(turn_server);
1537 allocator_->set_step_delay(cricket::kMinimumStepDelay); 1492 allocator_->set_step_delay(cricket::kMinimumStepDelay);
1538 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); 1493 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP);
1539 } 1494 }
1540 1495
1541 webrtc::RtcEventLogNullImpl event_log_; 1496 webrtc::RtcEventLogNullImpl event_log_;
1542 cricket::FakeMediaEngine* media_engine_; 1497 cricket::FakeMediaEngine* media_engine_;
1543 cricket::FakeDataEngine* data_engine_; 1498 cricket::FakeDataEngine* data_engine_;
1544 // Actually owned by session_.
1545 FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr;
1546 std::unique_ptr<cricket::ChannelManager> channel_manager_; 1499 std::unique_ptr<cricket::ChannelManager> channel_manager_;
1547 cricket::FakeCall fake_call_; 1500 cricket::FakeCall fake_call_;
1548 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; 1501 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_;
1549 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; 1502 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_;
1550 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; 1503 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_;
1551 std::unique_ptr<rtc::PhysicalSocketServer> pss_; 1504 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
1552 std::unique_ptr<rtc::VirtualSocketServer> vss_; 1505 std::unique_ptr<rtc::VirtualSocketServer> vss_;
1553 std::unique_ptr<rtc::FirewallSocketServer> fss_; 1506 std::unique_ptr<rtc::FirewallSocketServer> fss_;
1554 rtc::SocketServerScope ss_scope_; 1507 rtc::SocketServerScope ss_scope_;
1555 rtc::SocketAddress stun_socket_addr_; 1508 rtc::SocketAddress stun_socket_addr_;
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3915 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | 3868 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
3916 cricket::PORTALLOCATOR_DISABLE_RELAY); 3869 cricket::PORTALLOCATOR_DISABLE_RELAY);
3917 TestLoopbackCall(); 3870 TestLoopbackCall();
3918 } 3871 }
3919 3872
3920 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { 3873 TEST_F(WebRtcSessionTest, TestRtpDataChannel) {
3921 configuration_.enable_rtp_data_channel = true; 3874 configuration_.enable_rtp_data_channel = true;
3922 Init(); 3875 Init();
3923 SetLocalDescriptionWithDataChannel(); 3876 SetLocalDescriptionWithDataChannel();
3924 ASSERT_TRUE(data_engine_); 3877 ASSERT_TRUE(data_engine_);
3925 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); 3878 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type());
3926 } 3879 }
3927 3880
3928 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { 3881 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) {
3929 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3882 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3930 3883
3931 configuration_.enable_rtp_data_channel = true; 3884 configuration_.enable_rtp_data_channel = true;
3932 options_.disable_sctp_data_channels = false; 3885 options_.disable_sctp_data_channels = false;
3933 3886
3934 InitWithDtls(GetParam()); 3887 InitWithDtls(GetParam());
3935 3888
3936 SetLocalDescriptionWithDataChannel(); 3889 SetLocalDescriptionWithDataChannel();
3937 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); 3890 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type());
3938 }
3939
3940 // Test that sctp_content_name/sctp_transport_name (used for stats) are correct
3941 // before and after BUNDLE is negotiated.
3942 TEST_P(WebRtcSessionTest, SctpContentAndTransportName) {
3943 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3944 SetFactoryDtlsSrtp();
3945 InitWithDtls(GetParam());
3946
3947 // Initially these fields should be empty.
3948 EXPECT_FALSE(session_->sctp_content_name());
3949 EXPECT_FALSE(session_->sctp_transport_name());
3950
3951 // Create offer with audio/video/data.
3952 // Default bundle policy is "balanced", so data should be using its own
3953 // transport.
3954 SendAudioVideoStream1();
3955 CreateDataChannel();
3956 InitiateCall();
3957 ASSERT_TRUE(session_->sctp_content_name());
3958 ASSERT_TRUE(session_->sctp_transport_name());
3959 EXPECT_EQ("data", *session_->sctp_content_name());
3960 EXPECT_EQ("data", *session_->sctp_transport_name());
3961
3962 // Create answer that finishes BUNDLE negotiation, which means everything
3963 // should be bundled on the first transport (audio).
3964 cricket::MediaSessionOptions answer_options;
3965 answer_options.recv_video = true;
3966 answer_options.bundle_enabled = true;
3967 answer_options.data_channel_type = cricket::DCT_SCTP;
3968 SetRemoteDescriptionWithoutError(CreateRemoteAnswer(
3969 session_->local_description(), answer_options, cricket::SEC_DISABLED));
3970 ASSERT_TRUE(session_->sctp_content_name());
3971 ASSERT_TRUE(session_->sctp_transport_name());
3972 EXPECT_EQ("data", *session_->sctp_content_name());
3973 EXPECT_EQ("audio", *session_->sctp_transport_name());
3974 } 3891 }
3975 3892
3976 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { 3893 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) {
3977 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3894 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3978 3895
3979 InitWithDtls(GetParam()); 3896 InitWithDtls(GetParam());
3980 3897
3981 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3898 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3982 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); 3899 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL);
3983 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); 3900 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL);
(...skipping 11 matching lines...) Expand all
3995 CreateRemoteOffer(options, cricket::SEC_DISABLED); 3912 CreateRemoteOffer(options, cricket::SEC_DISABLED);
3996 SetRemoteDescriptionWithoutError(offer); 3913 SetRemoteDescriptionWithoutError(offer);
3997 3914
3998 // Verifies the answer contains SCTP. 3915 // Verifies the answer contains SCTP.
3999 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3916 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
4000 EXPECT_TRUE(answer != NULL); 3917 EXPECT_TRUE(answer != NULL);
4001 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); 3918 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL);
4002 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); 3919 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL);
4003 } 3920 }
4004 3921
4005 // Test that if DTLS is disabled, we don't end up with an SctpTransport
4006 // created (or an RtpDataChannel).
4007 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { 3922 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) {
4008 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false); 3923 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false);
4009 InitWithDtls(GetParam()); 3924 InitWithDtls(GetParam());
4010 3925
4011 SetLocalDescriptionWithDataChannel(); 3926 SetLocalDescriptionWithDataChannel();
4012 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 3927 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type());
4013 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport());
4014 } 3928 }
4015 3929
4016 // Test that if DTLS is enabled, we end up with an SctpTransport created
4017 // (and not an RtpDataChannel).
4018 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { 3930 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) {
4019 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3931 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4020 3932
4021 InitWithDtls(GetParam()); 3933 InitWithDtls(GetParam());
4022 3934
4023 SetLocalDescriptionWithDataChannel(); 3935 SetLocalDescriptionWithDataChannel();
4024 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 3936 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());
4025 EXPECT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport());
4026 } 3937 }
4027 3938
4028 // Test that if SCTP is disabled, we don't end up with an SctpTransport
4029 // created (or an RtpDataChannel).
4030 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) { 3939 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) {
4031 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3940 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4032 options_.disable_sctp_data_channels = true; 3941 options_.disable_sctp_data_channels = true;
4033 InitWithDtls(GetParam()); 3942 InitWithDtls(GetParam());
4034 3943
4035 SetLocalDescriptionWithDataChannel(); 3944 SetLocalDescriptionWithDataChannel();
4036 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 3945 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type());
4037 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport());
4038 } 3946 }
4039 3947
4040 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { 3948 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) {
4041 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3949 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4042 const int new_send_port = 9998; 3950 const int new_send_port = 9998;
4043 const int new_recv_port = 7775; 3951 const int new_recv_port = 7775;
4044 3952
4045 InitWithDtls(GetParam()); 3953 InitWithDtls(GetParam());
4046 SetFactoryDtlsSrtp(); 3954 SetFactoryDtlsSrtp();
4047 3955
(...skipping 10 matching lines...) Expand all
4058 3966
4059 SessionDescriptionInterface* answer = 3967 SessionDescriptionInterface* answer =
4060 ChangeSDPSctpPort(new_recv_port, CreateAnswer()); 3968 ChangeSDPSctpPort(new_recv_port, CreateAnswer());
4061 ASSERT_TRUE(answer != NULL); 3969 ASSERT_TRUE(answer != NULL);
4062 3970
4063 // Now set the local description, which'll take ownership of the answer. 3971 // Now set the local description, which'll take ownership of the answer.
4064 SetLocalDescriptionWithoutError(answer); 3972 SetLocalDescriptionWithoutError(answer);
4065 3973
4066 // TEST PLAN: Set the port number to something new, set it in the SDP, 3974 // TEST PLAN: Set the port number to something new, set it in the SDP,
4067 // and pass it all the way down. 3975 // and pass it all the way down.
4068 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 3976 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());
4069 CreateDataChannel(); 3977 CreateDataChannel();
4070 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); 3978
4071 EXPECT_EQ( 3979 cricket::FakeDataMediaChannel* ch = data_engine_->GetChannel(0);
4072 new_recv_port, 3980 int portnum = -1;
4073 fake_sctp_transport_factory_->last_fake_sctp_transport()->local_port()); 3981 ASSERT_TRUE(ch != NULL);
4074 EXPECT_EQ( 3982 ASSERT_EQ(1UL, ch->send_codecs().size());
4075 new_send_port, 3983 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, ch->send_codecs()[0].id);
4076 fake_sctp_transport_factory_->last_fake_sctp_transport()->remote_port()); 3984 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName,
3985 ch->send_codecs()[0].name.c_str()));
3986 EXPECT_TRUE(ch->send_codecs()[0].GetParam(cricket::kCodecParamPort,
3987 &portnum));
3988 EXPECT_EQ(new_send_port, portnum);
3989
3990 ASSERT_EQ(1UL, ch->recv_codecs().size());
3991 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, ch->recv_codecs()[0].id);
3992 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName,
3993 ch->recv_codecs()[0].name.c_str()));
3994 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort,
3995 &portnum));
3996 EXPECT_EQ(new_recv_port, portnum);
4077 } 3997 }
4078 3998
4079 // Verifies that when a session's SctpTransport receives an OPEN message, 3999 // Verifies that when a session's DataChannel receives an OPEN message,
4080 // WebRtcSession signals the SctpTransport creation request with the expected 4000 // WebRtcSession signals the DataChannel creation request with the expected
4081 // config. 4001 // config.
4082 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) { 4002 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) {
4083 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4003 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4084 4004
4085 InitWithDtls(GetParam()); 4005 InitWithDtls(GetParam());
4086 4006
4087 SetLocalDescriptionWithDataChannel(); 4007 SetLocalDescriptionWithDataChannel();
4088 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 4008 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());
4089 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport());
4090 4009
4091 // Make the fake SCTP transport pretend it received an OPEN message.
4092 webrtc::DataChannelInit config; 4010 webrtc::DataChannelInit config;
4093 config.id = 1; 4011 config.id = 1;
4094 rtc::CopyOnWriteBuffer payload; 4012 rtc::CopyOnWriteBuffer payload;
4095 webrtc::WriteDataChannelOpenMessage("a", config, &payload); 4013 webrtc::WriteDataChannelOpenMessage("a", config, &payload);
4096 cricket::ReceiveDataParams params; 4014 cricket::ReceiveDataParams params;
4097 params.ssrc = config.id; 4015 params.ssrc = config.id;
4098 params.type = cricket::DMT_CONTROL; 4016 params.type = cricket::DMT_CONTROL;
4099 fake_sctp_transport_factory_->last_fake_sctp_transport()->SignalDataReceived(
4100 params, payload);
4101 4017
4102 EXPECT_EQ_WAIT("a", last_data_channel_label_, kDefaultTimeout); 4018 cricket::DataChannel* data_channel = session_->data_channel();
4019 data_channel->SignalDataReceived(data_channel, params, payload);
4020
4021 EXPECT_EQ("a", last_data_channel_label_);
4103 EXPECT_EQ(config.id, last_data_channel_config_.id); 4022 EXPECT_EQ(config.id, last_data_channel_config_.id);
4104 EXPECT_FALSE(last_data_channel_config_.negotiated); 4023 EXPECT_FALSE(last_data_channel_config_.negotiated);
4105 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker, 4024 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker,
4106 last_data_channel_config_.open_handshake_role); 4025 last_data_channel_config_.open_handshake_role);
4107 } 4026 }
4108 4027
4109 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) { 4028 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) {
4110 rtc::scoped_refptr<rtc::RTCCertificate> certificate = 4029 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
4111 FakeRTCCertificateGenerator::GenerateCertificate(); 4030 FakeRTCCertificateGenerator::GenerateCertificate();
4112 4031
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 } 4361 }
4443 4362
4444 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4363 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4445 // currently fails because upon disconnection and reconnection OnIceComplete is 4364 // currently fails because upon disconnection and reconnection OnIceComplete is
4446 // called more than once without returning to IceGatheringGathering. 4365 // called more than once without returning to IceGatheringGathering.
4447 4366
4448 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4367 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4449 WebRtcSessionTest, 4368 WebRtcSessionTest,
4450 testing::Values(ALREADY_GENERATED, 4369 testing::Values(ALREADY_GENERATED,
4451 DTLS_IDENTITY_STORE)); 4370 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/api/webrtcsessiondescriptionfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698