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

Unified Diff: webrtc/p2p/base/port_unittest.cc

Issue 1218293016: Tighten link-local IPv6 routing exclusion check (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Test more cases Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port_unittest.cc
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index fb7fc17709539679b73d7945b7438564fd961973..0ecddf8a0aa5573d4ba2e4f8eab26358d9ae5fd2 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -538,6 +538,8 @@ class PortTest : public testing::Test, public sigslot::has_slots<> {
void TestCrossFamilyPorts(int type);
+ void TestPortsCanConnect(Port* p1, Port* p2, bool can_connect);
+
// This does all the work and then deletes |port1| and |port2|.
void TestConnectivity(const char* name1, Port* port1,
const char* name2, Port* port2,
@@ -1394,6 +1396,49 @@ TEST_F(PortTest, TestSkipCrossFamilyUdp) {
TestCrossFamilyPorts(SOCK_DGRAM);
}
+void PortTest::TestPortsCanConnect(Port* p1, Port* p2, bool can_connect) {
pthatcher1 2015/07/07 20:53:24 I'd call this ExpectPortsCanConnect, and make the
bemasc2 2015/07/07 21:00:35 Done.
+ Connection* c = p1->CreateConnection(GetCandidate(p2),
+ Port::ORIGIN_MESSAGE);
+ if (can_connect) {
+ EXPECT_FALSE(NULL == c);
+ EXPECT_EQ(1U, p1->connections().size());
+ } else {
+ EXPECT_TRUE(NULL == c);
+ EXPECT_EQ(0U, p1->connections().size());
+ }
+}
+
+TEST_F(PortTest, TestUdpV6CrossTypePorts) {
+ FakePacketSocketFactory factory;
+ scoped_ptr<Port> ports[4];
+ SocketAddress addresses[4] = {SocketAddress("2001:db8::1", 0),
+ SocketAddress("fe80::1", 0),
+ SocketAddress("fe80::2", 0),
+ SocketAddress("::1", 0)};
+ for (int i = 0; i < 4; i++) {
+ FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket();
+ factory.set_next_udp_socket(socket);
+ ports[i].reset(CreateUdpPort(addresses[i], &factory));
+ socket->set_state(AsyncPacketSocket::STATE_BINDING);
+ socket->SignalAddressReady(socket, addresses[i]);
+ ports[i]->PrepareAddress();
+ }
+
+ Port* standard = ports[0].get();
+ Port* link_local1 = ports[1].get();
+ Port* link_local2 = ports[2].get();
+ Port* localhost = ports[3].get();
+
+ TestPortsCanConnect(link_local1, standard, false);
+ TestPortsCanConnect(standard, link_local1, false);
+ TestPortsCanConnect(link_local1, localhost, false);
+ TestPortsCanConnect(localhost, link_local1, false);
+
+ TestPortsCanConnect(link_local1, link_local2, true);
+ TestPortsCanConnect(localhost, standard, true);
+ TestPortsCanConnect(standard, localhost, true);
pthatcher1 2015/07/07 20:53:24 Looks nice
+}
+
// This test verifies DSCP value set through SetOption interface can be
// get through DefaultDscpValue.
TEST_F(PortTest, TestDefaultDscpValue) {
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698