| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 typedef std::vector<rtc::scoped_refptr<DataChannelInterface> > | 49 typedef std::vector<rtc::scoped_refptr<DataChannelInterface> > |
| 50 DataChannelList; | 50 DataChannelList; |
| 51 | 51 |
| 52 PeerConnectionEndToEndTest() { | 52 PeerConnectionEndToEndTest() { |
| 53 RTC_CHECK(network_thread_.Start()); | 53 RTC_CHECK(network_thread_.Start()); |
| 54 RTC_CHECK(worker_thread_.Start()); | 54 RTC_CHECK(worker_thread_.Start()); |
| 55 caller_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( | 55 caller_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( |
| 56 "caller", &network_thread_, &worker_thread_); | 56 "caller", &network_thread_, &worker_thread_); |
| 57 callee_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( | 57 callee_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( |
| 58 "callee", &network_thread_, &worker_thread_); | 58 "callee", &network_thread_, &worker_thread_); |
| 59 webrtc::PeerConnectionInterface::IceServer ice_server; | |
| 60 ice_server.uri = "stun:stun.l.google.com:19302"; | |
| 61 config_.servers.push_back(ice_server); | |
| 62 | |
| 63 #ifdef WEBRTC_ANDROID | 59 #ifdef WEBRTC_ANDROID |
| 64 webrtc::InitializeAndroidObjects(); | 60 webrtc::InitializeAndroidObjects(); |
| 65 #endif | 61 #endif |
| 66 } | 62 } |
| 67 | 63 |
| 68 void CreatePcs() { | 64 void CreatePcs() { |
| 69 CreatePcs(NULL); | 65 CreatePcs(NULL); |
| 70 } | 66 } |
| 71 | 67 |
| 72 void CreatePcs(const MediaConstraintsInterface* pc_constraints) { | 68 void CreatePcs(const MediaConstraintsInterface* pc_constraints) { |
| 73 EXPECT_TRUE(caller_->CreatePc(pc_constraints, config_)); | 69 EXPECT_TRUE(caller_->CreatePc(pc_constraints)); |
| 74 EXPECT_TRUE(callee_->CreatePc(pc_constraints, config_)); | 70 EXPECT_TRUE(callee_->CreatePc(pc_constraints)); |
| 75 PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); | 71 PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); |
| 76 | 72 |
| 77 caller_->SignalOnDataChannel.connect( | 73 caller_->SignalOnDataChannel.connect( |
| 78 this, &PeerConnectionEndToEndTest::OnCallerAddedDataChanel); | 74 this, &PeerConnectionEndToEndTest::OnCallerAddedDataChanel); |
| 79 callee_->SignalOnDataChannel.connect( | 75 callee_->SignalOnDataChannel.connect( |
| 80 this, &PeerConnectionEndToEndTest::OnCalleeAddedDataChannel); | 76 this, &PeerConnectionEndToEndTest::OnCalleeAddedDataChannel); |
| 81 } | 77 } |
| 82 | 78 |
| 83 void GetAndAddUserMedia() { | 79 void GetAndAddUserMedia() { |
| 84 FakeConstraints audio_constraints; | 80 FakeConstraints audio_constraints; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 kMaxWait); | 155 kMaxWait); |
| 160 } | 156 } |
| 161 | 157 |
| 162 protected: | 158 protected: |
| 163 rtc::Thread network_thread_; | 159 rtc::Thread network_thread_; |
| 164 rtc::Thread worker_thread_; | 160 rtc::Thread worker_thread_; |
| 165 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; | 161 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; |
| 166 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; | 162 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; |
| 167 DataChannelList caller_signaled_data_channels_; | 163 DataChannelList caller_signaled_data_channels_; |
| 168 DataChannelList callee_signaled_data_channels_; | 164 DataChannelList callee_signaled_data_channels_; |
| 169 webrtc::PeerConnectionInterface::RTCConfiguration config_; | |
| 170 }; | 165 }; |
| 171 | 166 |
| 172 // Disabled for TSan v2, see | 167 // Disabled for TSan v2, see |
| 173 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4719 for details. | 168 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4719 for details. |
| 174 // Disabled for Mac, see | 169 // Disabled for Mac, see |
| 175 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5231 for details. | 170 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5231 for details. |
| 176 #if !defined(THREAD_SANITIZER) && !defined(WEBRTC_MAC) | 171 #if !defined(THREAD_SANITIZER) && !defined(WEBRTC_MAC) |
| 177 TEST_F(PeerConnectionEndToEndTest, Call) { | 172 TEST_F(PeerConnectionEndToEndTest, Call) { |
| 178 CreatePcs(); | 173 CreatePcs(); |
| 179 GetAndAddUserMedia(); | 174 GetAndAddUserMedia(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 caller_dc_1->Send(webrtc::DataBuffer(message_1)); | 306 caller_dc_1->Send(webrtc::DataBuffer(message_1)); |
| 312 EXPECT_EQ_WAIT(message_1, dc_1_observer->last_message(), kMaxWait); | 307 EXPECT_EQ_WAIT(message_1, dc_1_observer->last_message(), kMaxWait); |
| 313 | 308 |
| 314 caller_dc_2->Send(webrtc::DataBuffer(message_2)); | 309 caller_dc_2->Send(webrtc::DataBuffer(message_2)); |
| 315 EXPECT_EQ_WAIT(message_2, dc_2_observer->last_message(), kMaxWait); | 310 EXPECT_EQ_WAIT(message_2, dc_2_observer->last_message(), kMaxWait); |
| 316 | 311 |
| 317 EXPECT_EQ(1U, dc_1_observer->received_message_count()); | 312 EXPECT_EQ(1U, dc_1_observer->received_message_count()); |
| 318 EXPECT_EQ(1U, dc_2_observer->received_message_count()); | 313 EXPECT_EQ(1U, dc_2_observer->received_message_count()); |
| 319 } | 314 } |
| 320 | 315 |
| 321 #ifdef HAVE_QUIC | |
| 322 // Test that QUIC data channels can be used and that messages go to the correct | |
| 323 // remote data channel when both peers want to use QUIC. It is assumed that the | |
| 324 // application has externally negotiated the data channel parameters. | |
| 325 TEST_F(PeerConnectionEndToEndTest, MessageTransferBetweenQuicDataChannels) { | |
| 326 config_.enable_quic = true; | |
| 327 CreatePcs(); | |
| 328 | |
| 329 webrtc::DataChannelInit init_1; | |
| 330 init_1.id = 0; | |
| 331 init_1.ordered = false; | |
| 332 init_1.reliable = true; | |
| 333 | |
| 334 webrtc::DataChannelInit init_2; | |
| 335 init_2.id = 1; | |
| 336 init_2.ordered = false; | |
| 337 init_2.reliable = true; | |
| 338 | |
| 339 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( | |
| 340 caller_->CreateDataChannel("data", init_1)); | |
| 341 ASSERT_NE(nullptr, caller_dc_1); | |
| 342 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( | |
| 343 caller_->CreateDataChannel("data", init_2)); | |
| 344 ASSERT_NE(nullptr, caller_dc_2); | |
| 345 rtc::scoped_refptr<DataChannelInterface> callee_dc_1( | |
| 346 callee_->CreateDataChannel("data", init_1)); | |
| 347 ASSERT_NE(nullptr, callee_dc_1); | |
| 348 rtc::scoped_refptr<DataChannelInterface> callee_dc_2( | |
| 349 callee_->CreateDataChannel("data", init_2)); | |
| 350 ASSERT_NE(nullptr, callee_dc_2); | |
| 351 | |
| 352 Negotiate(); | |
| 353 WaitForConnection(); | |
| 354 EXPECT_TRUE_WAIT(caller_dc_1->state() == webrtc::DataChannelInterface::kOpen, | |
| 355 kMaxWait); | |
| 356 EXPECT_TRUE_WAIT(callee_dc_1->state() == webrtc::DataChannelInterface::kOpen, | |
| 357 kMaxWait); | |
| 358 EXPECT_TRUE_WAIT(caller_dc_2->state() == webrtc::DataChannelInterface::kOpen, | |
| 359 kMaxWait); | |
| 360 EXPECT_TRUE_WAIT(callee_dc_2->state() == webrtc::DataChannelInterface::kOpen, | |
| 361 kMaxWait); | |
| 362 | |
| 363 std::unique_ptr<webrtc::MockDataChannelObserver> dc_1_observer( | |
| 364 new webrtc::MockDataChannelObserver(callee_dc_1.get())); | |
| 365 | |
| 366 std::unique_ptr<webrtc::MockDataChannelObserver> dc_2_observer( | |
| 367 new webrtc::MockDataChannelObserver(callee_dc_2.get())); | |
| 368 | |
| 369 const std::string message_1 = "hello 1"; | |
| 370 const std::string message_2 = "hello 2"; | |
| 371 | |
| 372 // Send data from caller to callee. | |
| 373 caller_dc_1->Send(webrtc::DataBuffer(message_1)); | |
| 374 EXPECT_EQ_WAIT(message_1, dc_1_observer->last_message(), kMaxWait); | |
| 375 | |
| 376 caller_dc_2->Send(webrtc::DataBuffer(message_2)); | |
| 377 EXPECT_EQ_WAIT(message_2, dc_2_observer->last_message(), kMaxWait); | |
| 378 | |
| 379 EXPECT_EQ(1U, dc_1_observer->received_message_count()); | |
| 380 EXPECT_EQ(1U, dc_2_observer->received_message_count()); | |
| 381 | |
| 382 // Send data from callee to caller. | |
| 383 dc_1_observer.reset(new webrtc::MockDataChannelObserver(caller_dc_1.get())); | |
| 384 dc_2_observer.reset(new webrtc::MockDataChannelObserver(caller_dc_2.get())); | |
| 385 | |
| 386 callee_dc_1->Send(webrtc::DataBuffer(message_1)); | |
| 387 EXPECT_EQ_WAIT(message_1, dc_1_observer->last_message(), kMaxWait); | |
| 388 | |
| 389 callee_dc_2->Send(webrtc::DataBuffer(message_2)); | |
| 390 EXPECT_EQ_WAIT(message_2, dc_2_observer->last_message(), kMaxWait); | |
| 391 | |
| 392 EXPECT_EQ(1U, dc_1_observer->received_message_count()); | |
| 393 EXPECT_EQ(1U, dc_2_observer->received_message_count()); | |
| 394 } | |
| 395 #endif // HAVE_QUIC | |
| 396 | |
| 397 // Verifies that a DataChannel added from an OPEN message functions after | 316 // Verifies that a DataChannel added from an OPEN message functions after |
| 398 // a channel has been previously closed (webrtc issue 3778). | 317 // a channel has been previously closed (webrtc issue 3778). |
| 399 // This previously failed because the new channel re-uses the ID of the closed | 318 // This previously failed because the new channel re-uses the ID of the closed |
| 400 // channel, and the closed channel was incorrectly still assigned to the id. | 319 // channel, and the closed channel was incorrectly still assigned to the id. |
| 401 // TODO(deadbeef): This is disabled because there's currently a race condition | 320 // TODO(deadbeef): This is disabled because there's currently a race condition |
| 402 // caused by the fact that a data channel signals that it's closed before it | 321 // caused by the fact that a data channel signals that it's closed before it |
| 403 // really is. Re-enable this test once that's fixed. | 322 // really is. Re-enable this test once that's fixed. |
| 404 TEST_F(PeerConnectionEndToEndTest, | 323 TEST_F(PeerConnectionEndToEndTest, |
| 405 DISABLED_DataChannelFromOpenWorksAfterClose) { | 324 DISABLED_DataChannelFromOpenWorksAfterClose) { |
| 406 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 325 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 364 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
| 446 // This removes the reference to the remote data channel that we hold. | 365 // This removes the reference to the remote data channel that we hold. |
| 447 callee_signaled_data_channels_.clear(); | 366 callee_signaled_data_channels_.clear(); |
| 448 caller_dc->Close(); | 367 caller_dc->Close(); |
| 449 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); | 368 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); |
| 450 | 369 |
| 451 // Wait for a bit longer so the remote data channel will receive the | 370 // Wait for a bit longer so the remote data channel will receive the |
| 452 // close message and be destroyed. | 371 // close message and be destroyed. |
| 453 rtc::Thread::Current()->ProcessMessages(100); | 372 rtc::Thread::Current()->ProcessMessages(100); |
| 454 } | 373 } |
| OLD | NEW |