| Index: webrtc/p2p/base/port_unittest.cc
|
| diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
|
| index 43ef084b02e1aa49a970c9d9a10accce7a414236..a9f18cf736a0af6c33883d226dba755fec0247ac 100644
|
| --- a/webrtc/p2p/base/port_unittest.cc
|
| +++ b/webrtc/p2p/base/port_unittest.cc
|
| @@ -2665,3 +2665,31 @@ TEST_F(PortTest, TestSetIceParameters) {
|
| EXPECT_EQ("ufrag2", candidate.username());
|
| EXPECT_EQ("password2", candidate.password());
|
| }
|
| +
|
| +TEST_F(PortTest, TestAddConnectionWithSameAddress) {
|
| + std::unique_ptr<TestPort> port(
|
| + CreateTestPort(kLocalAddr1, "ufrag1", "password1"));
|
| + port->PrepareAddress();
|
| + EXPECT_EQ(1u, port->Candidates().size());
|
| + rtc::SocketAddress address("1.1.1.1", 5000);
|
| + cricket::Candidate candidate(1, "udp", address, 0, "", "", "relay", 0, "");
|
| + cricket::Connection* conn1 =
|
| + port->CreateConnection(candidate, Port::ORIGIN_MESSAGE);
|
| + cricket::Connection* conn_in_use = port->GetConnection(address);
|
| + EXPECT_EQ(conn1, conn_in_use);
|
| + EXPECT_EQ(0u, conn_in_use->remote_candidate().generation());
|
| +
|
| + // Creating with a candidate with the same address again will get us a
|
| + // different connection with the new candidate.
|
| + candidate.set_generation(2);
|
| + cricket::Connection* conn2 =
|
| + port->CreateConnection(candidate, Port::ORIGIN_MESSAGE);
|
| + EXPECT_NE(conn1, conn2);
|
| + conn_in_use = port->GetConnection(address);
|
| + EXPECT_EQ(conn2, conn_in_use);
|
| + EXPECT_EQ(2u, conn_in_use->remote_candidate().generation());
|
| +
|
| + // Make sure the new connection was not deleted.
|
| + rtc::Thread::Current()->ProcessMessages(300);
|
| + EXPECT_TRUE(port->GetConnection(address) != nullptr);
|
| +}
|
|
|