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 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | |
13 #include "webrtc/base/gunit.h" | 14 #include "webrtc/base/gunit.h" |
14 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
16 #include "webrtc/base/ptr_util.h" | |
15 #include "webrtc/base/ssladapter.h" | 17 #include "webrtc/base/ssladapter.h" |
16 #include "webrtc/base/thread.h" | |
17 #include "webrtc/base/sslstreamadapter.h" | 18 #include "webrtc/base/sslstreamadapter.h" |
18 #include "webrtc/base/stringencode.h" | 19 #include "webrtc/base/stringencode.h" |
19 #include "webrtc/base/stringutils.h" | 20 #include "webrtc/base/stringutils.h" |
21 #include "webrtc/base/thread.h" | |
20 #ifdef WEBRTC_ANDROID | 22 #ifdef WEBRTC_ANDROID |
21 #include "webrtc/pc/test/androidtestinitializer.h" | 23 #include "webrtc/pc/test/androidtestinitializer.h" |
22 #endif | 24 #endif |
23 #include "webrtc/pc/test/peerconnectiontestwrapper.h" | 25 #include "webrtc/pc/test/peerconnectiontestwrapper.h" |
24 // Notice that mockpeerconnectionobservers.h must be included after the above! | 26 // Notice that mockpeerconnectionobservers.h must be included after the above! |
25 #include "webrtc/pc/test/mockpeerconnectionobservers.h" | 27 #include "webrtc/pc/test/mockpeerconnectionobservers.h" |
28 #include "webrtc/test/mock_audio_decoder.h" | |
29 #include "webrtc/test/mock_audio_decoder_factory.h" | |
30 | |
31 using testing::AtLeast; | |
32 using testing::Invoke; | |
33 using testing::StrictMock; | |
34 using testing::_; | |
26 | 35 |
27 using webrtc::DataChannelInterface; | 36 using webrtc::DataChannelInterface; |
28 using webrtc::FakeConstraints; | 37 using webrtc::FakeConstraints; |
29 using webrtc::MediaConstraintsInterface; | 38 using webrtc::MediaConstraintsInterface; |
30 using webrtc::MediaStreamInterface; | 39 using webrtc::MediaStreamInterface; |
31 using webrtc::PeerConnectionInterface; | 40 using webrtc::PeerConnectionInterface; |
32 | 41 |
33 namespace { | 42 namespace { |
34 | 43 |
35 const int kMaxWait = 10000; | 44 const int kMaxWait = 10000; |
(...skipping 16 matching lines...) Expand all Loading... | |
52 "callee", &network_thread_, &worker_thread_); | 61 "callee", &network_thread_, &worker_thread_); |
53 webrtc::PeerConnectionInterface::IceServer ice_server; | 62 webrtc::PeerConnectionInterface::IceServer ice_server; |
54 ice_server.uri = "stun:stun.l.google.com:19302"; | 63 ice_server.uri = "stun:stun.l.google.com:19302"; |
55 config_.servers.push_back(ice_server); | 64 config_.servers.push_back(ice_server); |
56 | 65 |
57 #ifdef WEBRTC_ANDROID | 66 #ifdef WEBRTC_ANDROID |
58 webrtc::InitializeAndroidObjects(); | 67 webrtc::InitializeAndroidObjects(); |
59 #endif | 68 #endif |
60 } | 69 } |
61 | 70 |
62 void CreatePcs() { | 71 void CreatePcs( |
63 CreatePcs(NULL); | 72 const MediaConstraintsInterface* pc_constraints, |
64 } | 73 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, |
65 | 74 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) { |
66 void CreatePcs(const MediaConstraintsInterface* pc_constraints) { | 75 EXPECT_TRUE(caller_->CreatePc( |
67 EXPECT_TRUE(caller_->CreatePc(pc_constraints, config_)); | 76 pc_constraints, config_, audio_encoder_factory, audio_decoder_factory)); |
68 EXPECT_TRUE(callee_->CreatePc(pc_constraints, config_)); | 77 EXPECT_TRUE(callee_->CreatePc( |
78 pc_constraints, config_, audio_encoder_factory, audio_decoder_factory)); | |
69 PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); | 79 PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); |
70 | 80 |
71 caller_->SignalOnDataChannel.connect( | 81 caller_->SignalOnDataChannel.connect( |
72 this, &PeerConnectionEndToEndTest::OnCallerAddedDataChanel); | 82 this, &PeerConnectionEndToEndTest::OnCallerAddedDataChanel); |
73 callee_->SignalOnDataChannel.connect( | 83 callee_->SignalOnDataChannel.connect( |
74 this, &PeerConnectionEndToEndTest::OnCalleeAddedDataChannel); | 84 this, &PeerConnectionEndToEndTest::OnCalleeAddedDataChannel); |
75 } | 85 } |
76 | 86 |
77 void GetAndAddUserMedia() { | 87 void GetAndAddUserMedia() { |
78 FakeConstraints audio_constraints; | 88 FakeConstraints audio_constraints; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 protected: | 166 protected: |
157 rtc::Thread network_thread_; | 167 rtc::Thread network_thread_; |
158 rtc::Thread worker_thread_; | 168 rtc::Thread worker_thread_; |
159 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; | 169 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; |
160 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; | 170 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; |
161 DataChannelList caller_signaled_data_channels_; | 171 DataChannelList caller_signaled_data_channels_; |
162 DataChannelList callee_signaled_data_channels_; | 172 DataChannelList callee_signaled_data_channels_; |
163 webrtc::PeerConnectionInterface::RTCConfiguration config_; | 173 webrtc::PeerConnectionInterface::RTCConfiguration config_; |
164 }; | 174 }; |
165 | 175 |
176 std::unique_ptr<webrtc::AudioDecoder> CreateForwardingMockDecoder( | |
177 std::unique_ptr<webrtc::AudioDecoder> real_decoder) { | |
178 class ForwardingMockDecoder : public StrictMock<webrtc::MockAudioDecoder> { | |
179 public: | |
180 ForwardingMockDecoder(std::unique_ptr<AudioDecoder> decoder) | |
181 : decoder_(std::move(decoder)) {} | |
182 | |
183 private: | |
184 std::unique_ptr<AudioDecoder> decoder_; | |
185 }; | |
186 | |
187 const auto dec = real_decoder.get(); // For lambda capturing. | |
188 auto mock_decoder = | |
189 rtc::MakeUnique<ForwardingMockDecoder>(std::move(real_decoder)); | |
190 EXPECT_CALL(*mock_decoder, Channels()) | |
191 .Times(AtLeast(1)) | |
192 .WillRepeatedly(Invoke([dec] { return dec->Channels(); })); | |
193 EXPECT_CALL(*mock_decoder, DecodeInternal(_, _, _, _, _)) | |
194 .Times(AtLeast(1)) | |
195 .WillRepeatedly( | |
196 Invoke([dec](const uint8_t* encoded, size_t encoded_len, | |
197 int sample_rate_hz, int16_t* decoded, | |
198 webrtc::AudioDecoder::SpeechType* speech_type) { | |
199 return dec->Decode(encoded, encoded_len, sample_rate_hz, | |
200 std::numeric_limits<size_t>::max(), decoded, | |
201 speech_type); | |
202 })); | |
203 EXPECT_CALL(*mock_decoder, Die()); | |
204 EXPECT_CALL(*mock_decoder, HasDecodePlc()).WillRepeatedly(Invoke([dec] { | |
205 return dec->HasDecodePlc(); | |
206 })); | |
207 EXPECT_CALL(*mock_decoder, IncomingPacket(_, _, _, _, _)) | |
208 .Times(AtLeast(1)) | |
209 .WillRepeatedly(Invoke([dec](const uint8_t* payload, size_t payload_len, | |
210 uint16_t rtp_sequence_number, | |
211 uint32_t rtp_timestamp, | |
212 uint32_t arrival_timestamp) { | |
213 return dec->IncomingPacket(payload, payload_len, rtp_sequence_number, | |
214 rtp_timestamp, arrival_timestamp); | |
215 })); | |
216 EXPECT_CALL(*mock_decoder, PacketDuration(_, _)) | |
217 .Times(AtLeast(1)) | |
218 .WillRepeatedly(Invoke([dec](const uint8_t* encoded, size_t encoded_len) { | |
219 return dec->PacketDuration(encoded, encoded_len); | |
220 })); | |
221 EXPECT_CALL(*mock_decoder, SampleRateHz()) | |
222 .Times(AtLeast(1)) | |
223 .WillRepeatedly(Invoke([dec] { return dec->SampleRateHz(); })); | |
224 | |
225 return std::move(mock_decoder); | |
226 } | |
227 | |
228 rtc::scoped_refptr<webrtc::AudioDecoderFactory> | |
229 CreateForwardingMockDecoderFactory( | |
230 webrtc::AudioDecoderFactory* real_decoder_factory) { | |
231 rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> mock_decoder_factory = | |
232 new rtc::RefCountedObject<StrictMock<webrtc::MockAudioDecoderFactory>>; | |
233 EXPECT_CALL(*mock_decoder_factory, GetSupportedDecoders()) | |
234 .Times(AtLeast(1)) | |
235 .WillRepeatedly(Invoke([real_decoder_factory] { | |
236 return real_decoder_factory->GetSupportedDecoders(); | |
237 })); | |
238 EXPECT_CALL(*mock_decoder_factory, IsSupportedDecoder(_)) | |
239 .Times(AtLeast(1)) | |
240 .WillRepeatedly( | |
241 Invoke([real_decoder_factory](const webrtc::SdpAudioFormat& format) { | |
242 return real_decoder_factory->IsSupportedDecoder(format); | |
243 })); | |
244 EXPECT_CALL(*mock_decoder_factory, MakeAudioDecoderMock(_, _)) | |
245 .Times(AtLeast(2)) | |
246 .WillRepeatedly( | |
247 Invoke([real_decoder_factory]( | |
248 const webrtc::SdpAudioFormat& format, | |
249 std::unique_ptr<webrtc::AudioDecoder>* return_value) { | |
250 auto real_decoder = real_decoder_factory->MakeAudioDecoder(format); | |
251 *return_value = | |
252 real_decoder | |
253 ? CreateForwardingMockDecoder(std::move(real_decoder)) | |
254 : nullptr; | |
255 })); | |
256 return mock_decoder_factory; | |
257 } | |
258 | |
166 // Disabled for TSan v2, see | 259 // Disabled for TSan v2, see |
167 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4719 for details. | 260 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4719 for details. |
168 // Disabled for Mac, see | 261 // Disabled for Mac, see |
169 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5231 for details. | 262 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5231 for details. |
170 #if !defined(THREAD_SANITIZER) && !defined(WEBRTC_MAC) | 263 #if !defined(THREAD_SANITIZER) && !defined(WEBRTC_MAC) |
171 TEST_F(PeerConnectionEndToEndTest, Call) { | 264 TEST_F(PeerConnectionEndToEndTest, Call) { |
172 CreatePcs(); | 265 rtc::scoped_refptr<webrtc::AudioDecoderFactory> real_decoder_factory = |
266 webrtc::CreateBuiltinAudioDecoderFactory(); | |
267 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | |
268 CreateForwardingMockDecoderFactory(real_decoder_factory.get())); | |
the sun
2017/04/18 10:38:21
What's the rationale for only using the mocks here
kwiberg-webrtc
2017/04/18 10:56:08
IIRC only the two Call* tests actually decode audi
| |
173 GetAndAddUserMedia(); | 269 GetAndAddUserMedia(); |
174 Negotiate(); | 270 Negotiate(); |
175 WaitForCallEstablished(); | 271 WaitForCallEstablished(); |
176 } | 272 } |
177 #endif // if !defined(THREAD_SANITIZER) && !defined(WEBRTC_MAC) | 273 #endif // if !defined(THREAD_SANITIZER) && !defined(WEBRTC_MAC) |
178 | 274 |
179 #if !defined(ADDRESS_SANITIZER) | 275 #if !defined(ADDRESS_SANITIZER) |
180 TEST_F(PeerConnectionEndToEndTest, CallWithLegacySdp) { | 276 TEST_F(PeerConnectionEndToEndTest, CallWithLegacySdp) { |
181 FakeConstraints pc_constraints; | 277 FakeConstraints pc_constraints; |
182 pc_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 278 pc_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
183 false); | 279 false); |
184 CreatePcs(&pc_constraints); | 280 CreatePcs(&pc_constraints, webrtc::CreateBuiltinAudioEncoderFactory(), |
281 webrtc::CreateBuiltinAudioDecoderFactory()); | |
185 GetAndAddUserMedia(); | 282 GetAndAddUserMedia(); |
186 Negotiate(); | 283 Negotiate(); |
187 WaitForCallEstablished(); | 284 WaitForCallEstablished(); |
188 } | 285 } |
189 #endif // !defined(ADDRESS_SANITIZER) | 286 #endif // !defined(ADDRESS_SANITIZER) |
190 | 287 |
191 #ifdef HAVE_SCTP | 288 #ifdef HAVE_SCTP |
192 // Verifies that a DataChannel created before the negotiation can transition to | 289 // Verifies that a DataChannel created before the negotiation can transition to |
193 // "OPEN" and transfer data. | 290 // "OPEN" and transfer data. |
194 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) { | 291 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) { |
195 CreatePcs(); | 292 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
293 webrtc::CreateBuiltinAudioDecoderFactory()); | |
196 | 294 |
197 webrtc::DataChannelInit init; | 295 webrtc::DataChannelInit init; |
198 rtc::scoped_refptr<DataChannelInterface> caller_dc( | 296 rtc::scoped_refptr<DataChannelInterface> caller_dc( |
199 caller_->CreateDataChannel("data", init)); | 297 caller_->CreateDataChannel("data", init)); |
200 rtc::scoped_refptr<DataChannelInterface> callee_dc( | 298 rtc::scoped_refptr<DataChannelInterface> callee_dc( |
201 callee_->CreateDataChannel("data", init)); | 299 callee_->CreateDataChannel("data", init)); |
202 | 300 |
203 Negotiate(); | 301 Negotiate(); |
204 WaitForConnection(); | 302 WaitForConnection(); |
205 | 303 |
206 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 304 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
207 WaitForDataChannelsToOpen(callee_dc, caller_signaled_data_channels_, 0); | 305 WaitForDataChannelsToOpen(callee_dc, caller_signaled_data_channels_, 0); |
208 | 306 |
209 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[0]); | 307 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[0]); |
210 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); | 308 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); |
211 | 309 |
212 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); | 310 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); |
213 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); | 311 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); |
214 } | 312 } |
215 | 313 |
216 // Verifies that a DataChannel created after the negotiation can transition to | 314 // Verifies that a DataChannel created after the negotiation can transition to |
217 // "OPEN" and transfer data. | 315 // "OPEN" and transfer data. |
218 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) { | 316 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) { |
219 CreatePcs(); | 317 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
318 webrtc::CreateBuiltinAudioDecoderFactory()); | |
220 | 319 |
221 webrtc::DataChannelInit init; | 320 webrtc::DataChannelInit init; |
222 | 321 |
223 // This DataChannel is for creating the data content in the negotiation. | 322 // This DataChannel is for creating the data content in the negotiation. |
224 rtc::scoped_refptr<DataChannelInterface> dummy( | 323 rtc::scoped_refptr<DataChannelInterface> dummy( |
225 caller_->CreateDataChannel("data", init)); | 324 caller_->CreateDataChannel("data", init)); |
226 Negotiate(); | 325 Negotiate(); |
227 WaitForConnection(); | 326 WaitForConnection(); |
228 | 327 |
229 // Wait for the data channel created pre-negotiation to be opened. | 328 // Wait for the data channel created pre-negotiation to be opened. |
(...skipping 10 matching lines...) Expand all Loading... | |
240 | 339 |
241 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); | 340 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); |
242 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); | 341 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); |
243 | 342 |
244 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); | 343 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); |
245 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); | 344 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); |
246 } | 345 } |
247 | 346 |
248 // Verifies that DataChannel IDs are even/odd based on the DTLS roles. | 347 // Verifies that DataChannel IDs are even/odd based on the DTLS roles. |
249 TEST_F(PeerConnectionEndToEndTest, DataChannelIdAssignment) { | 348 TEST_F(PeerConnectionEndToEndTest, DataChannelIdAssignment) { |
250 CreatePcs(); | 349 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
350 webrtc::CreateBuiltinAudioDecoderFactory()); | |
251 | 351 |
252 webrtc::DataChannelInit init; | 352 webrtc::DataChannelInit init; |
253 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( | 353 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( |
254 caller_->CreateDataChannel("data", init)); | 354 caller_->CreateDataChannel("data", init)); |
255 rtc::scoped_refptr<DataChannelInterface> callee_dc_1( | 355 rtc::scoped_refptr<DataChannelInterface> callee_dc_1( |
256 callee_->CreateDataChannel("data", init)); | 356 callee_->CreateDataChannel("data", init)); |
257 | 357 |
258 Negotiate(); | 358 Negotiate(); |
259 WaitForConnection(); | 359 WaitForConnection(); |
260 | 360 |
261 EXPECT_EQ(1U, caller_dc_1->id() % 2); | 361 EXPECT_EQ(1U, caller_dc_1->id() % 2); |
262 EXPECT_EQ(0U, callee_dc_1->id() % 2); | 362 EXPECT_EQ(0U, callee_dc_1->id() % 2); |
263 | 363 |
264 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( | 364 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( |
265 caller_->CreateDataChannel("data", init)); | 365 caller_->CreateDataChannel("data", init)); |
266 rtc::scoped_refptr<DataChannelInterface> callee_dc_2( | 366 rtc::scoped_refptr<DataChannelInterface> callee_dc_2( |
267 callee_->CreateDataChannel("data", init)); | 367 callee_->CreateDataChannel("data", init)); |
268 | 368 |
269 EXPECT_EQ(1U, caller_dc_2->id() % 2); | 369 EXPECT_EQ(1U, caller_dc_2->id() % 2); |
270 EXPECT_EQ(0U, callee_dc_2->id() % 2); | 370 EXPECT_EQ(0U, callee_dc_2->id() % 2); |
271 } | 371 } |
272 | 372 |
273 // Verifies that the message is received by the right remote DataChannel when | 373 // Verifies that the message is received by the right remote DataChannel when |
274 // there are multiple DataChannels. | 374 // there are multiple DataChannels. |
275 TEST_F(PeerConnectionEndToEndTest, | 375 TEST_F(PeerConnectionEndToEndTest, |
276 MessageTransferBetweenTwoPairsOfDataChannels) { | 376 MessageTransferBetweenTwoPairsOfDataChannels) { |
277 CreatePcs(); | 377 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
378 webrtc::CreateBuiltinAudioDecoderFactory()); | |
278 | 379 |
279 webrtc::DataChannelInit init; | 380 webrtc::DataChannelInit init; |
280 | 381 |
281 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( | 382 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( |
282 caller_->CreateDataChannel("data", init)); | 383 caller_->CreateDataChannel("data", init)); |
283 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( | 384 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( |
284 caller_->CreateDataChannel("data", init)); | 385 caller_->CreateDataChannel("data", init)); |
285 | 386 |
286 Negotiate(); | 387 Negotiate(); |
287 WaitForConnection(); | 388 WaitForConnection(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 // Verifies that a DataChannel added from an OPEN message functions after | 489 // Verifies that a DataChannel added from an OPEN message functions after |
389 // a channel has been previously closed (webrtc issue 3778). | 490 // a channel has been previously closed (webrtc issue 3778). |
390 // This previously failed because the new channel re-uses the ID of the closed | 491 // This previously failed because the new channel re-uses the ID of the closed |
391 // channel, and the closed channel was incorrectly still assigned to the id. | 492 // channel, and the closed channel was incorrectly still assigned to the id. |
392 // TODO(deadbeef): This is disabled because there's currently a race condition | 493 // TODO(deadbeef): This is disabled because there's currently a race condition |
393 // caused by the fact that a data channel signals that it's closed before it | 494 // caused by the fact that a data channel signals that it's closed before it |
394 // really is. Re-enable this test once that's fixed. | 495 // really is. Re-enable this test once that's fixed. |
395 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4453 | 496 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4453 |
396 TEST_F(PeerConnectionEndToEndTest, | 497 TEST_F(PeerConnectionEndToEndTest, |
397 DISABLED_DataChannelFromOpenWorksAfterClose) { | 498 DISABLED_DataChannelFromOpenWorksAfterClose) { |
398 CreatePcs(); | 499 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
500 webrtc::CreateBuiltinAudioDecoderFactory()); | |
399 | 501 |
400 webrtc::DataChannelInit init; | 502 webrtc::DataChannelInit init; |
401 rtc::scoped_refptr<DataChannelInterface> caller_dc( | 503 rtc::scoped_refptr<DataChannelInterface> caller_dc( |
402 caller_->CreateDataChannel("data", init)); | 504 caller_->CreateDataChannel("data", init)); |
403 | 505 |
404 Negotiate(); | 506 Negotiate(); |
405 WaitForConnection(); | 507 WaitForConnection(); |
406 | 508 |
407 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 509 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
408 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); | 510 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); |
409 | 511 |
410 // Create a new channel and ensure it works after closing the previous one. | 512 // Create a new channel and ensure it works after closing the previous one. |
411 caller_dc = caller_->CreateDataChannel("data2", init); | 513 caller_dc = caller_->CreateDataChannel("data2", init); |
412 | 514 |
413 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 1); | 515 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 1); |
414 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); | 516 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); |
415 | 517 |
416 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); | 518 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); |
417 } | 519 } |
418 | 520 |
419 // This tests that if a data channel is closed remotely while not referenced | 521 // This tests that if a data channel is closed remotely while not referenced |
420 // by the application (meaning only the PeerConnection contributes to its | 522 // by the application (meaning only the PeerConnection contributes to its |
421 // reference count), no memory access violation will occur. | 523 // reference count), no memory access violation will occur. |
422 // See: https://code.google.com/p/chromium/issues/detail?id=565048 | 524 // See: https://code.google.com/p/chromium/issues/detail?id=565048 |
423 TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) { | 525 TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) { |
424 CreatePcs(); | 526 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
527 webrtc::CreateBuiltinAudioDecoderFactory()); | |
425 | 528 |
426 webrtc::DataChannelInit init; | 529 webrtc::DataChannelInit init; |
427 rtc::scoped_refptr<DataChannelInterface> caller_dc( | 530 rtc::scoped_refptr<DataChannelInterface> caller_dc( |
428 caller_->CreateDataChannel("data", init)); | 531 caller_->CreateDataChannel("data", init)); |
429 | 532 |
430 Negotiate(); | 533 Negotiate(); |
431 WaitForConnection(); | 534 WaitForConnection(); |
432 | 535 |
433 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 536 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
434 // This removes the reference to the remote data channel that we hold. | 537 // This removes the reference to the remote data channel that we hold. |
435 callee_signaled_data_channels_.clear(); | 538 callee_signaled_data_channels_.clear(); |
436 caller_dc->Close(); | 539 caller_dc->Close(); |
437 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); | 540 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); |
438 | 541 |
439 // Wait for a bit longer so the remote data channel will receive the | 542 // Wait for a bit longer so the remote data channel will receive the |
440 // close message and be destroyed. | 543 // close message and be destroyed. |
441 rtc::Thread::Current()->ProcessMessages(100); | 544 rtc::Thread::Current()->ProcessMessages(100); |
442 } | 545 } |
443 #endif // HAVE_SCTP | 546 #endif // HAVE_SCTP |
OLD | NEW |