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

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

Issue 2828223002: Delete method MessageQueue::set_socketserver (Closed)
Patch Set: Fix memory leak in SSLAdapterTestBase. 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 2013 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2013 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 64
65 static const rtc::SocketAddress kClientAddr("11.11.11.11", 0); 65 static const rtc::SocketAddress kClientAddr("11.11.11.11", 0);
66 static const rtc::SocketAddress kServerAddr("22.22.22.22", 0); 66 static const rtc::SocketAddress kServerAddr("22.22.22.22", 0);
67 67
68 class AsyncStunTCPSocketTest : public testing::Test, 68 class AsyncStunTCPSocketTest : public testing::Test,
69 public sigslot::has_slots<> { 69 public sigslot::has_slots<> {
70 protected: 70 protected:
71 AsyncStunTCPSocketTest() 71 AsyncStunTCPSocketTest()
72 : vss_(new rtc::VirtualSocketServer(NULL)), 72 : vss_(new rtc::VirtualSocketServer(NULL)),
73 ss_scope_(vss_.get()) { 73 thread_(vss_.get()) {}
74 }
75 74
76 virtual void SetUp() { 75 virtual void SetUp() {
77 CreateSockets(); 76 CreateSockets();
78 } 77 }
79 78
80 void CreateSockets() { 79 void CreateSockets() {
81 rtc::AsyncSocket* server = vss_->CreateAsyncSocket( 80 rtc::AsyncSocket* server = vss_->CreateAsyncSocket(
82 kServerAddr.family(), SOCK_STREAM); 81 kServerAddr.family(), SOCK_STREAM);
83 server->Bind(kServerAddr); 82 server->Bind(kServerAddr);
84 recv_socket_.reset(new AsyncStunTCPSocket(server, true)); 83 recv_socket_.reset(new AsyncStunTCPSocket(server, true));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 bool ret = false; 117 bool ret = false;
119 if (recv_packets_.size()) { 118 if (recv_packets_.size()) {
120 std::string packet = recv_packets_.front(); 119 std::string packet = recv_packets_.front();
121 recv_packets_.pop_front(); 120 recv_packets_.pop_front();
122 ret = (memcmp(data, packet.c_str(), len) == 0); 121 ret = (memcmp(data, packet.c_str(), len) == 0);
123 } 122 }
124 return ret; 123 return ret;
125 } 124 }
126 125
127 std::unique_ptr<rtc::VirtualSocketServer> vss_; 126 std::unique_ptr<rtc::VirtualSocketServer> vss_;
128 rtc::SocketServerScope ss_scope_; 127 rtc::AutoSocketServerThread thread_;
129 std::unique_ptr<AsyncStunTCPSocket> send_socket_; 128 std::unique_ptr<AsyncStunTCPSocket> send_socket_;
130 std::unique_ptr<AsyncStunTCPSocket> recv_socket_; 129 std::unique_ptr<AsyncStunTCPSocket> recv_socket_;
131 std::unique_ptr<rtc::AsyncPacketSocket> listen_socket_; 130 std::unique_ptr<rtc::AsyncPacketSocket> listen_socket_;
132 std::list<std::string> recv_packets_; 131 std::list<std::string> recv_packets_;
133 }; 132 };
134 133
135 // Testing a stun packet sent/recv properly. 134 // Testing a stun packet sent/recv properly.
136 TEST_F(AsyncStunTCPSocketTest, TestSingleStunPacket) { 135 TEST_F(AsyncStunTCPSocketTest, TestSingleStunPacket) {
137 EXPECT_TRUE(Send(kStunMessageWithZeroLength, 136 EXPECT_TRUE(Send(kStunMessageWithZeroLength,
138 sizeof(kStunMessageWithZeroLength))); 137 sizeof(kStunMessageWithZeroLength)));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 TEST_F(AsyncStunTCPSocketTest, DISABLED_TestWithSmallSendBuffer) { 255 TEST_F(AsyncStunTCPSocketTest, DISABLED_TestWithSmallSendBuffer) {
257 vss_->set_send_buffer_capacity(1); 256 vss_->set_send_buffer_capacity(1);
258 Send(kTurnChannelDataMessageWithOddLength, 257 Send(kTurnChannelDataMessageWithOddLength,
259 sizeof(kTurnChannelDataMessageWithOddLength)); 258 sizeof(kTurnChannelDataMessageWithOddLength));
260 EXPECT_EQ(1u, recv_packets_.size()); 259 EXPECT_EQ(1u, recv_packets_.size());
261 EXPECT_TRUE(CheckData(kTurnChannelDataMessageWithOddLength, 260 EXPECT_TRUE(CheckData(kTurnChannelDataMessageWithOddLength,
262 sizeof(kTurnChannelDataMessageWithOddLength))); 261 sizeof(kTurnChannelDataMessageWithOddLength)));
263 } 262 }
264 263
265 } // namespace cricket 264 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698