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

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

Issue 2883313003: Remove VirtualSocketServer's dependency on PhysicalSocketServer. (Closed)
Patch Set: 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
11 #include <algorithm> 11 #include <algorithm>
12 #include <list> 12 #include <list>
13 #include <memory> 13 #include <memory>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/gunit.h" 17 #include "webrtc/base/gunit.h"
18 #include "webrtc/base/thread.h" 18 #include "webrtc/base/thread.h"
19 #include "webrtc/base/asyncpacketsocket.h" 19 #include "webrtc/base/asyncpacketsocket.h"
20 #include "webrtc/base/ipaddress.h" 20 #include "webrtc/base/ipaddress.h"
21 #include "webrtc/base/physicalsocketserver.h"
22 #include "webrtc/base/socketaddress.h" 21 #include "webrtc/base/socketaddress.h"
23 #include "webrtc/base/socketserver.h" 22 #include "webrtc/base/socketserver.h"
24 #include "webrtc/base/virtualsocketserver.h" 23 #include "webrtc/base/virtualsocketserver.h"
25 #include "webrtc/p2p/base/basicpacketsocketfactory.h" 24 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
26 #include "webrtc/p2p/base/packettransportinternal.h" 25 #include "webrtc/p2p/base/packettransportinternal.h"
27 #include "webrtc/p2p/base/udptransport.h" 26 #include "webrtc/p2p/base/udptransport.h"
28 27
29 namespace cricket { 28 namespace cricket {
30 29
31 constexpr int kTimeoutMs = 10000; 30 constexpr int kTimeoutMs = 10000;
32 static const rtc::IPAddress kIPv4LocalHostAddress = 31 static const rtc::IPAddress kIPv4LocalHostAddress =
33 rtc::IPAddress(0x7F000001); // 127.0.0.1 32 rtc::IPAddress(0x7F000001); // 127.0.0.1
34 33
35 class UdpTransportTest : public testing::Test, public sigslot::has_slots<> { 34 class UdpTransportTest : public testing::Test, public sigslot::has_slots<> {
36 public: 35 public:
37 UdpTransportTest() 36 UdpTransportTest()
38 : physical_socket_server_(new rtc::PhysicalSocketServer), 37 : virtual_socket_server_(new rtc::VirtualSocketServer()),
39 virtual_socket_server_(
40 new rtc::VirtualSocketServer(physical_socket_server_.get())),
41 network_thread_(virtual_socket_server_.get()), 38 network_thread_(virtual_socket_server_.get()),
42 ep1_("Name1", 39 ep1_("Name1",
43 std::unique_ptr<rtc::AsyncPacketSocket>( 40 std::unique_ptr<rtc::AsyncPacketSocket>(
44 socket_factory_.CreateUdpSocket( 41 socket_factory_.CreateUdpSocket(
45 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), 42 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0),
46 0, 43 0,
47 0))), 44 0))),
48 ep2_("Name2", 45 ep2_("Name2",
49 std::unique_ptr<rtc::AsyncPacketSocket>( 46 std::unique_ptr<rtc::AsyncPacketSocket>(
50 socket_factory_.CreateUdpSocket( 47 socket_factory_.CreateUdpSocket(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 110 }
114 111
115 std::list<std::string> ch_packets_; 112 std::list<std::string> ch_packets_;
116 std::unique_ptr<UdpTransport> ch_; 113 std::unique_ptr<UdpTransport> ch_;
117 uint32_t num_received_packets_ = 0; // Increases on SignalReadPacket. 114 uint32_t num_received_packets_ = 0; // Increases on SignalReadPacket.
118 uint32_t num_sig_sent_packets_ = 0; // Increases on SignalSentPacket. 115 uint32_t num_sig_sent_packets_ = 0; // Increases on SignalSentPacket.
119 uint32_t num_sig_writable_ = 0; // Increases on SignalWritable. 116 uint32_t num_sig_writable_ = 0; // Increases on SignalWritable.
120 uint32_t num_sig_ready_to_send_ = 0; // Increases on SignalReadyToSend. 117 uint32_t num_sig_ready_to_send_ = 0; // Increases on SignalReadyToSend.
121 }; 118 };
122 119
123 std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_;
124 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_; 120 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_;
125 rtc::AutoSocketServerThread network_thread_; 121 rtc::AutoSocketServerThread network_thread_;
126 // Uses current thread's socket server, which will be set by ss_scope_. 122 // Uses current thread's socket server, which will be set by ss_scope_.
127 rtc::BasicPacketSocketFactory socket_factory_; 123 rtc::BasicPacketSocketFactory socket_factory_;
128 124
129 Endpoint ep1_; 125 Endpoint ep1_;
130 Endpoint ep2_; 126 Endpoint ep2_;
131 127
132 void TestSendRecv() { 128 void TestSendRecv() {
133 for (uint32_t i = 0; i < 5; ++i) { 129 for (uint32_t i = 0; i < 5; ++i) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 EXPECT_TRUE(ep1_.ch_->writable()); 180 EXPECT_TRUE(ep1_.ch_->writable());
185 EXPECT_EQ(1u, ep1_.num_sig_writable_); 181 EXPECT_EQ(1u, ep1_.num_sig_writable_);
186 EXPECT_EQ(1u, ep1_.num_sig_ready_to_send_); 182 EXPECT_EQ(1u, ep1_.num_sig_ready_to_send_);
187 const char data[] = "abc"; 183 const char data[] = "abc";
188 ep1_.SendData(data, sizeof(data)); 184 ep1_.SendData(data, sizeof(data));
189 EXPECT_EQ_WAIT(1u, ep1_.ch_packets_.size(), kTimeoutMs); 185 EXPECT_EQ_WAIT(1u, ep1_.ch_packets_.size(), kTimeoutMs);
190 EXPECT_EQ_WAIT(1u, ep1_.num_sig_sent_packets_, kTimeoutMs); 186 EXPECT_EQ_WAIT(1u, ep1_.num_sig_sent_packets_, kTimeoutMs);
191 } 187 }
192 188
193 } // namespace cricket 189 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnserver_unittest.cc ('k') | webrtc/p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698