OLD | NEW |
| (Empty) |
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 | |
11 #include <memory> | |
12 | |
13 #include "webrtc/base/gunit.h" | |
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 | |
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 }; | |
44 std::unique_ptr<MacBaseSocketServer> server_; | |
45 SocketServerScope scope_; | |
46 }; | |
47 | |
48 TEST_F(MacAsyncSocketTest, TestConnectIPv4) { | |
49 SocketTest::TestConnectIPv4(); | |
50 } | |
51 | |
52 TEST_F(MacAsyncSocketTest, TestConnectIPv6) { | |
53 SocketTest::TestConnectIPv6(); | |
54 } | |
55 | |
56 TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv4) { | |
57 SocketTest::TestConnectWithDnsLookupIPv4(); | |
58 } | |
59 | |
60 TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv6) { | |
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 | |
69 // Flaky. See webrtc:4738. | |
70 TEST_F(MacAsyncSocketTest, DISABLED_TestConnectFailIPv6) { | |
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 | |
83 TEST_F(MacAsyncSocketTest, TestConnectWithClosedSocketIPv4) { | |
84 SocketTest::TestConnectWithClosedSocketIPv4(); | |
85 } | |
86 | |
87 TEST_F(MacAsyncSocketTest, TestConnectWithClosedSocketIPv6) { | |
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... | |
102 TEST_F(MacAsyncSocketTest, TestClientCloseDuringConnectIPv4) { | |
103 SocketTest::TestClientCloseDuringConnectIPv4(); | |
104 } | |
105 | |
106 TEST_F(MacAsyncSocketTest, TestClientCloseDuringConnectIPv6) { | |
107 SocketTest::TestClientCloseDuringConnectIPv6(); | |
108 } | |
109 | |
110 TEST_F(MacAsyncSocketTest, TestServerCloseIPv4) { | |
111 SocketTest::TestServerCloseIPv4(); | |
112 } | |
113 | |
114 TEST_F(MacAsyncSocketTest, TestServerCloseIPv6) { | |
115 SocketTest::TestServerCloseIPv6(); | |
116 } | |
117 | |
118 TEST_F(MacAsyncSocketTest, TestCloseInClosedCallbackIPv4) { | |
119 SocketTest::TestCloseInClosedCallbackIPv4(); | |
120 } | |
121 | |
122 TEST_F(MacAsyncSocketTest, TestCloseInClosedCallbackIPv6) { | |
123 SocketTest::TestCloseInClosedCallbackIPv6(); | |
124 } | |
125 | |
126 TEST_F(MacAsyncSocketTest, TestSocketServerWaitIPv4) { | |
127 SocketTest::TestSocketServerWaitIPv4(); | |
128 } | |
129 | |
130 TEST_F(MacAsyncSocketTest, TestSocketServerWaitIPv6) { | |
131 SocketTest::TestSocketServerWaitIPv6(); | |
132 } | |
133 | |
134 TEST_F(MacAsyncSocketTest, TestTcpIPv4) { | |
135 SocketTest::TestTcpIPv4(); | |
136 } | |
137 | |
138 TEST_F(MacAsyncSocketTest, TestTcpIPv6) { | |
139 SocketTest::TestTcpIPv6(); | |
140 } | |
141 | |
142 TEST_F(MacAsyncSocketTest, TestSingleFlowControlCallbackIPv4) { | |
143 SocketTest::TestSingleFlowControlCallbackIPv4(); | |
144 } | |
145 | |
146 TEST_F(MacAsyncSocketTest, TestSingleFlowControlCallbackIPv6) { | |
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 } | |
165 } // namespace rtc | |
OLD | NEW |