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/socket_test_util.h" | 5 #include "net/socket/socket_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "net/base/address_family.h" | 17 #include "net/base/address_family.h" |
18 #include "net/base/address_list.h" | 18 #include "net/base/address_list.h" |
19 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
20 #include "net/base/load_timing_info.h" | 20 #include "net/base/load_timing_info.h" |
| 21 #include "net/base/test_data_directory.h" |
21 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
22 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
23 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
24 #include "net/socket/socket.h" | 25 #include "net/socket/socket.h" |
25 #include "net/socket/websocket_endpoint_lock_manager.h" | 26 #include "net/socket/websocket_endpoint_lock_manager.h" |
26 #include "net/ssl/ssl_cert_request_info.h" | 27 #include "net/ssl/ssl_cert_request_info.h" |
27 #include "net/ssl/ssl_connection_status_flags.h" | 28 #include "net/ssl/ssl_connection_status_flags.h" |
28 #include "net/ssl/ssl_info.h" | 29 #include "net/ssl/ssl_info.h" |
| 30 #include "net/test/cert_test_util.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
30 | 32 |
31 #define NET_TRACE(level, s) VLOG(level) << s << __FUNCTION__ << "() " | 33 #define NET_TRACE(level, s) VLOG(level) << s << __FUNCTION__ << "() " |
32 | 34 |
33 namespace net { | 35 namespace net { |
34 | 36 |
35 namespace { | 37 namespace { |
36 | 38 |
37 inline char AsciifyHigh(char x) { | 39 inline char AsciifyHigh(char x) { |
38 char nybble = static_cast<char>((x >> 4) & 0x0F); | 40 char nybble = static_cast<char>((x >> 4) & 0x0F); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 SSLSocketDataProvider::~SSLSocketDataProvider() { | 290 SSLSocketDataProvider::~SSLSocketDataProvider() { |
289 } | 291 } |
290 | 292 |
291 void SSLSocketDataProvider::SetNextProto(NextProto proto) { | 293 void SSLSocketDataProvider::SetNextProto(NextProto proto) { |
292 was_npn_negotiated = true; | 294 was_npn_negotiated = true; |
293 next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 295 next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
294 protocol_negotiated = proto; | 296 protocol_negotiated = proto; |
295 next_proto = SSLClientSocket::NextProtoToString(proto); | 297 next_proto = SSLClientSocket::NextProtoToString(proto); |
296 } | 298 } |
297 | 299 |
| 300 void SSLSocketDataProvider::SetCertFromFile(const std::string& cert_filename) { |
| 301 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 302 cert = ImportCertFromFile(certs_dir, cert_filename); |
| 303 ASSERT_NE(nullptr, cert.get()); |
| 304 } |
| 305 |
298 DelayedSocketData::DelayedSocketData( | 306 DelayedSocketData::DelayedSocketData( |
299 int write_delay, MockRead* reads, size_t reads_count, | 307 int write_delay, MockRead* reads, size_t reads_count, |
300 MockWrite* writes, size_t writes_count) | 308 MockWrite* writes, size_t writes_count) |
301 : StaticSocketDataProvider(reads, reads_count, writes, writes_count), | 309 : StaticSocketDataProvider(reads, reads_count, writes, writes_count), |
302 write_delay_(write_delay), | 310 write_delay_(write_delay), |
303 read_in_progress_(false), | 311 read_in_progress_(false), |
304 weak_factory_(this) { | 312 weak_factory_(this) { |
305 DCHECK_GE(write_delay_, 0); | 313 DCHECK_GE(write_delay_, 0); |
306 } | 314 } |
307 | 315 |
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 | 1933 |
1926 const char kSOCKS5OkRequest[] = | 1934 const char kSOCKS5OkRequest[] = |
1927 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1935 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1928 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1936 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1929 | 1937 |
1930 const char kSOCKS5OkResponse[] = | 1938 const char kSOCKS5OkResponse[] = |
1931 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1939 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1932 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1940 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1933 | 1941 |
1934 } // namespace net | 1942 } // namespace net |
OLD | NEW |