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