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 SupportsProtocol(const std::string& protocol) const { |
| 145 return true; |
| 146 } |
| 147 |
144 // Exposed for testing candidate building. | 148 // Exposed for testing candidate building. |
145 void AddCandidateAddress(const rtc::SocketAddress& addr) { | 149 void AddCandidateAddress(const rtc::SocketAddress& addr) { |
146 AddAddress(addr, addr, rtc::SocketAddress(), "udp", "", "", Type(), | 150 AddAddress(addr, addr, rtc::SocketAddress(), "udp", "", "", Type(), |
147 type_preference_, 0, false); | 151 type_preference_, 0, false); |
148 } | 152 } |
149 void AddCandidateAddress(const rtc::SocketAddress& addr, | 153 void AddCandidateAddress(const rtc::SocketAddress& addr, |
150 const rtc::SocketAddress& base_address, | 154 const rtc::SocketAddress& base_address, |
151 const std::string& type, | 155 const std::string& type, |
152 int type_preference, | 156 int type_preference, |
153 bool final) { | 157 bool final) { |
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 StartConnectAndStopChannels(&ch1, &ch2); | 2492 StartConnectAndStopChannels(&ch1, &ch2); |
2489 // Switch the role after all connections are destroyed. | 2493 // Switch the role after all connections are destroyed. |
2490 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); | 2494 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
2491 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2495 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
2492 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2496 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2493 | 2497 |
2494 // After the connection is destroyed, the port should not be destroyed. | 2498 // After the connection is destroyed, the port should not be destroyed. |
2495 rtc::Thread::Current()->ProcessMessages(kTimeout); | 2499 rtc::Thread::Current()->ProcessMessages(kTimeout); |
2496 EXPECT_FALSE(destroyed()); | 2500 EXPECT_FALSE(destroyed()); |
2497 } | 2501 } |
| 2502 |
| 2503 TEST_F(PortTest, TestSupportsProtocol) { |
| 2504 rtc::scoped_ptr<Port> udp_port(CreateUdpPort(kLocalAddr1)); |
| 2505 EXPECT_TRUE(udp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
| 2506 EXPECT_FALSE(udp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
| 2507 |
| 2508 rtc::scoped_ptr<Port> stun_port( |
| 2509 CreateStunPort(kLocalAddr1, nat_socket_factory1())); |
| 2510 EXPECT_TRUE(stun_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
| 2511 EXPECT_FALSE(stun_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
| 2512 |
| 2513 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); |
| 2514 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
| 2515 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); |
| 2516 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
| 2517 |
| 2518 rtc::scoped_ptr<Port> turn_port( |
| 2519 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
| 2520 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
| 2521 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
| 2522 } |
OLD | NEW |