Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 9419032: Modify the MockConnect constructor to take an enum of ASYNC or SYNC, instead (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix Test Break Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 6430 matching lines...) Expand 10 before | Expand all | Expand 10 after
6441 6441
6442 TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) { 6442 TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) {
6443 HttpStreamFactory::set_use_alternate_protocols(true); 6443 HttpStreamFactory::set_use_alternate_protocols(true);
6444 SessionDependencies session_deps; 6444 SessionDependencies session_deps;
6445 6445
6446 HttpRequestInfo request; 6446 HttpRequestInfo request;
6447 request.method = "GET"; 6447 request.method = "GET";
6448 request.url = GURL("http://www.google.com/"); 6448 request.url = GURL("http://www.google.com/");
6449 request.load_flags = 0; 6449 request.load_flags = 0;
6450 6450
6451 MockConnect mock_connect(true, ERR_CONNECTION_REFUSED); 6451 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
6452 StaticSocketDataProvider first_data; 6452 StaticSocketDataProvider first_data;
6453 first_data.set_connect_data(mock_connect); 6453 first_data.set_connect_data(mock_connect);
6454 session_deps.socket_factory.AddSocketDataProvider(&first_data); 6454 session_deps.socket_factory.AddSocketDataProvider(&first_data);
6455 6455
6456 MockRead data_reads[] = { 6456 MockRead data_reads[] = {
6457 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 6457 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
6458 MockRead("hello world"), 6458 MockRead("hello world"),
6459 MockRead(true, OK), 6459 MockRead(true, OK),
6460 }; 6460 };
6461 StaticSocketDataProvider second_data( 6461 StaticSocketDataProvider second_data(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6504 // on a restricted port (port < 1024). Ensure that we can redirect in all 6504 // on a restricted port (port < 1024). Ensure that we can redirect in all
6505 // other cases. 6505 // other cases.
6506 HttpStreamFactory::set_use_alternate_protocols(true); 6506 HttpStreamFactory::set_use_alternate_protocols(true);
6507 SessionDependencies session_deps; 6507 SessionDependencies session_deps;
6508 6508
6509 HttpRequestInfo restricted_port_request; 6509 HttpRequestInfo restricted_port_request;
6510 restricted_port_request.method = "GET"; 6510 restricted_port_request.method = "GET";
6511 restricted_port_request.url = GURL("http://www.google.com:1023/"); 6511 restricted_port_request.url = GURL("http://www.google.com:1023/");
6512 restricted_port_request.load_flags = 0; 6512 restricted_port_request.load_flags = 0;
6513 6513
6514 MockConnect mock_connect(true, ERR_CONNECTION_REFUSED); 6514 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
6515 StaticSocketDataProvider first_data; 6515 StaticSocketDataProvider first_data;
6516 first_data.set_connect_data(mock_connect); 6516 first_data.set_connect_data(mock_connect);
6517 session_deps.socket_factory.AddSocketDataProvider(&first_data); 6517 session_deps.socket_factory.AddSocketDataProvider(&first_data);
6518 6518
6519 MockRead data_reads[] = { 6519 MockRead data_reads[] = {
6520 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 6520 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
6521 MockRead("hello world"), 6521 MockRead("hello world"),
6522 MockRead(true, OK), 6522 MockRead(true, OK),
6523 }; 6523 };
6524 StaticSocketDataProvider second_data( 6524 StaticSocketDataProvider second_data(
(...skipping 28 matching lines...) Expand all
6553 // on a restricted port (port < 1024). Ensure that we can redirect in all 6553 // on a restricted port (port < 1024). Ensure that we can redirect in all
6554 // other cases. 6554 // other cases.
6555 HttpStreamFactory::set_use_alternate_protocols(true); 6555 HttpStreamFactory::set_use_alternate_protocols(true);
6556 SessionDependencies session_deps; 6556 SessionDependencies session_deps;
6557 6557
6558 HttpRequestInfo restricted_port_request; 6558 HttpRequestInfo restricted_port_request;
6559 restricted_port_request.method = "GET"; 6559 restricted_port_request.method = "GET";
6560 restricted_port_request.url = GURL("http://www.google.com:1023/"); 6560 restricted_port_request.url = GURL("http://www.google.com:1023/");
6561 restricted_port_request.load_flags = 0; 6561 restricted_port_request.load_flags = 0;
6562 6562
6563 MockConnect mock_connect(true, ERR_CONNECTION_REFUSED); 6563 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
6564 StaticSocketDataProvider first_data; 6564 StaticSocketDataProvider first_data;
6565 first_data.set_connect_data(mock_connect); 6565 first_data.set_connect_data(mock_connect);
6566 session_deps.socket_factory.AddSocketDataProvider(&first_data); 6566 session_deps.socket_factory.AddSocketDataProvider(&first_data);
6567 6567
6568 MockRead data_reads[] = { 6568 MockRead data_reads[] = {
6569 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 6569 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
6570 MockRead("hello world"), 6570 MockRead("hello world"),
6571 MockRead(true, OK), 6571 MockRead(true, OK),
6572 }; 6572 };
6573 StaticSocketDataProvider second_data( 6573 StaticSocketDataProvider second_data(
(...skipping 28 matching lines...) Expand all
6602 // on a restricted port (port < 1024). Ensure that we can redirect in all 6602 // on a restricted port (port < 1024). Ensure that we can redirect in all
6603 // other cases. 6603 // other cases.
6604 HttpStreamFactory::set_use_alternate_protocols(true); 6604 HttpStreamFactory::set_use_alternate_protocols(true);
6605 SessionDependencies session_deps; 6605 SessionDependencies session_deps;
6606 6606
6607 HttpRequestInfo unrestricted_port_request; 6607 HttpRequestInfo unrestricted_port_request;
6608 unrestricted_port_request.method = "GET"; 6608 unrestricted_port_request.method = "GET";
6609 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); 6609 unrestricted_port_request.url = GURL("http://www.google.com:1024/");
6610 unrestricted_port_request.load_flags = 0; 6610 unrestricted_port_request.load_flags = 0;
6611 6611
6612 MockConnect mock_connect(true, ERR_CONNECTION_REFUSED); 6612 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
6613 StaticSocketDataProvider first_data; 6613 StaticSocketDataProvider first_data;
6614 first_data.set_connect_data(mock_connect); 6614 first_data.set_connect_data(mock_connect);
6615 session_deps.socket_factory.AddSocketDataProvider(&first_data); 6615 session_deps.socket_factory.AddSocketDataProvider(&first_data);
6616 6616
6617 MockRead data_reads[] = { 6617 MockRead data_reads[] = {
6618 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 6618 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
6619 MockRead("hello world"), 6619 MockRead("hello world"),
6620 MockRead(true, OK), 6620 MockRead(true, OK),
6621 }; 6621 };
6622 StaticSocketDataProvider second_data( 6622 StaticSocketDataProvider second_data(
(...skipping 28 matching lines...) Expand all
6651 // on a restricted port (port < 1024). Ensure that we can redirect in all 6651 // on a restricted port (port < 1024). Ensure that we can redirect in all
6652 // other cases. 6652 // other cases.
6653 HttpStreamFactory::set_use_alternate_protocols(true); 6653 HttpStreamFactory::set_use_alternate_protocols(true);
6654 SessionDependencies session_deps; 6654 SessionDependencies session_deps;
6655 6655
6656 HttpRequestInfo unrestricted_port_request; 6656 HttpRequestInfo unrestricted_port_request;
6657 unrestricted_port_request.method = "GET"; 6657 unrestricted_port_request.method = "GET";
6658 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); 6658 unrestricted_port_request.url = GURL("http://www.google.com:1024/");
6659 unrestricted_port_request.load_flags = 0; 6659 unrestricted_port_request.load_flags = 0;
6660 6660
6661 MockConnect mock_connect(true, ERR_CONNECTION_REFUSED); 6661 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
6662 StaticSocketDataProvider first_data; 6662 StaticSocketDataProvider first_data;
6663 first_data.set_connect_data(mock_connect); 6663 first_data.set_connect_data(mock_connect);
6664 session_deps.socket_factory.AddSocketDataProvider(&first_data); 6664 session_deps.socket_factory.AddSocketDataProvider(&first_data);
6665 6665
6666 MockRead data_reads[] = { 6666 MockRead data_reads[] = {
6667 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 6667 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
6668 MockRead("hello world"), 6668 MockRead("hello world"),
6669 MockRead(true, OK), 6669 MockRead(true, OK),
6670 }; 6670 };
6671 StaticSocketDataProvider second_data( 6671 StaticSocketDataProvider second_data(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
6787 MockRead(true, 0, 0), 6787 MockRead(true, 0, 0),
6788 }; 6788 };
6789 6789
6790 scoped_ptr<DelayedSocketData> spdy_data( 6790 scoped_ptr<DelayedSocketData> spdy_data(
6791 new DelayedSocketData( 6791 new DelayedSocketData(
6792 1, // wait for one write to finish before reading. 6792 1, // wait for one write to finish before reading.
6793 spdy_reads, arraysize(spdy_reads), 6793 spdy_reads, arraysize(spdy_reads),
6794 spdy_writes, arraysize(spdy_writes))); 6794 spdy_writes, arraysize(spdy_writes)));
6795 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); 6795 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get());
6796 6796
6797 MockConnect never_finishing_connect(false, ERR_IO_PENDING); 6797 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
6798 StaticSocketDataProvider hanging_non_alternate_protocol_socket( 6798 StaticSocketDataProvider hanging_non_alternate_protocol_socket(
6799 NULL, 0, NULL, 0); 6799 NULL, 0, NULL, 0);
6800 hanging_non_alternate_protocol_socket.set_connect_data( 6800 hanging_non_alternate_protocol_socket.set_connect_data(
6801 never_finishing_connect); 6801 never_finishing_connect);
6802 session_deps.socket_factory.AddSocketDataProvider( 6802 session_deps.socket_factory.AddSocketDataProvider(
6803 &hanging_non_alternate_protocol_socket); 6803 &hanging_non_alternate_protocol_socket);
6804 6804
6805 TestCompletionCallback callback; 6805 TestCompletionCallback callback;
6806 6806
6807 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); 6807 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
6855 MockRead(kAlternateProtocolHttpHeader), 6855 MockRead(kAlternateProtocolHttpHeader),
6856 MockRead("hello world"), 6856 MockRead("hello world"),
6857 MockRead(true, OK), 6857 MockRead(true, OK),
6858 }; 6858 };
6859 6859
6860 StaticSocketDataProvider first_transaction( 6860 StaticSocketDataProvider first_transaction(
6861 data_reads, arraysize(data_reads), NULL, 0); 6861 data_reads, arraysize(data_reads), NULL, 0);
6862 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. 6862 // Socket 1 is the HTTP transaction with the Alternate-Protocol header.
6863 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); 6863 session_deps.socket_factory.AddSocketDataProvider(&first_transaction);
6864 6864
6865 MockConnect never_finishing_connect(false, ERR_IO_PENDING); 6865 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
6866 StaticSocketDataProvider hanging_socket( 6866 StaticSocketDataProvider hanging_socket(
6867 NULL, 0, NULL, 0); 6867 NULL, 0, NULL, 0);
6868 hanging_socket.set_connect_data(never_finishing_connect); 6868 hanging_socket.set_connect_data(never_finishing_connect);
6869 // Socket 2 and 3 are the hanging Alternate-Protocol and 6869 // Socket 2 and 3 are the hanging Alternate-Protocol and
6870 // non-Alternate-Protocol jobs from the 2nd transaction. 6870 // non-Alternate-Protocol jobs from the 2nd transaction.
6871 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); 6871 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket);
6872 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); 6872 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket);
6873 6873
6874 SSLSocketDataProvider ssl(true, OK); 6874 SSLSocketDataProvider ssl(true, OK);
6875 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; 6875 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
6980 data_reads, arraysize(data_reads), NULL, 0); 6980 data_reads, arraysize(data_reads), NULL, 0);
6981 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); 6981 session_deps.socket_factory.AddSocketDataProvider(&first_transaction);
6982 6982
6983 SSLSocketDataProvider ssl(true, OK); 6983 SSLSocketDataProvider ssl(true, OK);
6984 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; 6984 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated;
6985 ssl.next_proto = "spdy/2.1"; 6985 ssl.next_proto = "spdy/2.1";
6986 ssl.was_npn_negotiated = true; 6986 ssl.was_npn_negotiated = true;
6987 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; 6987 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21;
6988 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); 6988 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
6989 6989
6990 MockConnect never_finishing_connect(false, ERR_IO_PENDING); 6990 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
6991 StaticSocketDataProvider hanging_alternate_protocol_socket( 6991 StaticSocketDataProvider hanging_alternate_protocol_socket(
6992 NULL, 0, NULL, 0); 6992 NULL, 0, NULL, 0);
6993 hanging_alternate_protocol_socket.set_connect_data( 6993 hanging_alternate_protocol_socket.set_connect_data(
6994 never_finishing_connect); 6994 never_finishing_connect);
6995 session_deps.socket_factory.AddSocketDataProvider( 6995 session_deps.socket_factory.AddSocketDataProvider(
6996 &hanging_alternate_protocol_socket); 6996 &hanging_alternate_protocol_socket);
6997 6997
6998 // 2nd request is just a copy of the first one, over HTTP again. 6998 // 2nd request is just a copy of the first one, over HTTP again.
6999 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); 6999 session_deps.socket_factory.AddSocketDataProvider(&first_transaction);
7000 7000
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
7140 CreateMockRead(*data.get(), 4), // 5 7140 CreateMockRead(*data.get(), 4), // 5
7141 MockRead(true, 0, 0, 4), // 6 7141 MockRead(true, 0, 0, 4), // 6
7142 }; 7142 };
7143 7143
7144 scoped_ptr<OrderedSocketData> spdy_data( 7144 scoped_ptr<OrderedSocketData> spdy_data(
7145 new OrderedSocketData( 7145 new OrderedSocketData(
7146 spdy_reads, arraysize(spdy_reads), 7146 spdy_reads, arraysize(spdy_reads),
7147 spdy_writes, arraysize(spdy_writes))); 7147 spdy_writes, arraysize(spdy_writes)));
7148 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); 7148 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get());
7149 7149
7150 MockConnect never_finishing_connect(false, ERR_IO_PENDING); 7150 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
7151 StaticSocketDataProvider hanging_non_alternate_protocol_socket( 7151 StaticSocketDataProvider hanging_non_alternate_protocol_socket(
7152 NULL, 0, NULL, 0); 7152 NULL, 0, NULL, 0);
7153 hanging_non_alternate_protocol_socket.set_connect_data( 7153 hanging_non_alternate_protocol_socket.set_connect_data(
7154 never_finishing_connect); 7154 never_finishing_connect);
7155 session_deps.socket_factory.AddSocketDataProvider( 7155 session_deps.socket_factory.AddSocketDataProvider(
7156 &hanging_non_alternate_protocol_socket); 7156 &hanging_non_alternate_protocol_socket);
7157 7157
7158 TestCompletionCallback callback; 7158 TestCompletionCallback callback;
7159 7159
7160 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); 7160 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
7964 SSLSocketDataProvider ssl_socket_data_provider2(false, OK); 7964 SSLSocketDataProvider ssl_socket_data_provider2(false, OK);
7965 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1); 7965 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1);
7966 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2); 7966 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2);
7967 session_deps.socket_factory.AddSSLSocketDataProvider( 7967 session_deps.socket_factory.AddSSLSocketDataProvider(
7968 &ssl_socket_data_provider1); 7968 &ssl_socket_data_provider1);
7969 session_deps.socket_factory.AddSSLSocketDataProvider( 7969 session_deps.socket_factory.AddSSLSocketDataProvider(
7970 &ssl_socket_data_provider2); 7970 &ssl_socket_data_provider2);
7971 7971
7972 // Work around http://crbug.com/37454 7972 // Work around http://crbug.com/37454
7973 StaticSocketDataProvider bug37454_connection; 7973 StaticSocketDataProvider bug37454_connection;
7974 bug37454_connection.set_connect_data(MockConnect(true, ERR_UNEXPECTED)); 7974 bug37454_connection.set_connect_data(MockConnect(ASYNC, ERR_UNEXPECTED));
7975 session_deps.socket_factory.AddSocketDataProvider(&bug37454_connection); 7975 session_deps.socket_factory.AddSocketDataProvider(&bug37454_connection);
7976 7976
7977 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); 7977 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
7978 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 7978 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
7979 TestCompletionCallback callback; 7979 TestCompletionCallback callback;
7980 7980
7981 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 7981 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
7982 EXPECT_EQ(ERR_IO_PENDING, rv); 7982 EXPECT_EQ(ERR_IO_PENDING, rv);
7983 EXPECT_EQ(OK, callback.WaitForResult()); 7983 EXPECT_EQ(OK, callback.WaitForResult());
7984 7984
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
8242 scoped_ptr<OrderedSocketData> data_2( 8242 scoped_ptr<OrderedSocketData> data_2(
8243 new OrderedSocketData(data_reads_2, arraysize(data_reads_2), 8243 new OrderedSocketData(data_reads_2, arraysize(data_reads_2),
8244 data_writes_2, arraysize(data_writes_2))); 8244 data_writes_2, arraysize(data_writes_2)));
8245 8245
8246 SSLSocketDataProvider ssl(true, OK); 8246 SSLSocketDataProvider ssl(true, OK);
8247 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; 8247 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated;
8248 ssl.next_proto = "spdy/2.1"; 8248 ssl.next_proto = "spdy/2.1";
8249 ssl.was_npn_negotiated = true; 8249 ssl.was_npn_negotiated = true;
8250 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; 8250 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21;
8251 8251
8252 MockConnect never_finishing_connect(false, ERR_IO_PENDING); 8252 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
8253 StaticSocketDataProvider hanging_non_alternate_protocol_socket( 8253 StaticSocketDataProvider hanging_non_alternate_protocol_socket(
8254 NULL, 0, NULL, 0); 8254 NULL, 0, NULL, 0);
8255 hanging_non_alternate_protocol_socket.set_connect_data( 8255 hanging_non_alternate_protocol_socket.set_connect_data(
8256 never_finishing_connect); 8256 never_finishing_connect);
8257 8257
8258 session_deps.socket_factory.AddSocketDataProvider(&data_1); 8258 session_deps.socket_factory.AddSocketDataProvider(&data_1);
8259 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); 8259 session_deps.socket_factory.AddSocketDataProvider(data_2.get());
8260 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); 8260 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
8261 session_deps.socket_factory.AddSocketDataProvider( 8261 session_deps.socket_factory.AddSocketDataProvider(
8262 &hanging_non_alternate_protocol_socket); 8262 &hanging_non_alternate_protocol_socket);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
8297 } 8297 }
8298 8298
8299 // Test that if we cancel the transaction as the connection is completing, that 8299 // Test that if we cancel the transaction as the connection is completing, that
8300 // everything tears down correctly. 8300 // everything tears down correctly.
8301 TEST_F(HttpNetworkTransactionTest, SimpleCancel) { 8301 TEST_F(HttpNetworkTransactionTest, SimpleCancel) {
8302 // Setup everything about the connection to complete synchronously, so that 8302 // Setup everything about the connection to complete synchronously, so that
8303 // after calling HttpNetworkTransaction::Start, the only thing we're waiting 8303 // after calling HttpNetworkTransaction::Start, the only thing we're waiting
8304 // for is the callback from the HttpStreamRequest. 8304 // for is the callback from the HttpStreamRequest.
8305 // Then cancel the transaction. 8305 // Then cancel the transaction.
8306 // Verify that we don't crash. 8306 // Verify that we don't crash.
8307 MockConnect mock_connect(false, OK); 8307 MockConnect mock_connect(SYNCHRONOUS, OK);
8308 MockRead data_reads[] = { 8308 MockRead data_reads[] = {
8309 MockRead(false, "HTTP/1.0 200 OK\r\n\r\n"), 8309 MockRead(false, "HTTP/1.0 200 OK\r\n\r\n"),
8310 MockRead(false, "hello world"), 8310 MockRead(false, "hello world"),
8311 MockRead(false, OK), 8311 MockRead(false, OK),
8312 }; 8312 };
8313 8313
8314 HttpRequestInfo request; 8314 HttpRequestInfo request;
8315 request.method = "GET"; 8315 request.method = "GET";
8316 request.url = GURL("http://www.google.com/"); 8316 request.url = GURL("http://www.google.com/");
8317 request.load_flags = 0; 8317 request.load_flags = 0;
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
9250 StaticSocketDataProvider* data[] = { &data1, &data2 }; 9250 StaticSocketDataProvider* data[] = { &data1, &data2 };
9251 9251
9252 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); 9252 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data));
9253 9253
9254 EXPECT_EQ(OK, out.rv); 9254 EXPECT_EQ(OK, out.rv);
9255 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); 9255 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line);
9256 EXPECT_EQ("hello world", out.response_data); 9256 EXPECT_EQ("hello world", out.response_data);
9257 } 9257 }
9258 9258
9259 } // namespace net 9259 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698