OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2006 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 size_t sec_count; | 139 size_t sec_count; |
140 double sum; | 140 double sum; |
141 double sum_sq; | 141 double sum_sq; |
142 uint32_t samples; | 142 uint32_t samples; |
143 }; | 143 }; |
144 | 144 |
145 class VirtualSocketServerTest : public testing::Test { | 145 class VirtualSocketServerTest : public testing::Test { |
146 public: | 146 public: |
147 VirtualSocketServerTest() | 147 VirtualSocketServerTest() |
148 : ss_(new VirtualSocketServer(nullptr)), | 148 : ss_(new VirtualSocketServer(nullptr)), |
| 149 thread_(ss_), |
149 kIPv4AnyAddress(IPAddress(INADDR_ANY), 0), | 150 kIPv4AnyAddress(IPAddress(INADDR_ANY), 0), |
150 kIPv6AnyAddress(IPAddress(in6addr_any), 0) {} | 151 kIPv6AnyAddress(IPAddress(in6addr_any), 0) {} |
151 | 152 |
152 void CheckPortIncrementalization(const SocketAddress& post, | 153 void CheckPortIncrementalization(const SocketAddress& post, |
153 const SocketAddress& pre) { | 154 const SocketAddress& pre) { |
154 EXPECT_EQ(post.port(), pre.port() + 1); | 155 EXPECT_EQ(post.port(), pre.port() + 1); |
155 IPAddress post_ip = post.ipaddr(); | 156 IPAddress post_ip = post.ipaddr(); |
156 IPAddress pre_ip = pre.ipaddr(); | 157 IPAddress pre_ip = pre.ipaddr(); |
157 EXPECT_EQ(pre_ip.family(), post_ip.family()); | 158 EXPECT_EQ(pre_ip.family(), post_ip.family()); |
158 if (post_ip.family() == AF_INET) { | 159 if (post_ip.family() == AF_INET) { |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 EXPECT_EQ(6, client1->SendTo("bizbaz", 6, client2_addr)); | 816 EXPECT_EQ(6, client1->SendTo("bizbaz", 6, client2_addr)); |
816 EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &client1_addr)); | 817 EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &client1_addr)); |
817 EXPECT_EQ(client1_addr, bound_server_addr); | 818 EXPECT_EQ(client1_addr, bound_server_addr); |
818 } else { | 819 } else { |
819 EXPECT_EQ(-1, client2->SendTo("foo", 3, bound_server_addr)); | 820 EXPECT_EQ(-1, client2->SendTo("foo", 3, bound_server_addr)); |
820 EXPECT_TRUE(client1->CheckNoPacket()); | 821 EXPECT_TRUE(client1->CheckNoPacket()); |
821 } | 822 } |
822 } | 823 } |
823 | 824 |
824 protected: | 825 protected: |
825 virtual void SetUp() { | |
826 Thread::Current()->set_socketserver(ss_); | |
827 } | |
828 virtual void TearDown() { Thread::Current()->set_socketserver(nullptr); } | |
829 | |
830 VirtualSocketServer* ss_; | 826 VirtualSocketServer* ss_; |
| 827 AutoSocketServerThread thread_; |
831 const SocketAddress kIPv4AnyAddress; | 828 const SocketAddress kIPv4AnyAddress; |
832 const SocketAddress kIPv6AnyAddress; | 829 const SocketAddress kIPv6AnyAddress; |
833 }; | 830 }; |
834 | 831 |
835 TEST_F(VirtualSocketServerTest, basic_v4) { | 832 TEST_F(VirtualSocketServerTest, basic_v4) { |
836 SocketAddress ipv4_test_addr(IPAddress(INADDR_ANY), 5000); | 833 SocketAddress ipv4_test_addr(IPAddress(INADDR_ANY), 5000); |
837 BasicTest(ipv4_test_addr); | 834 BasicTest(ipv4_test_addr); |
838 } | 835 } |
839 | 836 |
840 TEST_F(VirtualSocketServerTest, basic_v6) { | 837 TEST_F(VirtualSocketServerTest, basic_v6) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 << " N=" << kTestSamples[sidx]; | 1117 << " N=" << kTestSamples[sidx]; |
1121 EXPECT_NEAR(kStdDev, stddev, 0.1 * kStdDev) | 1118 EXPECT_NEAR(kStdDev, stddev, 0.1 * kStdDev) |
1122 << "M=" << kTestMean[midx] | 1119 << "M=" << kTestMean[midx] |
1123 << " SD=" << kStdDev | 1120 << " SD=" << kStdDev |
1124 << " N=" << kTestSamples[sidx]; | 1121 << " N=" << kTestSamples[sidx]; |
1125 delete f; | 1122 delete f; |
1126 } | 1123 } |
1127 } | 1124 } |
1128 } | 1125 } |
1129 } | 1126 } |
OLD | NEW |