| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 ch.AddRemoteCandidate(CreateHostCandidate("3.3.3.3", 3, 2)); | 2525 ch.AddRemoteCandidate(CreateHostCandidate("3.3.3.3", 3, 2)); |
| 2526 cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 2526 cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); |
| 2527 ASSERT_TRUE(conn3 != nullptr); | 2527 ASSERT_TRUE(conn3 != nullptr); |
| 2528 conn3->ReceivedPing(); // Becomes receiving | 2528 conn3->ReceivedPing(); // Becomes receiving |
| 2529 // Now prune both conn2 and conn3; they will be deleted soon. | 2529 // Now prune both conn2 and conn3; they will be deleted soon. |
| 2530 conn2->Prune(); | 2530 conn2->Prune(); |
| 2531 conn3->Prune(); | 2531 conn3->Prune(); |
| 2532 EXPECT_TRUE_WAIT(ch.connections().empty(), 1000); | 2532 EXPECT_TRUE_WAIT(ch.connections().empty(), 1000); |
| 2533 } | 2533 } |
| 2534 | 2534 |
| 2535 // Test that after a port allocator session is started, it will be stopped | 2535 // Tests that after a port allocator session is started, it will be stopped |
| 2536 // when a new connection becomes writable and receiving. Also test that this | 2536 // when a new connection becomes writable and receiving. Also tests that if a |
| 2537 // holds even if the transport channel did not lose the writability. | 2537 // connection belonging to an old session becomes writable, it won't stop |
| 2538 // the current port allocator session. |
| 2538 TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { | 2539 TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { |
| 2539 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2540 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 2540 cricket::P2PTransportChannel ch("test channel", 1, &pa); | 2541 cricket::P2PTransportChannel ch("test channel", 1, &pa); |
| 2541 PrepareChannel(&ch); | 2542 PrepareChannel(&ch); |
| 2542 ch.SetIceConfig(CreateIceConfig(2000, false)); | 2543 ch.SetIceConfig(CreateIceConfig(2000, false)); |
| 2543 ch.Connect(); | 2544 ch.Connect(); |
| 2544 ch.MaybeStartGathering(); | 2545 ch.MaybeStartGathering(); |
| 2545 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 100)); | 2546 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 100)); |
| 2546 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2547 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| 2547 ASSERT_TRUE(conn1 != nullptr); | 2548 ASSERT_TRUE(conn1 != nullptr); |
| 2548 conn1->ReceivedPingResponse(); // Becomes writable and receiving | 2549 conn1->ReceivedPingResponse(); // Becomes writable and receiving |
| 2549 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 2550 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
| 2550 | 2551 |
| 2551 // Restart gathering even if the transport channel is still writable. | 2552 // Start a new session. Even though conn1, which belongs to an older |
| 2552 // It should stop getting ports after a new connection becomes strongly | 2553 // session, becomes unwritable and writable again, it should not stop the |
| 2553 // connected. | 2554 // current session. |
| 2554 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2555 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| 2555 ch.MaybeStartGathering(); | 2556 ch.MaybeStartGathering(); |
| 2557 conn1->Prune(); |
| 2558 conn1->ReceivedPingResponse(); |
| 2559 EXPECT_TRUE(ch.allocator_session()->IsGettingPorts()); |
| 2560 |
| 2561 // But if a new connection created from the new session becomes writable, |
| 2562 // it will stop the current session. |
| 2556 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 100)); | 2563 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 100)); |
| 2557 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2564 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
| 2558 ASSERT_TRUE(conn2 != nullptr); | 2565 ASSERT_TRUE(conn2 != nullptr); |
| 2559 conn2->ReceivedPingResponse(); // Becomes writable and receiving | 2566 conn2->ReceivedPingResponse(); // Becomes writable and receiving |
| 2560 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 2567 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
| 2561 } | 2568 } |
| 2562 | 2569 |
| 2563 class P2PTransportChannelMostLikelyToWorkFirstTest | 2570 class P2PTransportChannelMostLikelyToWorkFirstTest |
| 2564 : public P2PTransportChannelPingTest { | 2571 : public P2PTransportChannelPingTest { |
| 2565 public: | 2572 public: |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 | 2787 |
| 2781 // TCP Relay/Relay is the next. | 2788 // TCP Relay/Relay is the next. |
| 2782 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, | 2789 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, |
| 2783 cricket::RELAY_PORT_TYPE, | 2790 cricket::RELAY_PORT_TYPE, |
| 2784 cricket::TCP_PROTOCOL_NAME); | 2791 cricket::TCP_PROTOCOL_NAME); |
| 2785 | 2792 |
| 2786 // Finally, Local/Relay will be pinged. | 2793 // Finally, Local/Relay will be pinged. |
| 2787 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, | 2794 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, |
| 2788 cricket::RELAY_PORT_TYPE); | 2795 cricket::RELAY_PORT_TYPE); |
| 2789 } | 2796 } |
| OLD | NEW |