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