| 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 | |
| 92 // Test that MacAsyncSocket passes all the generic Socket tests. | 34 // Test that MacAsyncSocket passes all the generic Socket tests. |
| 93 class MacAsyncSocketTest : public SocketTest { | 35 class MacAsyncSocketTest : public SocketTest { |
| 94 protected: | 36 protected: |
| 95 MacAsyncSocketTest() | 37 MacAsyncSocketTest() |
| 96 : server_(CreateSocketServer()), | 38 : server_(CreateSocketServer()), |
| 97 scope_(server_.get()) {} | 39 scope_(server_.get()) {} |
| 98 // Override for other implementations of MacBaseSocketServer. | 40 // Override for other implementations of MacBaseSocketServer. |
| 99 virtual MacBaseSocketServer* CreateSocketServer() { | 41 virtual MacBaseSocketServer* CreateSocketServer() { |
| 100 return new MacCFSocketServer(); | 42 return new MacCFSocketServer(); |
| 101 }; | 43 }; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 SocketTest::TestUdpIPv6(); | 155 SocketTest::TestUdpIPv6(); |
| 214 } | 156 } |
| 215 | 157 |
| 216 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv4) { | 158 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv4) { |
| 217 SocketTest::TestGetSetOptionsIPv4(); | 159 SocketTest::TestGetSetOptionsIPv4(); |
| 218 } | 160 } |
| 219 | 161 |
| 220 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv6) { | 162 TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv6) { |
| 221 SocketTest::TestGetSetOptionsIPv6(); | 163 SocketTest::TestGetSetOptionsIPv6(); |
| 222 } | 164 } |
| 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 | |
| 239 } // namespace rtc | 165 } // namespace rtc |
| OLD | NEW |