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

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

Issue 2828223002: Delete method MessageQueue::set_socketserver (Closed)
Patch Set: Delete redundant private: 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 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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 17 matching lines...) Expand all
28 28
29 namespace cricket { 29 namespace cricket {
30 30
31 constexpr int kTimeoutMs = 10000; 31 constexpr int kTimeoutMs = 10000;
32 static const rtc::IPAddress kIPv4LocalHostAddress = 32 static const rtc::IPAddress kIPv4LocalHostAddress =
33 rtc::IPAddress(0x7F000001); // 127.0.0.1 33 rtc::IPAddress(0x7F000001); // 127.0.0.1
34 34
35 class UdpTransportTest : public testing::Test, public sigslot::has_slots<> { 35 class UdpTransportTest : public testing::Test, public sigslot::has_slots<> {
36 public: 36 public:
37 UdpTransportTest() 37 UdpTransportTest()
38 : network_thread_(rtc::Thread::Current()), 38 : physical_socket_server_(new rtc::PhysicalSocketServer),
39 physical_socket_server_(new rtc::PhysicalSocketServer),
40 virtual_socket_server_( 39 virtual_socket_server_(
41 new rtc::VirtualSocketServer(physical_socket_server_.get())), 40 new rtc::VirtualSocketServer(physical_socket_server_.get())),
42 ss_scope_(virtual_socket_server_.get()), 41 network_thread_(virtual_socket_server_.get()),
43 ep1_("Name1", 42 ep1_("Name1",
44 std::unique_ptr<rtc::AsyncPacketSocket>( 43 std::unique_ptr<rtc::AsyncPacketSocket>(
45 socket_factory_.CreateUdpSocket( 44 socket_factory_.CreateUdpSocket(
46 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), 45 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0),
47 0, 46 0,
48 0))), 47 0))),
49 ep2_("Name2", 48 ep2_("Name2",
50 std::unique_ptr<rtc::AsyncPacketSocket>( 49 std::unique_ptr<rtc::AsyncPacketSocket>(
51 socket_factory_.CreateUdpSocket( 50 socket_factory_.CreateUdpSocket(
52 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), 51 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 113 }
115 114
116 std::list<std::string> ch_packets_; 115 std::list<std::string> ch_packets_;
117 std::unique_ptr<UdpTransport> ch_; 116 std::unique_ptr<UdpTransport> ch_;
118 uint32_t num_received_packets_ = 0; // Increases on SignalReadPacket. 117 uint32_t num_received_packets_ = 0; // Increases on SignalReadPacket.
119 uint32_t num_sig_sent_packets_ = 0; // Increases on SignalSentPacket. 118 uint32_t num_sig_sent_packets_ = 0; // Increases on SignalSentPacket.
120 uint32_t num_sig_writable_ = 0; // Increases on SignalWritable. 119 uint32_t num_sig_writable_ = 0; // Increases on SignalWritable.
121 uint32_t num_sig_ready_to_send_ = 0; // Increases on SignalReadyToSend. 120 uint32_t num_sig_ready_to_send_ = 0; // Increases on SignalReadyToSend.
122 }; 121 };
123 122
124 rtc::Thread* network_thread_ = nullptr;
125 std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_; 123 std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_;
126 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_; 124 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_;
127 rtc::SocketServerScope ss_scope_; 125 rtc::AutoSocketServerThread network_thread_;
128 // Uses current thread's socket server, which will be set by ss_scope_. 126 // Uses current thread's socket server, which will be set by ss_scope_.
129 rtc::BasicPacketSocketFactory socket_factory_; 127 rtc::BasicPacketSocketFactory socket_factory_;
130 128
131 Endpoint ep1_; 129 Endpoint ep1_;
132 Endpoint ep2_; 130 Endpoint ep2_;
133 131
134 void TestSendRecv() { 132 void TestSendRecv() {
135 for (uint32_t i = 0; i < 5; ++i) { 133 for (uint32_t i = 0; i < 5; ++i) {
136 static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 134 static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
137 int len = static_cast<int>(strlen(data)); 135 int len = static_cast<int>(strlen(data));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_TRUE(ep1_.ch_->writable()); 184 EXPECT_TRUE(ep1_.ch_->writable());
187 EXPECT_EQ(1u, ep1_.num_sig_writable_); 185 EXPECT_EQ(1u, ep1_.num_sig_writable_);
188 EXPECT_EQ(1u, ep1_.num_sig_ready_to_send_); 186 EXPECT_EQ(1u, ep1_.num_sig_ready_to_send_);
189 const char data[] = "abc"; 187 const char data[] = "abc";
190 ep1_.SendData(data, sizeof(data)); 188 ep1_.SendData(data, sizeof(data));
191 EXPECT_EQ_WAIT(1u, ep1_.ch_packets_.size(), kTimeoutMs); 189 EXPECT_EQ_WAIT(1u, ep1_.ch_packets_.size(), kTimeoutMs);
192 EXPECT_EQ_WAIT(1u, ep1_.num_sig_sent_packets_, kTimeoutMs); 190 EXPECT_EQ_WAIT(1u, ep1_.num_sig_sent_packets_, kTimeoutMs);
193 } 191 }
194 192
195 } // namespace cricket 193 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698