OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 virtual ~WakeThread() { | 24 virtual ~WakeThread() { |
25 Stop(); | 25 Stop(); |
26 } | 26 } |
27 void Run() { | 27 void Run() { |
28 ss_->WakeUp(); | 28 ss_->WakeUp(); |
29 } | 29 } |
30 private: | 30 private: |
31 SocketServer* ss_; | 31 SocketServer* ss_; |
32 }; | 32 }; |
33 | 33 |
| 34 #ifndef CARBON_DEPRECATED |
| 35 |
| 36 // Test that MacCFSocketServer::Wait works as expected. |
| 37 TEST(MacCFSocketServerTest, TestWait) { |
| 38 MacCFSocketServer server; |
| 39 uint32_t start = Time(); |
| 40 server.Wait(1000, true); |
| 41 EXPECT_GE(TimeSince(start), 1000); |
| 42 } |
| 43 |
| 44 // Test that MacCFSocketServer::Wakeup works as expected. |
| 45 TEST(MacCFSocketServerTest, TestWakeup) { |
| 46 MacCFSocketServer server; |
| 47 WakeThread thread(&server); |
| 48 uint32_t start = Time(); |
| 49 thread.Start(); |
| 50 server.Wait(10000, true); |
| 51 EXPECT_LT(TimeSince(start), 10000); |
| 52 } |
| 53 |
| 54 // Test that MacCarbonSocketServer::Wait works as expected. |
| 55 TEST(MacCarbonSocketServerTest, TestWait) { |
| 56 MacCarbonSocketServer server; |
| 57 uint32_t start = Time(); |
| 58 server.Wait(1000, true); |
| 59 EXPECT_GE(TimeSince(start), 1000); |
| 60 } |
| 61 |
| 62 // Test that MacCarbonSocketServer::Wakeup works as expected. |
| 63 TEST(MacCarbonSocketServerTest, TestWakeup) { |
| 64 MacCarbonSocketServer server; |
| 65 WakeThread thread(&server); |
| 66 uint32_t start = Time(); |
| 67 thread.Start(); |
| 68 server.Wait(10000, true); |
| 69 EXPECT_LT(TimeSince(start), 10000); |
| 70 } |
| 71 |
| 72 // Test that MacCarbonAppSocketServer::Wait works as expected. |
| 73 TEST(MacCarbonAppSocketServerTest, TestWait) { |
| 74 MacCarbonAppSocketServer server; |
| 75 uint32_t start = Time(); |
| 76 server.Wait(1000, true); |
| 77 EXPECT_GE(TimeSince(start), 1000); |
| 78 } |
| 79 |
| 80 // Test that MacCarbonAppSocketServer::Wakeup works as expected. |
| 81 TEST(MacCarbonAppSocketServerTest, TestWakeup) { |
| 82 MacCarbonAppSocketServer server; |
| 83 WakeThread thread(&server); |
| 84 uint32_t start = Time(); |
| 85 thread.Start(); |
| 86 server.Wait(10000, true); |
| 87 EXPECT_LT(TimeSince(start), 10000); |
| 88 } |
| 89 |
| 90 #endif |
| 91 |
34 // Test that MacAsyncSocket passes all the generic Socket tests. | 92 // Test that MacAsyncSocket passes all the generic Socket tests. |
35 class MacAsyncSocketTest : public SocketTest { | 93 class MacAsyncSocketTest : public SocketTest { |
36 protected: | 94 protected: |
37 MacAsyncSocketTest() | 95 MacAsyncSocketTest() |
38 : server_(CreateSocketServer()), | 96 : server_(CreateSocketServer()), |
39 scope_(server_.get()) {} | 97 scope_(server_.get()) {} |
40 // Override for other implementations of MacBaseSocketServer. | 98 // Override for other implementations of MacBaseSocketServer. |
41 virtual MacBaseSocketServer* CreateSocketServer() { | 99 virtual MacBaseSocketServer* CreateSocketServer() { |
42 return new MacCFSocketServer(); | 100 return new MacCFSocketServer(); |
43 }; | 101 }; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 SocketTest::TestUdpIPv6(); | 213 SocketTest::TestUdpIPv6(); |
156 } | 214 } |
157 | 215 |
158 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv4) { | 216 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv4) { |
159 SocketTest::TestGetSetOptionsIPv4(); | 217 SocketTest::TestGetSetOptionsIPv4(); |
160 } | 218 } |
161 | 219 |
162 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv6) { | 220 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv6) { |
163 SocketTest::TestGetSetOptionsIPv6(); | 221 SocketTest::TestGetSetOptionsIPv6(); |
164 } | 222 } |
| 223 |
| 224 #ifndef CARBON_DEPRECATED |
| 225 class MacCarbonAppAsyncSocketTest : public MacAsyncSocketTest { |
| 226 virtual MacBaseSocketServer* CreateSocketServer() { |
| 227 return new MacCarbonAppSocketServer(); |
| 228 }; |
| 229 }; |
| 230 |
| 231 TEST_F(MacCarbonAppAsyncSocketTest, TestSocketServerWaitIPv4) { |
| 232 SocketTest::TestSocketServerWaitIPv4(); |
| 233 } |
| 234 |
| 235 TEST_F(MacCarbonAppAsyncSocketTest, TestSocketServerWaitIPv6) { |
| 236 SocketTest::TestSocketServerWaitIPv6(); |
| 237 } |
| 238 #endif |
165 } // namespace rtc | 239 } // namespace rtc |
OLD | NEW |