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