| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | 169 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), |
| 170 request->GetTotalSentBytes()); | 170 request->GetTotalSentBytes()); |
| 171 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), | 171 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), |
| 172 request->GetTotalReceivedBytes()); | 172 request->GetTotalReceivedBytes()); |
| 173 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | 173 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), |
| 174 network_delegate_.total_network_bytes_sent()); | 174 network_delegate_.total_network_bytes_sent()); |
| 175 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), | 175 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), |
| 176 network_delegate_.total_network_bytes_received()); | 176 network_delegate_.total_network_bytes_received()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 TEST_F(URLRequestHttpJobWithMockSocketsTest, | |
| 180 TestContentLengthSuccessfulHttp09Request) { | |
| 181 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; | |
| 182 MockRead reads[] = {MockRead("Test Content"), | |
| 183 MockRead(net::SYNCHRONOUS, net::OK)}; | |
| 184 | |
| 185 StaticSocketDataProvider socket_data(reads, arraysize(reads), nullptr, 0); | |
| 186 socket_factory_.AddSocketDataProvider(&socket_data); | |
| 187 | |
| 188 TestDelegate delegate; | |
| 189 std::unique_ptr<URLRequest> request = context_->CreateRequest( | |
| 190 GURL("http://www.example.com"), DEFAULT_PRIORITY, &delegate); | |
| 191 | |
| 192 request->Start(); | |
| 193 ASSERT_TRUE(request->is_pending()); | |
| 194 base::RunLoop().Run(); | |
| 195 | |
| 196 EXPECT_TRUE(request->status().is_success()); | |
| 197 EXPECT_EQ(12, request->received_response_content_length()); | |
| 198 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | |
| 199 request->GetTotalSentBytes()); | |
| 200 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), | |
| 201 request->GetTotalReceivedBytes()); | |
| 202 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | |
| 203 network_delegate_.total_network_bytes_sent()); | |
| 204 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), | |
| 205 network_delegate_.total_network_bytes_received()); | |
| 206 } | |
| 207 | |
| 208 TEST_F(URLRequestHttpJobWithMockSocketsTest, TestContentLengthFailedRequest) { | 179 TEST_F(URLRequestHttpJobWithMockSocketsTest, TestContentLengthFailedRequest) { |
| 209 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; | 180 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; |
| 210 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" | 181 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" |
| 211 "Content-Length: 20\r\n\r\n"), | 182 "Content-Length: 20\r\n\r\n"), |
| 212 MockRead("Test Content"), | 183 MockRead("Test Content"), |
| 213 MockRead(net::SYNCHRONOUS, net::ERR_FAILED)}; | 184 MockRead(net::SYNCHRONOUS, net::ERR_FAILED)}; |
| 214 | 185 |
| 215 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, | 186 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, |
| 216 arraysize(writes)); | 187 arraysize(writes)); |
| 217 socket_factory_.AddSocketDataProvider(&socket_data); | 188 socket_factory_.AddSocketDataProvider(&socket_data); |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 base::RunLoop().RunUntilIdle(); | 968 base::RunLoop().RunUntilIdle(); |
| 998 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); | 969 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); |
| 999 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); | 970 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); |
| 1000 } | 971 } |
| 1001 | 972 |
| 1002 #endif // defined(ENABLE_WEBSOCKETS) | 973 #endif // defined(ENABLE_WEBSOCKETS) |
| 1003 | 974 |
| 1004 } // namespace | 975 } // namespace |
| 1005 | 976 |
| 1006 } // namespace net | 977 } // namespace net |
| OLD | NEW |