| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/listen_socket_unittest.h" | 5 #include "net/base/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/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 loop_->PostTask(FROM_HERE, NewRunnableMethod( | 66 loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 67 this, &ListenSocketTester::Shutdown)); | 67 this, &ListenSocketTester::Shutdown)); |
| 68 NextAction(); | 68 NextAction(); |
| 69 ASSERT_EQ(ACTION_SHUTDOWN, last_action_.type()); | 69 ASSERT_EQ(ACTION_SHUTDOWN, last_action_.type()); |
| 70 | 70 |
| 71 thread_.reset(); | 71 thread_.reset(); |
| 72 loop_ = NULL; | 72 loop_ = NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ListenSocketTester::ReportAction(const ListenSocketTestAction& action) { | 75 void ListenSocketTester::ReportAction(const ListenSocketTestAction& action) { |
| 76 AutoLock locked(lock_); | 76 base::AutoLock locked(lock_); |
| 77 queue_.push_back(action); | 77 queue_.push_back(action); |
| 78 cv_.Broadcast(); | 78 cv_.Broadcast(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void ListenSocketTester::NextAction() { | 81 void ListenSocketTester::NextAction() { |
| 82 AutoLock locked(lock_); | 82 base::AutoLock locked(lock_); |
| 83 while (queue_.empty()) | 83 while (queue_.empty()) |
| 84 cv_.Wait(); | 84 cv_.Wait(); |
| 85 last_action_ = queue_.front(); | 85 last_action_ = queue_.front(); |
| 86 queue_.pop_front(); | 86 queue_.pop_front(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 int ListenSocketTester::ClearTestSocket() { | 89 int ListenSocketTester::ClearTestSocket() { |
| 90 char buf[kReadBufSize]; | 90 char buf[kReadBufSize]; |
| 91 int len_ret = 0; | 91 int len_ret = 0; |
| 92 do { | 92 do { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 tester_->TestClientSend(); | 226 tester_->TestClientSend(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 TEST_F(ListenSocketTest, ClientSendLong) { | 229 TEST_F(ListenSocketTest, ClientSendLong) { |
| 230 tester_->TestClientSendLong(); | 230 tester_->TestClientSendLong(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 TEST_F(ListenSocketTest, ServerSend) { | 233 TEST_F(ListenSocketTest, ServerSend) { |
| 234 tester_->TestServerSend(); | 234 tester_->TestServerSend(); |
| 235 } | 235 } |
| OLD | NEW |