OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 23 matching lines...) Expand all Loading... |
34 const rtc::SocketAddress kStunAddr1("1.1.1.1", 3478); | 34 const rtc::SocketAddress kStunAddr1("1.1.1.1", 3478); |
35 const rtc::SocketAddress kStunAddr2("1.1.1.2", 3478); | 35 const rtc::SocketAddress kStunAddr2("1.1.1.2", 3478); |
36 const rtc::SocketAddress kFailedStunAddr("1.1.1.3", 3478); | 36 const rtc::SocketAddress kFailedStunAddr("1.1.1.3", 3478); |
37 const rtc::SocketAddress kStunMappedAddr("77.77.77.77", 0); | 37 const rtc::SocketAddress kStunMappedAddr("77.77.77.77", 0); |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 class StunProberTest : public testing::Test { | 41 class StunProberTest : public testing::Test { |
42 public: | 42 public: |
43 StunProberTest() | 43 StunProberTest() |
44 : main_(rtc::Thread::Current()), | 44 : pss_(new rtc::PhysicalSocketServer), |
45 pss_(new rtc::PhysicalSocketServer), | |
46 ss_(new rtc::VirtualSocketServer(pss_.get())), | 45 ss_(new rtc::VirtualSocketServer(pss_.get())), |
47 ss_scope_(ss_.get()), | 46 main_(ss_.get()), |
48 result_(StunProber::SUCCESS), | 47 result_(StunProber::SUCCESS), |
49 stun_server_1_(cricket::TestStunServer::Create(rtc::Thread::Current(), | 48 stun_server_1_(cricket::TestStunServer::Create(rtc::Thread::Current(), |
50 kStunAddr1)), | 49 kStunAddr1)), |
51 stun_server_2_(cricket::TestStunServer::Create(rtc::Thread::Current(), | 50 stun_server_2_(cricket::TestStunServer::Create(rtc::Thread::Current(), |
52 kStunAddr2)) { | 51 kStunAddr2)) { |
53 stun_server_1_->set_fake_stun_addr(kStunMappedAddr); | 52 stun_server_1_->set_fake_stun_addr(kStunMappedAddr); |
54 stun_server_2_->set_fake_stun_addr(kStunMappedAddr); | 53 stun_server_2_->set_fake_stun_addr(kStunMappedAddr); |
55 rtc::InitializeSSL(); | 54 rtc::InitializeSSL(); |
56 } | 55 } |
57 | 56 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 EXPECT_EQ(static_cast<uint32_t>(stats.num_response_received), | 112 EXPECT_EQ(static_cast<uint32_t>(stats.num_response_received), |
114 total_pings_reported); | 113 total_pings_reported); |
115 } | 114 } |
116 | 115 |
117 private: | 116 private: |
118 void StopCallback(StunProber* prober, int result) { | 117 void StopCallback(StunProber* prober, int result) { |
119 EXPECT_EQ(result, result_); | 118 EXPECT_EQ(result, result_); |
120 stopped_ = true; | 119 stopped_ = true; |
121 } | 120 } |
122 | 121 |
123 rtc::Thread* main_; | |
124 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 122 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
125 std::unique_ptr<rtc::VirtualSocketServer> ss_; | 123 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
126 rtc::SocketServerScope ss_scope_; | 124 rtc::AutoSocketServerThread main_; |
127 std::unique_ptr<StunProber> prober; | 125 std::unique_ptr<StunProber> prober; |
128 int result_ = 0; | 126 int result_ = 0; |
129 bool stopped_ = false; | 127 bool stopped_ = false; |
130 std::unique_ptr<cricket::TestStunServer> stun_server_1_; | 128 std::unique_ptr<cricket::TestStunServer> stun_server_1_; |
131 std::unique_ptr<cricket::TestStunServer> stun_server_2_; | 129 std::unique_ptr<cricket::TestStunServer> stun_server_2_; |
132 }; | 130 }; |
133 | 131 |
134 TEST_F(StunProberTest, NonSharedMode) { | 132 TEST_F(StunProberTest, NonSharedMode) { |
135 RunProber(false); | 133 RunProber(false); |
136 } | 134 } |
137 | 135 |
138 TEST_F(StunProberTest, SharedMode) { | 136 TEST_F(StunProberTest, SharedMode) { |
139 RunProber(true); | 137 RunProber(true); |
140 } | 138 } |
141 | 139 |
142 } // namespace stunprober | 140 } // namespace stunprober |
OLD | NEW |