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

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

Issue 2828223002: Delete method MessageQueue::set_socketserver (Closed)
Patch Set: Use unique_ptr, fixing one leak in VirtualSocketServerTest. Created 3 years, 7 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 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 27 matching lines...) Expand all
38 // (cricket::RelayServer) using all currently available protocols. The 38 // (cricket::RelayServer) using all currently available protocols. The
39 // network layer is faked out by using a VirtualSocketServer for 39 // network layer is faked out by using a VirtualSocketServer for
40 // creating sockets. The test will monitor the current state of the 40 // creating sockets. The test will monitor the current state of the
41 // RelayPort and created sockets by listening for signals such as, 41 // RelayPort and created sockets by listening for signals such as,
42 // SignalConnectFailure, SignalConnectTimeout, SignalSocketClosed and 42 // SignalConnectFailure, SignalConnectTimeout, SignalSocketClosed and
43 // SignalReadPacket. 43 // SignalReadPacket.
44 class RelayPortTest : public testing::Test, 44 class RelayPortTest : public testing::Test,
45 public sigslot::has_slots<> { 45 public sigslot::has_slots<> {
46 public: 46 public:
47 RelayPortTest() 47 RelayPortTest()
48 : main_(rtc::Thread::Current()), 48 : physical_socket_server_(new rtc::PhysicalSocketServer),
49 physical_socket_server_(new rtc::PhysicalSocketServer),
50 virtual_socket_server_(new rtc::VirtualSocketServer( 49 virtual_socket_server_(new rtc::VirtualSocketServer(
51 physical_socket_server_.get())), 50 physical_socket_server_.get())),
52 ss_scope_(virtual_socket_server_.get()), 51 main_(virtual_socket_server_.get()),
53 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32), 52 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
54 socket_factory_(rtc::Thread::Current()), 53 socket_factory_(rtc::Thread::Current()),
55 username_(rtc::CreateRandomString(16)), 54 username_(rtc::CreateRandomString(16)),
56 password_(rtc::CreateRandomString(16)), 55 password_(rtc::CreateRandomString(16)),
57 relay_port_(cricket::RelayPort::Create(main_, &socket_factory_, 56 relay_port_(cricket::RelayPort::Create(&main_, &socket_factory_,
58 &network_, 57 &network_,
59 kLocalAddress.ipaddr(), 58 kLocalAddress.ipaddr(),
60 0, 0, username_, password_)), 59 0, 0, username_, password_)),
61 relay_server_(new cricket::RelayServer(main_)) { 60 relay_server_(new cricket::RelayServer(&main_)) {
62 } 61 }
63 62
64 void OnReadPacket(rtc::AsyncPacketSocket* socket, 63 void OnReadPacket(rtc::AsyncPacketSocket* socket,
65 const char* data, size_t size, 64 const char* data, size_t size,
66 const rtc::SocketAddress& remote_addr, 65 const rtc::SocketAddress& remote_addr,
67 const rtc::PacketTime& packet_time) { 66 const rtc::PacketTime& packet_time) {
68 received_packet_count_[socket]++; 67 received_packet_count_[socket]++;
69 } 68 }
70 69
71 void OnConnectFailure(const cricket::ProtocolAddress* addr) { 70 void OnConnectFailure(const cricket::ProtocolAddress* addr) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (soft_timedout_connections_[i].address == addr->address && 239 if (soft_timedout_connections_[i].address == addr->address &&
241 soft_timedout_connections_[i].proto == addr->proto) { 240 soft_timedout_connections_[i].proto == addr->proto) {
242 return true; 241 return true;
243 } 242 }
244 } 243 }
245 return false; 244 return false;
246 } 245 }
247 246
248 typedef std::map<rtc::AsyncPacketSocket*, int> PacketMap; 247 typedef std::map<rtc::AsyncPacketSocket*, int> PacketMap;
249 248
250 rtc::Thread* main_;
251 std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_; 249 std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_;
252 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_; 250 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_;
253 rtc::SocketServerScope ss_scope_; 251 rtc::AutoSocketServerThread main_;
254 rtc::Network network_; 252 rtc::Network network_;
255 rtc::BasicPacketSocketFactory socket_factory_; 253 rtc::BasicPacketSocketFactory socket_factory_;
256 std::string username_; 254 std::string username_;
257 std::string password_; 255 std::string password_;
258 std::unique_ptr<cricket::RelayPort> relay_port_; 256 std::unique_ptr<cricket::RelayPort> relay_port_;
259 std::unique_ptr<cricket::RelayServer> relay_server_; 257 std::unique_ptr<cricket::RelayServer> relay_server_;
260 std::vector<cricket::ProtocolAddress> failed_connections_; 258 std::vector<cricket::ProtocolAddress> failed_connections_;
261 std::vector<cricket::ProtocolAddress> soft_timedout_connections_; 259 std::vector<cricket::ProtocolAddress> soft_timedout_connections_;
262 PacketMap received_packet_count_; 260 PacketMap received_packet_count_;
263 }; 261 };
264 262
265 TEST_F(RelayPortTest, ConnectUdp) { 263 TEST_F(RelayPortTest, ConnectUdp) {
266 TestConnectUdp(); 264 TestConnectUdp();
267 } 265 }
268 266
269 TEST_F(RelayPortTest, ConnectTcp) { 267 TEST_F(RelayPortTest, ConnectTcp) {
270 TestConnectTcp(); 268 TestConnectTcp();
271 } 269 }
272 270
273 TEST_F(RelayPortTest, ConnectSslTcp) { 271 TEST_F(RelayPortTest, ConnectSslTcp) {
274 TestConnectSslTcp(); 272 TestConnectSslTcp();
275 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698