henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
jbauch | 555604a | 2016-04-26 03:13:22 -0700 | [diff] [blame] | 11 | #include <memory> |
| 12 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 13 | #include "webrtc/base/gunit.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 14 | #include "webrtc/base/socket_unittest.h" |
| 15 | #include "webrtc/base/thread.h" |
| 16 | #include "webrtc/base/macsocketserver.h" |
| 17 | |
| 18 | namespace rtc { |
| 19 | |
| 20 | class WakeThread : public Thread { |
| 21 | public: |
| 22 | WakeThread(SocketServer* ss) : ss_(ss) { |
| 23 | } |
| 24 | virtual ~WakeThread() { |
| 25 | Stop(); |
| 26 | } |
| 27 | void Run() { |
| 28 | ss_->WakeUp(); |
| 29 | } |
| 30 | private: |
| 31 | SocketServer* ss_; |
| 32 | }; |
| 33 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 34 | // Test that MacAsyncSocket passes all the generic Socket tests. |
| 35 | class MacAsyncSocketTest : public SocketTest { |
| 36 | protected: |
| 37 | MacAsyncSocketTest() |
| 38 | : server_(CreateSocketServer()), |
| 39 | scope_(server_.get()) {} |
| 40 | // Override for other implementations of MacBaseSocketServer. |
| 41 | virtual MacBaseSocketServer* CreateSocketServer() { |
| 42 | return new MacCFSocketServer(); |
| 43 | }; |
jbauch | 555604a | 2016-04-26 03:13:22 -0700 | [diff] [blame] | 44 | std::unique_ptr<MacBaseSocketServer> server_; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 45 | SocketServerScope scope_; |
| 46 | }; |
| 47 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 48 | TEST_F(MacAsyncSocketTest, TestConnectIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 49 | SocketTest::TestConnectIPv4(); |
| 50 | } |
| 51 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 52 | TEST_F(MacAsyncSocketTest, TestConnectIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 53 | SocketTest::TestConnectIPv6(); |
| 54 | } |
| 55 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 56 | TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 57 | SocketTest::TestConnectWithDnsLookupIPv4(); |
| 58 | } |
| 59 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 60 | TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 61 | SocketTest::TestConnectWithDnsLookupIPv6(); |
| 62 | } |
| 63 | |
| 64 | // BUG=https://code.google.com/p/webrtc/issues/detail?id=2272 |
| 65 | TEST_F(MacAsyncSocketTest, DISABLED_TestConnectFailIPv4) { |
| 66 | SocketTest::TestConnectFailIPv4(); |
| 67 | } |
| 68 | |
Minyue | 524f784 | 2015-06-15 16:03:46 +0200 | [diff] [blame] | 69 | // Flaky. See webrtc:4738. |
| 70 | TEST_F(MacAsyncSocketTest, DISABLED_TestConnectFailIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 71 | SocketTest::TestConnectFailIPv6(); |
| 72 | } |
| 73 | |
| 74 | // Reenable once we have mac async dns |
| 75 | TEST_F(MacAsyncSocketTest, DISABLED_TestConnectWithDnsLookupFailIPv4) { |
| 76 | SocketTest::TestConnectWithDnsLookupFailIPv4(); |
| 77 | } |
| 78 | |
| 79 | TEST_F(MacAsyncSocketTest, DISABLED_TestConnectWithDnsLookupFailIPv6) { |
| 80 | SocketTest::TestConnectWithDnsLookupFailIPv6(); |
| 81 | } |
| 82 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 83 | TEST_F(MacAsyncSocketTest, TestConnectWithClosedSocketIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 84 | SocketTest::TestConnectWithClosedSocketIPv4(); |
| 85 | } |
| 86 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 87 | TEST_F(MacAsyncSocketTest, TestConnectWithClosedSocketIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 88 | SocketTest::TestConnectWithClosedSocketIPv6(); |
| 89 | } |
| 90 | |
| 91 | // Flaky at the moment (10% failure rate). Seems the client doesn't get |
| 92 | // signalled in a timely manner... |
| 93 | TEST_F(MacAsyncSocketTest, DISABLED_TestServerCloseDuringConnectIPv4) { |
| 94 | SocketTest::TestServerCloseDuringConnectIPv4(); |
| 95 | } |
| 96 | |
| 97 | TEST_F(MacAsyncSocketTest, DISABLED_TestServerCloseDuringConnectIPv6) { |
| 98 | SocketTest::TestServerCloseDuringConnectIPv6(); |
| 99 | } |
| 100 | // Flaky at the moment (0.5% failure rate). Seems the client doesn't get |
| 101 | // signalled in a timely manner... |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 102 | TEST_F(MacAsyncSocketTest, TestClientCloseDuringConnectIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 103 | SocketTest::TestClientCloseDuringConnectIPv4(); |
| 104 | } |
| 105 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 106 | TEST_F(MacAsyncSocketTest, TestClientCloseDuringConnectIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 107 | SocketTest::TestClientCloseDuringConnectIPv6(); |
| 108 | } |
| 109 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 110 | TEST_F(MacAsyncSocketTest, TestServerCloseIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 111 | SocketTest::TestServerCloseIPv4(); |
| 112 | } |
| 113 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 114 | TEST_F(MacAsyncSocketTest, TestServerCloseIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 115 | SocketTest::TestServerCloseIPv6(); |
| 116 | } |
| 117 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 118 | TEST_F(MacAsyncSocketTest, TestCloseInClosedCallbackIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 119 | SocketTest::TestCloseInClosedCallbackIPv4(); |
| 120 | } |
| 121 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 122 | TEST_F(MacAsyncSocketTest, TestCloseInClosedCallbackIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 123 | SocketTest::TestCloseInClosedCallbackIPv6(); |
| 124 | } |
| 125 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 126 | TEST_F(MacAsyncSocketTest, TestSocketServerWaitIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 127 | SocketTest::TestSocketServerWaitIPv4(); |
| 128 | } |
| 129 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 130 | TEST_F(MacAsyncSocketTest, TestSocketServerWaitIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 131 | SocketTest::TestSocketServerWaitIPv6(); |
| 132 | } |
| 133 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 134 | TEST_F(MacAsyncSocketTest, TestTcpIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 135 | SocketTest::TestTcpIPv4(); |
| 136 | } |
| 137 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 138 | TEST_F(MacAsyncSocketTest, TestTcpIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 139 | SocketTest::TestTcpIPv6(); |
| 140 | } |
| 141 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 142 | TEST_F(MacAsyncSocketTest, TestSingleFlowControlCallbackIPv4) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 143 | SocketTest::TestSingleFlowControlCallbackIPv4(); |
| 144 | } |
| 145 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 146 | TEST_F(MacAsyncSocketTest, TestSingleFlowControlCallbackIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 147 | SocketTest::TestSingleFlowControlCallbackIPv6(); |
| 148 | } |
| 149 | |
| 150 | TEST_F(MacAsyncSocketTest, DISABLED_TestUdpIPv4) { |
| 151 | SocketTest::TestUdpIPv4(); |
| 152 | } |
| 153 | |
| 154 | TEST_F(MacAsyncSocketTest, DISABLED_TestUdpIPv6) { |
| 155 | SocketTest::TestUdpIPv6(); |
| 156 | } |
| 157 | |
| 158 | TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv4) { |
| 159 | SocketTest::TestGetSetOptionsIPv4(); |
| 160 | } |
| 161 | |
| 162 | TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv6) { |
| 163 | SocketTest::TestGetSetOptionsIPv6(); |
| 164 | } |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 165 | } // namespace rtc |