Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 2078423004: Revert of Update ICE role on all ports, not just ones used for new connections. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 2678
2679 // But if a new connection created from the new session becomes writable, 2679 // But if a new connection created from the new session becomes writable,
2680 // it will stop the current session. 2680 // it will stop the current session.
2681 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 100)); 2681 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 100));
2682 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); 2682 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
2683 ASSERT_TRUE(conn2 != nullptr); 2683 ASSERT_TRUE(conn2 != nullptr);
2684 conn2->ReceivedPingResponse(); // Becomes writable and receiving 2684 conn2->ReceivedPingResponse(); // Becomes writable and receiving
2685 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); 2685 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts());
2686 } 2686 }
2687 2687
2688 // Test that the ICE role is updated even on ports with inactive networks when
2689 // doing continual gathering. These ports may still have connections that need
2690 // a correct role, in case the network becomes active before the connection is
2691 // destroyed.
2692 TEST_F(P2PTransportChannelPingTest,
2693 TestIceRoleUpdatedOnPortAfterSignalNetworkInactive) {
2694 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2695 cricket::P2PTransportChannel ch(
2696 "test channel", cricket::ICE_CANDIDATE_COMPONENT_DEFAULT, &pa);
2697 // Starts with ICEROLE_CONTROLLING.
2698 PrepareChannel(&ch);
2699 cricket::IceConfig config = CreateIceConfig(1000, true);
2700 ch.SetIceConfig(config);
2701 ch.Connect();
2702 ch.MaybeStartGathering();
2703 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
2704
2705 cricket::Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1);
2706 ASSERT_TRUE(conn != nullptr);
2707
2708 // Make the fake port signal that its network is inactive, then change the
2709 // ICE role and expect it to be updated.
2710 conn->port()->SignalNetworkInactive(conn->port());
2711 ch.SetIceRole(cricket::ICEROLE_CONTROLLED);
2712 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, conn->port()->GetIceRole());
2713 }
2714
2715 // Test that the ICE role is updated even on ports with inactive networks.
2716 // These ports may still have connections that need a correct role, for the
2717 // pings sent by those connections until they're replaced by newer-generation
2718 // connections.
2719 TEST_F(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) {
2720 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2721 cricket::P2PTransportChannel ch(
2722 "test channel", cricket::ICE_CANDIDATE_COMPONENT_DEFAULT, &pa);
2723 // Starts with ICEROLE_CONTROLLING.
2724 PrepareChannel(&ch);
2725 ch.Connect();
2726 ch.MaybeStartGathering();
2727 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
2728
2729 cricket::Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1);
2730 ASSERT_TRUE(conn != nullptr);
2731
2732 // Do an ICE restart, change the role, and expect the old port to have its
2733 // role updated.
2734 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]);
2735 ch.MaybeStartGathering();
2736 ch.SetIceRole(cricket::ICEROLE_CONTROLLED);
2737 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, conn->port()->GetIceRole());
2738 }
2739
2740 class P2PTransportChannelMostLikelyToWorkFirstTest 2688 class P2PTransportChannelMostLikelyToWorkFirstTest
2741 : public P2PTransportChannelPingTest { 2689 : public P2PTransportChannelPingTest {
2742 public: 2690 public:
2743 P2PTransportChannelMostLikelyToWorkFirstTest() 2691 P2PTransportChannelMostLikelyToWorkFirstTest()
2744 : turn_server_(rtc::Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr) { 2692 : turn_server_(rtc::Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr) {
2745 network_manager_.AddInterface(kPublicAddrs[0]); 2693 network_manager_.AddInterface(kPublicAddrs[0]);
2746 allocator_.reset(new cricket::BasicPortAllocator( 2694 allocator_.reset(new cricket::BasicPortAllocator(
2747 &network_manager_, ServerAddresses(), rtc::SocketAddress(), 2695 &network_manager_, ServerAddresses(), rtc::SocketAddress(),
2748 rtc::SocketAddress(), rtc::SocketAddress())); 2696 rtc::SocketAddress(), rtc::SocketAddress()));
2749 allocator_->set_flags(allocator_->flags() | 2697 allocator_->set_flags(allocator_->flags() |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 2915
2968 // TCP Relay/Relay is the next. 2916 // TCP Relay/Relay is the next.
2969 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, 2917 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE,
2970 cricket::RELAY_PORT_TYPE, 2918 cricket::RELAY_PORT_TYPE,
2971 cricket::TCP_PROTOCOL_NAME); 2919 cricket::TCP_PROTOCOL_NAME);
2972 2920
2973 // Finally, Local/Relay will be pinged. 2921 // Finally, Local/Relay will be pinged.
2974 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, 2922 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE,
2975 cricket::RELAY_PORT_TYPE); 2923 cricket::RELAY_PORT_TYPE);
2976 } 2924 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698