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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
10 #include "net/base/net_log_unittest.h" | 10 #include "net/base/net_log_unittest.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); | 280 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
281 } | 281 } |
282 | 282 |
283 // Tests scenario when the client sends the handshake request in | 283 // Tests scenario when the client sends the handshake request in |
284 // more than one packet. | 284 // more than one packet. |
285 TEST_F(SOCKSClientSocketTest, PartialClientWrites) { | 285 TEST_F(SOCKSClientSocketTest, PartialClientWrites) { |
286 const char kSOCKSPartialRequest1[] = { 0x04, 0x01 }; | 286 const char kSOCKSPartialRequest1[] = { 0x04, 0x01 }; |
287 const char kSOCKSPartialRequest2[] = { 0x00, 0x50, 127, 0, 0, 1, 0 }; | 287 const char kSOCKSPartialRequest2[] = { 0x00, 0x50, 127, 0, 0, 1, 0 }; |
288 | 288 |
289 MockWrite data_writes[] = { | 289 MockWrite data_writes[] = { |
290 MockWrite(ASYNC, arraysize(kSOCKSPartialRequest1)), | 290 MockWrite(ASYNC, kSOCKSPartialRequest1, arraysize(kSOCKSPartialRequest1)), |
291 // simulate some empty writes | 291 // simulate some empty writes |
292 MockWrite(ASYNC, 0), | 292 MockWrite(ASYNC, 0), |
293 MockWrite(ASYNC, 0), | 293 MockWrite(ASYNC, 0), |
294 MockWrite(ASYNC, kSOCKSPartialRequest2, | 294 MockWrite(ASYNC, kSOCKSPartialRequest2, arraysize(kSOCKSPartialRequest2)), |
295 arraysize(kSOCKSPartialRequest2)) }; | 295 }; |
296 MockRead data_reads[] = { | 296 MockRead data_reads[] = { |
297 MockRead(ASYNC, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; | 297 MockRead(ASYNC, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; |
298 CapturingNetLog log; | 298 CapturingNetLog log; |
299 | 299 |
300 user_sock_ = BuildMockSocket(data_reads, arraysize(data_reads), | 300 user_sock_ = BuildMockSocket(data_reads, arraysize(data_reads), |
301 data_writes, arraysize(data_writes), | 301 data_writes, arraysize(data_writes), |
302 host_resolver_.get(), | 302 host_resolver_.get(), |
303 "localhost", 80, | 303 "localhost", 80, |
304 &log); | 304 &log); |
305 | 305 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 NULL, 0, | 441 NULL, 0, |
442 host_resolver.get(), | 442 host_resolver.get(), |
443 kHostName, 80, | 443 kHostName, 80, |
444 NULL); | 444 NULL); |
445 | 445 |
446 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, | 446 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, |
447 callback_.GetResult(user_sock_->Connect(callback_.callback()))); | 447 callback_.GetResult(user_sock_->Connect(callback_.callback()))); |
448 } | 448 } |
449 | 449 |
450 } // namespace net | 450 } // namespace net |
OLD | NEW |