OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/tcp_listen_socket_unittest.h" | 5 #include "net/socket/tcp_listen_socket_unittest.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/posix/eintr_wrapper.h" | 11 #include "base/posix/eintr_wrapper.h" |
12 #include "base/sys_byteorder.h" | 12 #include "base/sys_byteorder.h" |
13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 const int TCPListenSocketTester::kTestPort = 9999; | 18 const int TCPListenSocketTester::kTestPort = 9999; |
19 | 19 |
20 static const int kReadBufSize = 1024; | 20 static const int kReadBufSize = 1024; |
21 static const char kHelloWorld[] = "HELLO, WORLD"; | 21 static const char kHelloWorld[] = "HELLO, WORLD"; |
22 static const int kMaxQueueSize = 20; | 22 static const int kMaxQueueSize = 20; |
23 static const char kLoopback[] = "127.0.0.1"; | 23 static const char kLoopback[] = "127.0.0.1"; |
24 static const int kDefaultTimeoutMs = 5000; | 24 static const int kDefaultTimeoutMs = 5000; |
25 | 25 |
26 TCPListenSocketTester::TCPListenSocketTester() | 26 TCPListenSocketTester::TCPListenSocketTester() |
27 : thread_(NULL), | 27 : loop_(NULL), server_(NULL), connection_(NULL), cv_(&lock_) {} |
28 loop_(NULL), | |
29 server_(NULL), | |
30 connection_(NULL), | |
31 cv_(&lock_) { | |
32 } | |
33 | 28 |
34 void TCPListenSocketTester::SetUp() { | 29 void TCPListenSocketTester::SetUp() { |
35 base::Thread::Options options; | 30 base::Thread::Options options; |
36 options.message_loop_type = base::MessageLoop::TYPE_IO; | 31 options.message_loop_type = base::MessageLoop::TYPE_IO; |
37 thread_.reset(new base::Thread("socketio_test")); | 32 thread_.reset(new base::Thread("socketio_test")); |
38 thread_->StartWithOptions(options); | 33 thread_->StartWithOptions(options); |
39 loop_ = reinterpret_cast<base::MessageLoopForIO*>(thread_->message_loop()); | 34 loop_ = reinterpret_cast<base::MessageLoopForIO*>(thread_->message_loop()); |
40 | 35 |
41 loop_->PostTask(FROM_HERE, base::Bind( | 36 loop_->PostTask(FROM_HERE, base::Bind( |
42 &TCPListenSocketTester::Listen, this)); | 37 &TCPListenSocketTester::Listen, this)); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 282 |
288 TEST_F(TCPListenSocketTest, ServerSend) { | 283 TEST_F(TCPListenSocketTest, ServerSend) { |
289 tester_->TestServerSend(); | 284 tester_->TestServerSend(); |
290 } | 285 } |
291 | 286 |
292 TEST_F(TCPListenSocketTest, ServerSendMultiple) { | 287 TEST_F(TCPListenSocketTest, ServerSendMultiple) { |
293 tester_->TestServerSendMultiple(); | 288 tester_->TestServerSendMultiple(); |
294 } | 289 } |
295 | 290 |
296 } // namespace net | 291 } // namespace net |
OLD | NEW |