| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 Negotiate(); | 283 Negotiate(); |
| 284 WaitForCallEstablished(); | 284 WaitForCallEstablished(); |
| 285 } | 285 } |
| 286 #endif // !defined(ADDRESS_SANITIZER) | 286 #endif // !defined(ADDRESS_SANITIZER) |
| 287 | 287 |
| 288 #ifdef HAVE_SCTP | 288 #ifdef HAVE_SCTP |
| 289 // Verifies that a DataChannel created before the negotiation can transition to | 289 // Verifies that a DataChannel created before the negotiation can transition to |
| 290 // "OPEN" and transfer data. | 290 // "OPEN" and transfer data. |
| 291 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) { | 291 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) { |
| 292 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | 292 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
| 293 webrtc::CreateBuiltinAudioDecoderFactory()); | 293 webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); |
| 294 | 294 |
| 295 webrtc::DataChannelInit init; | 295 webrtc::DataChannelInit init; |
| 296 rtc::scoped_refptr<DataChannelInterface> caller_dc( | 296 rtc::scoped_refptr<DataChannelInterface> caller_dc( |
| 297 caller_->CreateDataChannel("data", init)); | 297 caller_->CreateDataChannel("data", init)); |
| 298 rtc::scoped_refptr<DataChannelInterface> callee_dc( | 298 rtc::scoped_refptr<DataChannelInterface> callee_dc( |
| 299 callee_->CreateDataChannel("data", init)); | 299 callee_->CreateDataChannel("data", init)); |
| 300 | 300 |
| 301 Negotiate(); | 301 Negotiate(); |
| 302 WaitForConnection(); | 302 WaitForConnection(); |
| 303 | 303 |
| 304 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 304 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
| 305 WaitForDataChannelsToOpen(callee_dc, caller_signaled_data_channels_, 0); | 305 WaitForDataChannelsToOpen(callee_dc, caller_signaled_data_channels_, 0); |
| 306 | 306 |
| 307 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[0]); | 307 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[0]); |
| 308 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); | 308 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); |
| 309 | 309 |
| 310 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); | 310 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); |
| 311 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); | 311 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // Verifies that a DataChannel created after the negotiation can transition to | 314 // Verifies that a DataChannel created after the negotiation can transition to |
| 315 // "OPEN" and transfer data. | 315 // "OPEN" and transfer data. |
| 316 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) { | 316 TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) { |
| 317 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | 317 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
| 318 webrtc::CreateBuiltinAudioDecoderFactory()); | 318 webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); |
| 319 | 319 |
| 320 webrtc::DataChannelInit init; | 320 webrtc::DataChannelInit init; |
| 321 | 321 |
| 322 // This DataChannel is for creating the data content in the negotiation. | 322 // This DataChannel is for creating the data content in the negotiation. |
| 323 rtc::scoped_refptr<DataChannelInterface> dummy( | 323 rtc::scoped_refptr<DataChannelInterface> dummy( |
| 324 caller_->CreateDataChannel("data", init)); | 324 caller_->CreateDataChannel("data", init)); |
| 325 Negotiate(); | 325 Negotiate(); |
| 326 WaitForConnection(); | 326 WaitForConnection(); |
| 327 | 327 |
| 328 // Wait for the data channel created pre-negotiation to be opened. | 328 // Wait for the data channel created pre-negotiation to be opened. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 340 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); | 340 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); |
| 341 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); | 341 TestDataChannelSendAndReceive(callee_dc, caller_signaled_data_channels_[0]); |
| 342 | 342 |
| 343 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); | 343 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); |
| 344 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); | 344 CloseDataChannels(callee_dc, caller_signaled_data_channels_, 0); |
| 345 } | 345 } |
| 346 | 346 |
| 347 // 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. |
| 348 TEST_F(PeerConnectionEndToEndTest, DataChannelIdAssignment) { | 348 TEST_F(PeerConnectionEndToEndTest, DataChannelIdAssignment) { |
| 349 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | 349 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
| 350 webrtc::CreateBuiltinAudioDecoderFactory()); | 350 webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); |
| 351 | 351 |
| 352 webrtc::DataChannelInit init; | 352 webrtc::DataChannelInit init; |
| 353 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( | 353 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( |
| 354 caller_->CreateDataChannel("data", init)); | 354 caller_->CreateDataChannel("data", init)); |
| 355 rtc::scoped_refptr<DataChannelInterface> callee_dc_1( | 355 rtc::scoped_refptr<DataChannelInterface> callee_dc_1( |
| 356 callee_->CreateDataChannel("data", init)); | 356 callee_->CreateDataChannel("data", init)); |
| 357 | 357 |
| 358 Negotiate(); | 358 Negotiate(); |
| 359 WaitForConnection(); | 359 WaitForConnection(); |
| 360 | 360 |
| 361 EXPECT_EQ(1U, caller_dc_1->id() % 2); | 361 EXPECT_EQ(1U, caller_dc_1->id() % 2); |
| 362 EXPECT_EQ(0U, callee_dc_1->id() % 2); | 362 EXPECT_EQ(0U, callee_dc_1->id() % 2); |
| 363 | 363 |
| 364 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( | 364 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( |
| 365 caller_->CreateDataChannel("data", init)); | 365 caller_->CreateDataChannel("data", init)); |
| 366 rtc::scoped_refptr<DataChannelInterface> callee_dc_2( | 366 rtc::scoped_refptr<DataChannelInterface> callee_dc_2( |
| 367 callee_->CreateDataChannel("data", init)); | 367 callee_->CreateDataChannel("data", init)); |
| 368 | 368 |
| 369 EXPECT_EQ(1U, caller_dc_2->id() % 2); | 369 EXPECT_EQ(1U, caller_dc_2->id() % 2); |
| 370 EXPECT_EQ(0U, callee_dc_2->id() % 2); | 370 EXPECT_EQ(0U, callee_dc_2->id() % 2); |
| 371 } | 371 } |
| 372 | 372 |
| 373 // 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 |
| 374 // there are multiple DataChannels. | 374 // there are multiple DataChannels. |
| 375 TEST_F(PeerConnectionEndToEndTest, | 375 TEST_F(PeerConnectionEndToEndTest, |
| 376 MessageTransferBetweenTwoPairsOfDataChannels) { | 376 MessageTransferBetweenTwoPairsOfDataChannels) { |
| 377 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | 377 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
| 378 webrtc::CreateBuiltinAudioDecoderFactory()); | 378 webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); |
| 379 | 379 |
| 380 webrtc::DataChannelInit init; | 380 webrtc::DataChannelInit init; |
| 381 | 381 |
| 382 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( | 382 rtc::scoped_refptr<DataChannelInterface> caller_dc_1( |
| 383 caller_->CreateDataChannel("data", init)); | 383 caller_->CreateDataChannel("data", init)); |
| 384 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( | 384 rtc::scoped_refptr<DataChannelInterface> caller_dc_2( |
| 385 caller_->CreateDataChannel("data", init)); | 385 caller_->CreateDataChannel("data", init)); |
| 386 | 386 |
| 387 Negotiate(); | 387 Negotiate(); |
| 388 WaitForConnection(); | 388 WaitForConnection(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // a channel has been previously closed (webrtc issue 3778). | 490 // a channel has been previously closed (webrtc issue 3778). |
| 491 // 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 |
| 492 // 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. |
| 493 // 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 |
| 494 // 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 |
| 495 // really is. Re-enable this test once that's fixed. | 495 // really is. Re-enable this test once that's fixed. |
| 496 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4453 | 496 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4453 |
| 497 TEST_F(PeerConnectionEndToEndTest, | 497 TEST_F(PeerConnectionEndToEndTest, |
| 498 DISABLED_DataChannelFromOpenWorksAfterClose) { | 498 DISABLED_DataChannelFromOpenWorksAfterClose) { |
| 499 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | 499 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
| 500 webrtc::CreateBuiltinAudioDecoderFactory()); | 500 webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); |
| 501 | 501 |
| 502 webrtc::DataChannelInit init; | 502 webrtc::DataChannelInit init; |
| 503 rtc::scoped_refptr<DataChannelInterface> caller_dc( | 503 rtc::scoped_refptr<DataChannelInterface> caller_dc( |
| 504 caller_->CreateDataChannel("data", init)); | 504 caller_->CreateDataChannel("data", init)); |
| 505 | 505 |
| 506 Negotiate(); | 506 Negotiate(); |
| 507 WaitForConnection(); | 507 WaitForConnection(); |
| 508 | 508 |
| 509 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 509 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
| 510 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); | 510 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); |
| 511 | 511 |
| 512 // 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. |
| 513 caller_dc = caller_->CreateDataChannel("data2", init); | 513 caller_dc = caller_->CreateDataChannel("data2", init); |
| 514 | 514 |
| 515 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 1); | 515 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 1); |
| 516 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); | 516 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); |
| 517 | 517 |
| 518 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); | 518 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); |
| 519 } | 519 } |
| 520 | 520 |
| 521 // 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 |
| 522 // by the application (meaning only the PeerConnection contributes to its | 522 // by the application (meaning only the PeerConnection contributes to its |
| 523 // reference count), no memory access violation will occur. | 523 // reference count), no memory access violation will occur. |
| 524 // See: https://code.google.com/p/chromium/issues/detail?id=565048 | 524 // See: https://code.google.com/p/chromium/issues/detail?id=565048 |
| 525 TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) { | 525 TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) { |
| 526 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), | 526 CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), |
| 527 webrtc::CreateBuiltinAudioDecoderFactory()); | 527 webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); |
| 528 | 528 |
| 529 webrtc::DataChannelInit init; | 529 webrtc::DataChannelInit init; |
| 530 rtc::scoped_refptr<DataChannelInterface> caller_dc( | 530 rtc::scoped_refptr<DataChannelInterface> caller_dc( |
| 531 caller_->CreateDataChannel("data", init)); | 531 caller_->CreateDataChannel("data", init)); |
| 532 | 532 |
| 533 Negotiate(); | 533 Negotiate(); |
| 534 WaitForConnection(); | 534 WaitForConnection(); |
| 535 | 535 |
| 536 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 536 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
| 537 // 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. |
| 538 callee_signaled_data_channels_.clear(); | 538 callee_signaled_data_channels_.clear(); |
| 539 caller_dc->Close(); | 539 caller_dc->Close(); |
| 540 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); | 540 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); |
| 541 | 541 |
| 542 // 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 |
| 543 // close message and be destroyed. | 543 // close message and be destroyed. |
| 544 rtc::Thread::Current()->ProcessMessages(100); | 544 rtc::Thread::Current()->ProcessMessages(100); |
| 545 } | 545 } |
| 546 #endif // HAVE_SCTP | 546 #endif // HAVE_SCTP |
| OLD | NEW |