blob: 520d226899bc6ef5cff6495f7c35423dee2c7c7c [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
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
jbauch555604a2016-04-26 03:13:22 -070011#include <memory>
12
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000013#include "webrtc/base/gunit.h"
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000014#include "webrtc/base/socket_unittest.h"
15#include "webrtc/base/thread.h"
16#include "webrtc/base/macsocketserver.h"
17
18namespace rtc {
19
20class 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.orgf0488722014-05-13 18:00:26 +000034// Test that MacAsyncSocket passes all the generic Socket tests.
35class 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 };
jbauch555604a2016-04-26 03:13:22 -070044 std::unique_ptr<MacBaseSocketServer> server_;
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000045 SocketServerScope scope_;
46};
47
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +000048TEST_F(MacAsyncSocketTest, TestConnectIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000049 SocketTest::TestConnectIPv4();
50}
51
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +000052TEST_F(MacAsyncSocketTest, TestConnectIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000053 SocketTest::TestConnectIPv6();
54}
55
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +000056TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000057 SocketTest::TestConnectWithDnsLookupIPv4();
58}
59
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +000060TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000061 SocketTest::TestConnectWithDnsLookupIPv6();
62}
63
64// BUG=https://code.google.com/p/webrtc/issues/detail?id=2272
65TEST_F(MacAsyncSocketTest, DISABLED_TestConnectFailIPv4) {
66 SocketTest::TestConnectFailIPv4();
67}
68
Minyue524f7842015-06-15 16:03:46 +020069// Flaky. See webrtc:4738.
70TEST_F(MacAsyncSocketTest, DISABLED_TestConnectFailIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000071 SocketTest::TestConnectFailIPv6();
72}
73
74// Reenable once we have mac async dns
75TEST_F(MacAsyncSocketTest, DISABLED_TestConnectWithDnsLookupFailIPv4) {
76 SocketTest::TestConnectWithDnsLookupFailIPv4();
77}
78
79TEST_F(MacAsyncSocketTest, DISABLED_TestConnectWithDnsLookupFailIPv6) {
80 SocketTest::TestConnectWithDnsLookupFailIPv6();
81}
82
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +000083TEST_F(MacAsyncSocketTest, TestConnectWithClosedSocketIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000084 SocketTest::TestConnectWithClosedSocketIPv4();
85}
86
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +000087TEST_F(MacAsyncSocketTest, TestConnectWithClosedSocketIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000088 SocketTest::TestConnectWithClosedSocketIPv6();
89}
90
91// Flaky at the moment (10% failure rate). Seems the client doesn't get
92// signalled in a timely manner...
93TEST_F(MacAsyncSocketTest, DISABLED_TestServerCloseDuringConnectIPv4) {
94 SocketTest::TestServerCloseDuringConnectIPv4();
95}
96
97TEST_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.orgc732a3e2014-10-09 22:08:15 +0000102TEST_F(MacAsyncSocketTest, TestClientCloseDuringConnectIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000103 SocketTest::TestClientCloseDuringConnectIPv4();
104}
105
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000106TEST_F(MacAsyncSocketTest, TestClientCloseDuringConnectIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000107 SocketTest::TestClientCloseDuringConnectIPv6();
108}
109
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000110TEST_F(MacAsyncSocketTest, TestServerCloseIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000111 SocketTest::TestServerCloseIPv4();
112}
113
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000114TEST_F(MacAsyncSocketTest, TestServerCloseIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000115 SocketTest::TestServerCloseIPv6();
116}
117
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000118TEST_F(MacAsyncSocketTest, TestCloseInClosedCallbackIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000119 SocketTest::TestCloseInClosedCallbackIPv4();
120}
121
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000122TEST_F(MacAsyncSocketTest, TestCloseInClosedCallbackIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000123 SocketTest::TestCloseInClosedCallbackIPv6();
124}
125
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000126TEST_F(MacAsyncSocketTest, TestSocketServerWaitIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000127 SocketTest::TestSocketServerWaitIPv4();
128}
129
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000130TEST_F(MacAsyncSocketTest, TestSocketServerWaitIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000131 SocketTest::TestSocketServerWaitIPv6();
132}
133
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000134TEST_F(MacAsyncSocketTest, TestTcpIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000135 SocketTest::TestTcpIPv4();
136}
137
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000138TEST_F(MacAsyncSocketTest, TestTcpIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000139 SocketTest::TestTcpIPv6();
140}
141
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000142TEST_F(MacAsyncSocketTest, TestSingleFlowControlCallbackIPv4) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000143 SocketTest::TestSingleFlowControlCallbackIPv4();
144}
145
henrike@webrtc.orgc732a3e2014-10-09 22:08:15 +0000146TEST_F(MacAsyncSocketTest, TestSingleFlowControlCallbackIPv6) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000147 SocketTest::TestSingleFlowControlCallbackIPv6();
148}
149
150TEST_F(MacAsyncSocketTest, DISABLED_TestUdpIPv4) {
151 SocketTest::TestUdpIPv4();
152}
153
154TEST_F(MacAsyncSocketTest, DISABLED_TestUdpIPv6) {
155 SocketTest::TestUdpIPv6();
156}
157
158TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv4) {
159 SocketTest::TestGetSetOptionsIPv4();
160}
161
162TEST_F(MacAsyncSocketTest, DISABLED_TestGetSetOptionsIPv6) {
163 SocketTest::TestGetSetOptionsIPv6();
164}
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000165} // namespace rtc