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