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" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 DCHECK(!at_read_eof()); | 164 DCHECK(!at_read_eof()); |
165 reads_[read_index_].time_stamp = base::Time::Now(); | 165 reads_[read_index_].time_stamp = base::Time::Now(); |
166 return reads_[read_index_++]; | 166 return reads_[read_index_++]; |
167 } | 167 } |
168 | 168 |
169 MockWriteResult StaticSocketDataProvider::OnWrite(const std::string& data) { | 169 MockWriteResult StaticSocketDataProvider::OnWrite(const std::string& data) { |
170 if (!writes_) { | 170 if (!writes_) { |
171 // Not using mock writes; succeed synchronously. | 171 // Not using mock writes; succeed synchronously. |
172 return MockWriteResult(SYNCHRONOUS, data.length()); | 172 return MockWriteResult(SYNCHRONOUS, data.length()); |
173 } | 173 } |
174 LOG(INFO) << "about to write: " << data; | |
175 DCHECK(!at_write_eof()); | 174 DCHECK(!at_write_eof()); |
176 | 175 |
177 // Check that what we are writing matches the expectation. | 176 // Check that what we are writing matches the expectation. |
178 // Then give the mocked return value. | 177 // Then give the mocked return value. |
179 MockWrite* w = &writes_[write_index_++]; | 178 MockWrite* w = &writes_[write_index_++]; |
180 w->time_stamp = base::Time::Now(); | 179 w->time_stamp = base::Time::Now(); |
181 int result = w->result; | 180 int result = w->result; |
182 if (w->data) { | 181 if (w->data) { |
183 // Note - we can simulate a partial write here. If the expected data | 182 // Note - we can simulate a partial write here. If the expected data |
184 // is a match, but shorter than the write actually written, that is legal. | 183 // is a match, but shorter than the write actually written, that is legal. |
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 | 1619 |
1621 const char kSOCKS5OkRequest[] = | 1620 const char kSOCKS5OkRequest[] = |
1622 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1621 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1623 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1622 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1624 | 1623 |
1625 const char kSOCKS5OkResponse[] = | 1624 const char kSOCKS5OkResponse[] = |
1626 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1625 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1627 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1626 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1628 | 1627 |
1629 } // namespace net | 1628 } // namespace net |
OLD | NEW |