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

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

Issue 2018693002: Create a new connection if a candidate reuses an address (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Sync with head 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
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 EXPECT_EQ(1UL, port->Candidates().size()); 2658 EXPECT_EQ(1UL, port->Candidates().size());
2659 port->SetIceParameters(1, "ufrag2", "password2"); 2659 port->SetIceParameters(1, "ufrag2", "password2");
2660 EXPECT_EQ(1, port->component()); 2660 EXPECT_EQ(1, port->component());
2661 EXPECT_EQ("ufrag2", port->username_fragment()); 2661 EXPECT_EQ("ufrag2", port->username_fragment());
2662 EXPECT_EQ("password2", port->password()); 2662 EXPECT_EQ("password2", port->password());
2663 const Candidate& candidate = port->Candidates()[0]; 2663 const Candidate& candidate = port->Candidates()[0];
2664 EXPECT_EQ(1, candidate.component()); 2664 EXPECT_EQ(1, candidate.component());
2665 EXPECT_EQ("ufrag2", candidate.username()); 2665 EXPECT_EQ("ufrag2", candidate.username());
2666 EXPECT_EQ("password2", candidate.password()); 2666 EXPECT_EQ("password2", candidate.password());
2667 } 2667 }
2668
2669 TEST_F(PortTest, TestAddConnectionWithSameAddress) {
2670 std::unique_ptr<TestPort> port(
2671 CreateTestPort(kLocalAddr1, "ufrag1", "password1"));
2672 port->PrepareAddress();
2673 EXPECT_EQ(1u, port->Candidates().size());
2674 rtc::SocketAddress address("1.1.1.1", 5000);
2675 cricket::Candidate candidate(1, "udp", address, 0, "", "", "relay", 0, "");
2676 cricket::Connection* conn1 =
2677 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE);
2678 cricket::Connection* conn_in_use = port->GetConnection(address);
2679 EXPECT_EQ(conn1, conn_in_use);
2680 EXPECT_EQ(0u, conn_in_use->remote_candidate().generation());
2681
2682 // Creating with a candidate with the same address again will get us a
2683 // different connection with the new candidate.
2684 candidate.set_generation(2);
2685 cricket::Connection* conn2 =
2686 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE);
2687 EXPECT_NE(conn1, conn2);
2688 conn_in_use = port->GetConnection(address);
2689 EXPECT_EQ(conn2, conn_in_use);
2690 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation());
2691
2692 // Make sure the new connection was not deleted.
2693 rtc::Thread::Current()->ProcessMessages(300);
2694 EXPECT_TRUE(port->GetConnection(address) != nullptr);
2695 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698