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

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

Issue 2828223002: Delete method MessageQueue::set_socketserver (Closed)
Patch Set: Use AutoSocketServerThread at one more place, missed in prev patchset. 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 28 matching lines...) Expand all
39 static const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000; 39 static const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000;
40 40
41 // Tests connecting a StunPort to a fake STUN server (cricket::StunServer) 41 // Tests connecting a StunPort to a fake STUN server (cricket::StunServer)
42 // TODO: Use a VirtualSocketServer here. We have to use a 42 // TODO: Use a VirtualSocketServer here. We have to use a
43 // PhysicalSocketServer right now since DNS is not part of SocketServer yet. 43 // PhysicalSocketServer right now since DNS is not part of SocketServer yet.
44 class StunPortTestBase : public testing::Test, public sigslot::has_slots<> { 44 class StunPortTestBase : public testing::Test, public sigslot::has_slots<> {
45 public: 45 public:
46 StunPortTestBase() 46 StunPortTestBase()
47 : pss_(new rtc::PhysicalSocketServer), 47 : pss_(new rtc::PhysicalSocketServer),
48 ss_(new rtc::VirtualSocketServer(pss_.get())), 48 ss_(new rtc::VirtualSocketServer(pss_.get())),
49 ss_scope_(ss_.get()), 49 thread_(ss_.get()),
50 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32), 50 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
51 socket_factory_(rtc::Thread::Current()), 51 socket_factory_(rtc::Thread::Current()),
52 stun_server_1_(cricket::TestStunServer::Create(rtc::Thread::Current(), 52 stun_server_1_(cricket::TestStunServer::Create(rtc::Thread::Current(),
53 kStunAddr1)), 53 kStunAddr1)),
54 stun_server_2_(cricket::TestStunServer::Create(rtc::Thread::Current(), 54 stun_server_2_(cricket::TestStunServer::Create(rtc::Thread::Current(),
55 kStunAddr2)), 55 kStunAddr2)),
56 done_(false), 56 done_(false),
57 error_(false), 57 error_(false),
58 stun_keepalive_delay_(1), 58 stun_keepalive_delay_(1),
59 stun_keepalive_lifetime_(-1) {} 59 stun_keepalive_lifetime_(-1) {}
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 cricket::TestStunServer* stun_server_1() { 151 cricket::TestStunServer* stun_server_1() {
152 return stun_server_1_.get(); 152 return stun_server_1_.get();
153 } 153 }
154 cricket::TestStunServer* stun_server_2() { 154 cricket::TestStunServer* stun_server_2() {
155 return stun_server_2_.get(); 155 return stun_server_2_.get();
156 } 156 }
157 157
158 private: 158 private:
159 std::unique_ptr<rtc::PhysicalSocketServer> pss_; 159 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
160 std::unique_ptr<rtc::VirtualSocketServer> ss_; 160 std::unique_ptr<rtc::VirtualSocketServer> ss_;
161 rtc::SocketServerScope ss_scope_; 161 rtc::AutoSocketServerThread thread_;
162 rtc::Network network_; 162 rtc::Network network_;
163 rtc::BasicPacketSocketFactory socket_factory_; 163 rtc::BasicPacketSocketFactory socket_factory_;
164 std::unique_ptr<cricket::UDPPort> stun_port_; 164 std::unique_ptr<cricket::UDPPort> stun_port_;
165 std::unique_ptr<cricket::TestStunServer> stun_server_1_; 165 std::unique_ptr<cricket::TestStunServer> stun_server_1_;
166 std::unique_ptr<cricket::TestStunServer> stun_server_2_; 166 std::unique_ptr<cricket::TestStunServer> stun_server_2_;
167 std::unique_ptr<rtc::AsyncPacketSocket> socket_; 167 std::unique_ptr<rtc::AsyncPacketSocket> socket_;
168 bool done_; 168 bool done_;
169 bool error_; 169 bool error_;
170 int stun_keepalive_delay_; 170 int stun_keepalive_delay_;
171 int stun_keepalive_lifetime_; 171 int stun_keepalive_lifetime_;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Test that by default, the STUN binding requests will last for a long time. 380 // Test that by default, the STUN binding requests will last for a long time.
381 TEST_F(StunPortTest, TestStunBindingRequestLongLifetime) { 381 TEST_F(StunPortTest, TestStunBindingRequestLongLifetime) {
382 SetKeepaliveDelay(101); 382 SetKeepaliveDelay(101);
383 CreateStunPort(kStunAddr1); 383 CreateStunPort(kStunAddr1);
384 PrepareAddress(); 384 PrepareAddress();
385 EXPECT_TRUE_SIMULATED_WAIT(done(), kTimeoutMs, fake_clock); 385 EXPECT_TRUE_SIMULATED_WAIT(done(), kTimeoutMs, fake_clock);
386 EXPECT_TRUE_SIMULATED_WAIT( 386 EXPECT_TRUE_SIMULATED_WAIT(
387 port()->HasPendingRequest(cricket::STUN_BINDING_REQUEST), 1000, 387 port()->HasPendingRequest(cricket::STUN_BINDING_REQUEST), 1000,
388 fake_clock); 388 fake_clock);
389 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698