| 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/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
| 6 | 6 |
| 7 #include "net/base/address_list.h" | 7 #include "net/base/address_list.h" |
| 8 #include "net/base/net_log.h" | 8 #include "net/base/net_log.h" |
| 9 #include "net/base/net_log_unittest.h" | 9 #include "net/base/net_log_unittest.h" |
| 10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 rv = callback_.WaitForResult(); | 156 rv = callback_.WaitForResult(); |
| 157 EXPECT_EQ(OK, rv); | 157 EXPECT_EQ(OK, rv); |
| 158 EXPECT_TRUE(user_sock_->IsConnected()); | 158 EXPECT_TRUE(user_sock_->IsConnected()); |
| 159 log.GetEntries(&entries); | 159 log.GetEntries(&entries); |
| 160 EXPECT_TRUE(LogContainsEndEvent( | 160 EXPECT_TRUE(LogContainsEndEvent( |
| 161 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); | 161 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
| 162 | 162 |
| 163 scoped_refptr<IOBuffer> buffer(new IOBuffer(payload_write.size())); | 163 scoped_refptr<IOBuffer> buffer(new IOBuffer(payload_write.size())); |
| 164 memcpy(buffer->data(), payload_write.data(), payload_write.size()); | 164 memcpy(buffer->data(), payload_write.data(), payload_write.size()); |
| 165 rv = user_sock_->Write(buffer, payload_write.size(), callback_.callback()); | 165 rv = user_sock_->Write( |
| 166 buffer.get(), payload_write.size(), callback_.callback()); |
| 166 EXPECT_EQ(ERR_IO_PENDING, rv); | 167 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 167 rv = callback_.WaitForResult(); | 168 rv = callback_.WaitForResult(); |
| 168 EXPECT_EQ(static_cast<int>(payload_write.size()), rv); | 169 EXPECT_EQ(static_cast<int>(payload_write.size()), rv); |
| 169 | 170 |
| 170 buffer = new IOBuffer(payload_read.size()); | 171 buffer = new IOBuffer(payload_read.size()); |
| 171 rv = user_sock_->Read(buffer, payload_read.size(), callback_.callback()); | 172 rv = |
| 173 user_sock_->Read(buffer.get(), payload_read.size(), callback_.callback()); |
| 172 EXPECT_EQ(ERR_IO_PENDING, rv); | 174 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 173 rv = callback_.WaitForResult(); | 175 rv = callback_.WaitForResult(); |
| 174 EXPECT_EQ(static_cast<int>(payload_read.size()), rv); | 176 EXPECT_EQ(static_cast<int>(payload_read.size()), rv); |
| 175 EXPECT_EQ(payload_read, std::string(buffer->data(), payload_read.size())); | 177 EXPECT_EQ(payload_read, std::string(buffer->data(), payload_read.size())); |
| 176 | 178 |
| 177 user_sock_->Disconnect(); | 179 user_sock_->Disconnect(); |
| 178 EXPECT_FALSE(tcp_sock_->IsConnected()); | 180 EXPECT_FALSE(tcp_sock_->IsConnected()); |
| 179 EXPECT_FALSE(user_sock_->IsConnected()); | 181 EXPECT_FALSE(user_sock_->IsConnected()); |
| 180 } | 182 } |
| 181 | 183 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. | 397 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. |
| 396 user_sock_->Disconnect(); | 398 user_sock_->Disconnect(); |
| 397 | 399 |
| 398 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); | 400 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); |
| 399 | 401 |
| 400 EXPECT_FALSE(user_sock_->IsConnected()); | 402 EXPECT_FALSE(user_sock_->IsConnected()); |
| 401 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); | 403 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); |
| 402 } | 404 } |
| 403 | 405 |
| 404 } // namespace net | 406 } // namespace net |
| OLD | NEW |