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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel_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
« no previous file with comments | « webrtc/p2p/base/asyncstuntcpsocket_unittest.cc ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 13
14 #include "webrtc/api/fakemetricsobserver.h" 14 #include "webrtc/api/fakemetricsobserver.h"
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/dscp.h" 16 #include "webrtc/base/dscp.h"
17 #include "webrtc/base/fakeclock.h" 17 #include "webrtc/base/fakeclock.h"
18 #include "webrtc/base/fakenetwork.h" 18 #include "webrtc/base/fakenetwork.h"
19 #include "webrtc/base/firewallsocketserver.h" 19 #include "webrtc/base/firewallsocketserver.h"
20 #include "webrtc/base/gunit.h" 20 #include "webrtc/base/gunit.h"
21 #include "webrtc/base/helpers.h" 21 #include "webrtc/base/helpers.h"
22 #include "webrtc/base/logging.h" 22 #include "webrtc/base/logging.h"
23 #include "webrtc/base/natserver.h" 23 #include "webrtc/base/natserver.h"
24 #include "webrtc/base/natsocketfactory.h" 24 #include "webrtc/base/natsocketfactory.h"
25 #include "webrtc/base/physicalsocketserver.h"
26 #include "webrtc/base/proxyserver.h" 25 #include "webrtc/base/proxyserver.h"
27 #include "webrtc/base/ptr_util.h" 26 #include "webrtc/base/ptr_util.h"
28 #include "webrtc/base/socketaddress.h" 27 #include "webrtc/base/socketaddress.h"
29 #include "webrtc/base/ssladapter.h" 28 #include "webrtc/base/ssladapter.h"
30 #include "webrtc/base/thread.h" 29 #include "webrtc/base/thread.h"
31 #include "webrtc/base/virtualsocketserver.h" 30 #include "webrtc/base/virtualsocketserver.h"
32 #include "webrtc/p2p/base/fakeportallocator.h" 31 #include "webrtc/p2p/base/fakeportallocator.h"
33 #include "webrtc/p2p/base/icetransportinternal.h" 32 #include "webrtc/p2p/base/icetransportinternal.h"
34 #include "webrtc/p2p/base/p2ptransportchannel.h" 33 #include "webrtc/p2p/base/p2ptransportchannel.h"
35 #include "webrtc/p2p/base/packettransportinternal.h" 34 #include "webrtc/p2p/base/packettransportinternal.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // form of connectivity to the other side. The test checks that the P2P 174 // form of connectivity to the other side. The test checks that the P2P
176 // negotiation successfully establishes connectivity within a certain time, 175 // negotiation successfully establishes connectivity within a certain time,
177 // and that the result is what we expect. 176 // and that the result is what we expect.
178 // Note that this class is a base class for use by other tests, who will provide 177 // Note that this class is a base class for use by other tests, who will provide
179 // specialized test behavior. 178 // specialized test behavior.
180 class P2PTransportChannelTestBase : public testing::Test, 179 class P2PTransportChannelTestBase : public testing::Test,
181 public rtc::MessageHandler, 180 public rtc::MessageHandler,
182 public sigslot::has_slots<> { 181 public sigslot::has_slots<> {
183 public: 182 public:
184 P2PTransportChannelTestBase() 183 P2PTransportChannelTestBase()
185 : pss_(new rtc::PhysicalSocketServer), 184 : vss_(new rtc::VirtualSocketServer()),
186 vss_(new rtc::VirtualSocketServer(pss_.get())),
187 nss_(new rtc::NATSocketServer(vss_.get())), 185 nss_(new rtc::NATSocketServer(vss_.get())),
188 ss_(new rtc::FirewallSocketServer(nss_.get())), 186 ss_(new rtc::FirewallSocketServer(nss_.get())),
189 main_(ss_.get()), 187 main_(ss_.get()),
190 stun_server_(TestStunServer::Create(&main_, kStunAddr)), 188 stun_server_(TestStunServer::Create(&main_, kStunAddr)),
191 turn_server_(&main_, kTurnUdpIntAddr, kTurnUdpExtAddr), 189 turn_server_(&main_, kTurnUdpIntAddr, kTurnUdpExtAddr),
192 socks_server1_(ss_.get(), 190 socks_server1_(ss_.get(),
193 kSocksProxyAddrs[0], 191 kSocksProxyAddrs[0],
194 ss_.get(), 192 ss_.get(),
195 kSocksProxyAddrs[0]), 193 kSocksProxyAddrs[0]),
196 socks_server2_(ss_.get(), 194 socks_server2_(ss_.get(),
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 865
868 void ConnectSignalNominated(Connection* conn) { 866 void ConnectSignalNominated(Connection* conn) {
869 conn->SignalNominated.connect(this, 867 conn->SignalNominated.connect(this,
870 &P2PTransportChannelTestBase::OnNominated); 868 &P2PTransportChannelTestBase::OnNominated);
871 } 869 }
872 870
873 void OnNominated(Connection* conn) { nominated_ = true; } 871 void OnNominated(Connection* conn) { nominated_ = true; }
874 bool nominated() { return nominated_; } 872 bool nominated() { return nominated_; }
875 873
876 private: 874 private:
877 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
878 std::unique_ptr<rtc::VirtualSocketServer> vss_; 875 std::unique_ptr<rtc::VirtualSocketServer> vss_;
879 std::unique_ptr<rtc::NATSocketServer> nss_; 876 std::unique_ptr<rtc::NATSocketServer> nss_;
880 std::unique_ptr<rtc::FirewallSocketServer> ss_; 877 std::unique_ptr<rtc::FirewallSocketServer> ss_;
881 rtc::AutoSocketServerThread main_; 878 rtc::AutoSocketServerThread main_;
882 std::unique_ptr<TestStunServer> stun_server_; 879 std::unique_ptr<TestStunServer> stun_server_;
883 TestTurnServer turn_server_; 880 TestTurnServer turn_server_;
884 rtc::SocksProxyServer socks_server1_; 881 rtc::SocksProxyServer socks_server1_;
885 rtc::SocksProxyServer socks_server2_; 882 rtc::SocksProxyServer socks_server2_;
886 Endpoint ep1_; 883 Endpoint ep1_;
887 Endpoint ep2_; 884 Endpoint ep2_;
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 2920
2924 DestroyChannels(); 2921 DestroyChannels();
2925 } 2922 }
2926 2923
2927 // A collection of tests which tests a single P2PTransportChannel by sending 2924 // A collection of tests which tests a single P2PTransportChannel by sending
2928 // pings. 2925 // pings.
2929 class P2PTransportChannelPingTest : public testing::Test, 2926 class P2PTransportChannelPingTest : public testing::Test,
2930 public sigslot::has_slots<> { 2927 public sigslot::has_slots<> {
2931 public: 2928 public:
2932 P2PTransportChannelPingTest() 2929 P2PTransportChannelPingTest()
2933 : pss_(new rtc::PhysicalSocketServer), 2930 : vss_(new rtc::VirtualSocketServer()), thread_(vss_.get()) {}
2934 vss_(new rtc::VirtualSocketServer(pss_.get())),
2935 thread_(vss_.get()) {}
2936 2931
2937 protected: 2932 protected:
2938 void PrepareChannel(P2PTransportChannel* ch) { 2933 void PrepareChannel(P2PTransportChannel* ch) {
2939 ch->SetIceRole(ICEROLE_CONTROLLING); 2934 ch->SetIceRole(ICEROLE_CONTROLLING);
2940 ch->SetIceParameters(kIceParams[0]); 2935 ch->SetIceParameters(kIceParams[0]);
2941 ch->SetRemoteIceParameters(kIceParams[1]); 2936 ch->SetRemoteIceParameters(kIceParams[1]);
2942 ch->SignalSelectedCandidatePairChanged.connect( 2937 ch->SignalSelectedCandidatePairChanged.connect(
2943 this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged); 2938 this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged);
2944 ch->SignalReadyToSend.connect(this, 2939 ch->SignalReadyToSend.connect(this,
2945 &P2PTransportChannelPingTest::OnReadyToSend); 2940 &P2PTransportChannelPingTest::OnReadyToSend);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 bool channel_ready_to_send() { return channel_ready_to_send_; } 3068 bool channel_ready_to_send() { return channel_ready_to_send_; }
3074 void reset_channel_ready_to_send() { channel_ready_to_send_ = false; } 3069 void reset_channel_ready_to_send() { channel_ready_to_send_ = false; }
3075 IceTransportState channel_state() { return channel_state_; } 3070 IceTransportState channel_state() { return channel_state_; }
3076 int reset_selected_candidate_pair_switches() { 3071 int reset_selected_candidate_pair_switches() {
3077 int switches = selected_candidate_pair_switches_; 3072 int switches = selected_candidate_pair_switches_;
3078 selected_candidate_pair_switches_ = 0; 3073 selected_candidate_pair_switches_ = 0;
3079 return switches; 3074 return switches;
3080 } 3075 }
3081 3076
3082 private: 3077 private:
3083 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
3084 std::unique_ptr<rtc::VirtualSocketServer> vss_; 3078 std::unique_ptr<rtc::VirtualSocketServer> vss_;
3085 rtc::AutoSocketServerThread thread_; 3079 rtc::AutoSocketServerThread thread_;
3086 CandidatePairInterface* last_selected_candidate_pair_ = nullptr; 3080 CandidatePairInterface* last_selected_candidate_pair_ = nullptr;
3087 int selected_candidate_pair_switches_ = 0; 3081 int selected_candidate_pair_switches_ = 0;
3088 int last_sent_packet_id_ = -1; 3082 int last_sent_packet_id_ = -1;
3089 bool channel_ready_to_send_ = false; 3083 bool channel_ready_to_send_ = false;
3090 IceTransportState channel_state_ = IceTransportState::STATE_INIT; 3084 IceTransportState channel_state_ = IceTransportState::STATE_INIT;
3091 }; 3085 };
3092 3086
3093 TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { 3087 TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) {
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
4393 4387
4394 // TCP Relay/Relay is the next. 4388 // TCP Relay/Relay is the next.
4395 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, 4389 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE,
4396 TCP_PROTOCOL_NAME); 4390 TCP_PROTOCOL_NAME);
4397 4391
4398 // Finally, Local/Relay will be pinged. 4392 // Finally, Local/Relay will be pinged.
4399 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); 4393 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
4400 } 4394 }
4401 4395
4402 } // namespace cricket { 4396 } // namespace cricket {
OLDNEW
« no previous file with comments | « webrtc/p2p/base/asyncstuntcpsocket_unittest.cc ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698