OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 void OnDataChannelOpenMessage(const std::string& label, | 400 void OnDataChannelOpenMessage(const std::string& label, |
401 const InternalDataChannelInit& config) { | 401 const InternalDataChannelInit& config) { |
402 last_data_channel_label_ = label; | 402 last_data_channel_label_ = label; |
403 last_data_channel_config_ = config; | 403 last_data_channel_config_ = config; |
404 } | 404 } |
405 | 405 |
406 void OnSessionDestroyed() { session_destroyed_ = true; } | 406 void OnSessionDestroyed() { session_destroyed_ = true; } |
407 | 407 |
408 void Init() { Init(nullptr); } | 408 void Init() { Init(nullptr); } |
409 | 409 |
| 410 void InitWithIceTransport( |
| 411 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
| 412 configuration_.type = ice_transport_type; |
| 413 Init(); |
| 414 } |
| 415 |
410 void InitWithBundlePolicy( | 416 void InitWithBundlePolicy( |
411 PeerConnectionInterface::BundlePolicy bundle_policy) { | 417 PeerConnectionInterface::BundlePolicy bundle_policy) { |
412 configuration_.bundle_policy = bundle_policy; | 418 configuration_.bundle_policy = bundle_policy; |
413 Init(); | 419 Init(); |
414 } | 420 } |
415 | 421 |
416 void InitWithRtcpMuxPolicy( | 422 void InitWithRtcpMuxPolicy( |
417 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 423 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
418 PeerConnectionInterface::RTCConfiguration configuration; | 424 PeerConnectionInterface::RTCConfiguration configuration; |
419 configuration_.rtcp_mux_policy = rtcp_mux_policy; | 425 configuration_.rtcp_mux_policy = rtcp_mux_policy; |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 1522 rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
1517 Init(); | 1523 Init(); |
1518 SendAudioVideoStream1(); | 1524 SendAudioVideoStream1(); |
1519 InitiateCall(); | 1525 InitiateCall(); |
1520 // Since kClientAddrHost1 is blocked, not expecting stun candidates for it. | 1526 // Since kClientAddrHost1 is blocked, not expecting stun candidates for it. |
1521 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 1527 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
1522 EXPECT_EQ(6u, observer_.mline_0_candidates_.size()); | 1528 EXPECT_EQ(6u, observer_.mline_0_candidates_.size()); |
1523 EXPECT_EQ(6u, observer_.mline_1_candidates_.size()); | 1529 EXPECT_EQ(6u, observer_.mline_1_candidates_.size()); |
1524 } | 1530 } |
1525 | 1531 |
| 1532 // Test session delivers no candidates gathered when constraint set to "none". |
| 1533 TEST_F(WebRtcSessionTest, TestIceTransportsNone) { |
| 1534 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1535 InitWithIceTransport(PeerConnectionInterface::kNone); |
| 1536 SendAudioVideoStream1(); |
| 1537 InitiateCall(); |
| 1538 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1539 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 1540 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 1541 } |
| 1542 |
| 1543 // Test session delivers only relay candidates gathered when constaint set to |
| 1544 // "relay". |
| 1545 TEST_F(WebRtcSessionTest, TestIceTransportsRelay) { |
| 1546 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1547 ConfigureAllocatorWithTurn(); |
| 1548 InitWithIceTransport(PeerConnectionInterface::kRelay); |
| 1549 SendAudioVideoStream1(); |
| 1550 InitiateCall(); |
| 1551 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1552 EXPECT_EQ(2u, observer_.mline_0_candidates_.size()); |
| 1553 EXPECT_EQ(2u, observer_.mline_1_candidates_.size()); |
| 1554 for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { |
| 1555 EXPECT_EQ(cricket::RELAY_PORT_TYPE, |
| 1556 observer_.mline_0_candidates_[i].type()); |
| 1557 } |
| 1558 for (size_t i = 0; i < observer_.mline_1_candidates_.size(); ++i) { |
| 1559 EXPECT_EQ(cricket::RELAY_PORT_TYPE, |
| 1560 observer_.mline_1_candidates_[i].type()); |
| 1561 } |
| 1562 } |
| 1563 |
| 1564 // Test session delivers all candidates gathered when constaint set to "all". |
| 1565 TEST_F(WebRtcSessionTest, TestIceTransportsAll) { |
| 1566 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1567 InitWithIceTransport(PeerConnectionInterface::kAll); |
| 1568 SendAudioVideoStream1(); |
| 1569 InitiateCall(); |
| 1570 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1571 // Host + STUN. By default allocator is disabled to gather relay candidates. |
| 1572 EXPECT_EQ(4u, observer_.mline_0_candidates_.size()); |
| 1573 EXPECT_EQ(4u, observer_.mline_1_candidates_.size()); |
| 1574 } |
| 1575 |
1526 TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) { | 1576 TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) { |
1527 Init(); | 1577 Init(); |
1528 SessionDescriptionInterface* offer = NULL; | 1578 SessionDescriptionInterface* offer = NULL; |
1529 // Since |offer| is NULL, there's no way to tell if it's an offer or answer. | 1579 // Since |offer| is NULL, there's no way to tell if it's an offer or answer. |
1530 std::string unknown_action; | 1580 std::string unknown_action; |
1531 SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer); | 1581 SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer); |
1532 SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer); | 1582 SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer); |
1533 } | 1583 } |
1534 | 1584 |
1535 // Test creating offers and receive answers and make sure the | 1585 // Test creating offers and receive answers and make sure the |
(...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4358 } | 4408 } |
4359 | 4409 |
4360 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4410 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4361 // currently fails because upon disconnection and reconnection OnIceComplete is | 4411 // currently fails because upon disconnection and reconnection OnIceComplete is |
4362 // called more than once without returning to IceGatheringGathering. | 4412 // called more than once without returning to IceGatheringGathering. |
4363 | 4413 |
4364 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4414 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4365 WebRtcSessionTest, | 4415 WebRtcSessionTest, |
4366 testing::Values(ALREADY_GENERATED, | 4416 testing::Values(ALREADY_GENERATED, |
4367 DTLS_IDENTITY_STORE)); | 4417 DTLS_IDENTITY_STORE)); |
OLD | NEW |