OLD | NEW |
---|---|
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 } | 134 } |
135 return code; | 135 return code; |
136 } | 136 } |
137 | 137 |
138 virtual void PrepareAddress() { | 138 virtual void PrepareAddress() { |
139 rtc::SocketAddress addr(ip(), min_port()); | 139 rtc::SocketAddress addr(ip(), min_port()); |
140 AddAddress(addr, addr, rtc::SocketAddress(), "udp", "", "", Type(), | 140 AddAddress(addr, addr, rtc::SocketAddress(), "udp", "", "", Type(), |
141 ICE_TYPE_PREFERENCE_HOST, 0, true); | 141 ICE_TYPE_PREFERENCE_HOST, 0, true); |
142 } | 142 } |
143 | 143 |
144 virtual bool ProtocolMatch(const std::string& protocol) const { return true; } | |
pthatcher1
2015/12/11 02:05:36
Shouldn't we use the enum instead of the string?
honghaiz3
2015/12/11 18:36:31
I am using string because candidate.protocol() ret
| |
145 | |
144 // Exposed for testing candidate building. | 146 // Exposed for testing candidate building. |
145 void AddCandidateAddress(const rtc::SocketAddress& addr) { | 147 void AddCandidateAddress(const rtc::SocketAddress& addr) { |
146 AddAddress(addr, addr, rtc::SocketAddress(), "udp", "", "", Type(), | 148 AddAddress(addr, addr, rtc::SocketAddress(), "udp", "", "", Type(), |
147 type_preference_, 0, false); | 149 type_preference_, 0, false); |
148 } | 150 } |
149 void AddCandidateAddress(const rtc::SocketAddress& addr, | 151 void AddCandidateAddress(const rtc::SocketAddress& addr, |
150 const rtc::SocketAddress& base_address, | 152 const rtc::SocketAddress& base_address, |
151 const std::string& type, | 153 const std::string& type, |
152 int type_preference, | 154 int type_preference, |
153 bool final) { | 155 bool final) { |
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2488 StartConnectAndStopChannels(&ch1, &ch2); | 2490 StartConnectAndStopChannels(&ch1, &ch2); |
2489 // Switch the role after all connections are destroyed. | 2491 // Switch the role after all connections are destroyed. |
2490 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); | 2492 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
2491 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2493 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
2492 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2494 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2493 | 2495 |
2494 // After the connection is destroyed, the port should not be destroyed. | 2496 // After the connection is destroyed, the port should not be destroyed. |
2495 rtc::Thread::Current()->ProcessMessages(kTimeout); | 2497 rtc::Thread::Current()->ProcessMessages(kTimeout); |
2496 EXPECT_FALSE(destroyed()); | 2498 EXPECT_FALSE(destroyed()); |
2497 } | 2499 } |
2500 | |
2501 TEST_F(PortTest, TestProtocolMatch) { | |
2502 rtc::scoped_ptr<Port> udp_port(CreateUdpPort(kLocalAddr1)); | |
2503 EXPECT_TRUE(udp_port->ProtocolMatch(UDP_PROTOCOL_NAME)); | |
2504 EXPECT_FALSE(udp_port->ProtocolMatch(TCP_PROTOCOL_NAME)); | |
2505 | |
2506 rtc::scoped_ptr<Port> stun_port( | |
2507 CreateStunPort(kLocalAddr1, nat_socket_factory1())); | |
2508 EXPECT_TRUE(stun_port->ProtocolMatch(UDP_PROTOCOL_NAME)); | |
2509 EXPECT_FALSE(stun_port->ProtocolMatch(TCP_PROTOCOL_NAME)); | |
2510 | |
2511 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); | |
2512 EXPECT_TRUE(tcp_port->ProtocolMatch(TCP_PROTOCOL_NAME)); | |
2513 EXPECT_TRUE(tcp_port->ProtocolMatch(SSLTCP_PROTOCOL_NAME)); | |
2514 EXPECT_FALSE(tcp_port->ProtocolMatch(UDP_PROTOCOL_NAME)); | |
2515 | |
2516 rtc::scoped_ptr<Port> turn_port( | |
2517 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | |
2518 EXPECT_TRUE(turn_port->ProtocolMatch(UDP_PROTOCOL_NAME)); | |
2519 EXPECT_FALSE(turn_port->ProtocolMatch(TCP_PROTOCOL_NAME)); | |
2520 } | |
OLD | NEW |