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

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 3033012: Fixed memory leak in SpdyHttpStreamTest. Removed suppressions. (Closed)
Patch Set: merge with trunk Created 10 years, 5 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
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/base/net_log_unittest.h"
6 #include "net/http/http_transaction_unittest.h"
7 #include "net/spdy/spdy_http_stream.h"
5 #include "net/spdy/spdy_network_transaction.h" 8 #include "net/spdy/spdy_network_transaction.h"
6
7 #include "base/basictypes.h"
8 #include "base/ref_counted.h"
9 #include "base/string_util.h"
10 #include "net/base/completion_callback.h"
11 #include "net/base/mock_host_resolver.h"
12 #include "net/base/net_log_unittest.h"
13 #include "net/base/request_priority.h"
14 #include "net/base/ssl_config_service_defaults.h"
15 #include "net/base/test_completion_callback.h"
16 #include "net/base/upload_data.h"
17 #include "net/http/http_auth_handler_factory.h"
18 #include "net/http/http_network_session.h"
19 #include "net/http/http_transaction_unittest.h"
20 #include "net/proxy/proxy_config_service_fixed.h"
21 #include "net/socket/socket_test_util.h"
22 #include "net/spdy/spdy_framer.h"
23 #include "net/spdy/spdy_http_stream.h"
24 #include "net/spdy/spdy_protocol.h"
25 #include "net/spdy/spdy_test_util.h" 9 #include "net/spdy/spdy_test_util.h"
26 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
27 11
28 //----------------------------------------------------------------------------- 12 //-----------------------------------------------------------------------------
29 13
30 namespace net { 14 namespace net {
31 15
32 class SpdyNetworkTransactionTest : public PlatformTest { 16 class SpdyNetworkTransactionTest : public PlatformTest {
33 protected: 17 protected:
34 virtual void SetUp() { 18 virtual void SetUp() {
(...skipping 20 matching lines...) Expand all
55 HttpResponseInfo response_info; 39 HttpResponseInfo response_info;
56 }; 40 };
57 41
58 void EnableCompression(bool enabled) { 42 void EnableCompression(bool enabled) {
59 spdy::SpdyFramer::set_enable_compression_default(enabled); 43 spdy::SpdyFramer::set_enable_compression_default(enabled);
60 } 44 }
61 45
62 class StartTransactionCallback; 46 class StartTransactionCallback;
63 class DeleteSessionCallback; 47 class DeleteSessionCallback;
64 48
65 // Helper to manage the lifetimes of the dependencies for a
66 // HttpNetworkTransaction.
67 class SessionDependencies {
68 public:
69 // Default set of dependencies -- "null" proxy service.
70 SessionDependencies()
71 : host_resolver(new MockHostResolver),
72 proxy_service(ProxyService::CreateNull()),
73 ssl_config_service(new SSLConfigServiceDefaults),
74 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
75 spdy_session_pool(new SpdySessionPool()) {
76 // Note: The CancelledTransaction test does cleanup by running all
77 // tasks in the message loop (RunAllPending). Unfortunately, that
78 // doesn't clean up tasks on the host resolver thread; and
79 // TCPConnectJob is currently not cancellable. Using synchronous
80 // lookups allows the test to shutdown cleanly. Until we have
81 // cancellable TCPConnectJobs, use synchronous lookups.
82 host_resolver->set_synchronous_mode(true);
83 }
84
85 // Custom proxy service dependency.
86 explicit SessionDependencies(ProxyService* proxy_service)
87 : host_resolver(new MockHostResolver),
88 proxy_service(proxy_service),
89 ssl_config_service(new SSLConfigServiceDefaults),
90 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
91 spdy_session_pool(new SpdySessionPool()) {}
92
93 scoped_refptr<MockHostResolverBase> host_resolver;
94 scoped_refptr<ProxyService> proxy_service;
95 scoped_refptr<SSLConfigService> ssl_config_service;
96 MockClientSocketFactory socket_factory;
97 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
98 scoped_refptr<SpdySessionPool> spdy_session_pool;
99 };
100
101 static HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
102 return new HttpNetworkSession(session_deps->host_resolver,
103 session_deps->proxy_service,
104 &session_deps->socket_factory,
105 session_deps->ssl_config_service,
106 session_deps->spdy_session_pool,
107 session_deps->http_auth_handler_factory.get(),
108 NULL,
109 NULL);
110 }
111
112 // A helper class that handles all the initial npn/ssl setup. 49 // A helper class that handles all the initial npn/ssl setup.
113 class NormalSpdyTransactionHelper { 50 class NormalSpdyTransactionHelper {
114 public: 51 public:
115 NormalSpdyTransactionHelper(const HttpRequestInfo& request, 52 NormalSpdyTransactionHelper(const HttpRequestInfo& request,
116 const BoundNetLog& log) 53 const BoundNetLog& log)
117 : request_(request), session_(CreateSession(&session_deps_)), 54 : request_(request),
55 session_(SpdySessionDependencies::SpdyCreateSession(&session_deps_)),
118 log_(log), add_data_allowed_(true) {} 56 log_(log), add_data_allowed_(true) {}
119 57
120 void RunPreTestSetup() { 58 void RunPreTestSetup() {
121 // Disallow future calls to AddData 59 // Disallow future calls to AddData
122 add_data_allowed_ = false; 60 add_data_allowed_ = false;
123 61
124 // Set up http data. 62 // Set up http data.
125 MockRead data_reads[] = { 63 MockRead data_reads[] = {
126 MockRead("HTTP/1.1 200 OK\r\n"), 64 MockRead("HTTP/1.1 200 OK\r\n"),
127 MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"), 65 MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 HttpNetworkTransaction* trans() { return trans_.get(); } 196 HttpNetworkTransaction* trans() { return trans_.get(); }
259 void ResetTrans() { trans_.reset(); } 197 void ResetTrans() { trans_.reset(); }
260 TransactionHelperResult& output() { return output_; } 198 TransactionHelperResult& output() { return output_; }
261 HttpRequestInfo& request() { return request_; } 199 HttpRequestInfo& request() { return request_; }
262 scoped_refptr<HttpNetworkSession>& session() { return session_; } 200 scoped_refptr<HttpNetworkSession>& session() { return session_; }
263 201
264 private: 202 private:
265 typedef std::vector<StaticSocketDataProvider*> DataVector; 203 typedef std::vector<StaticSocketDataProvider*> DataVector;
266 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector; 204 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector;
267 HttpRequestInfo request_; 205 HttpRequestInfo request_;
268 SessionDependencies session_deps_; 206 SpdySessionDependencies session_deps_;
269 scoped_refptr<HttpNetworkSession> session_; 207 scoped_refptr<HttpNetworkSession> session_;
270 TransactionHelperResult output_; 208 TransactionHelperResult output_;
271 scoped_ptr<StaticSocketDataProvider> first_transaction_; 209 scoped_ptr<StaticSocketDataProvider> first_transaction_;
272 SSLVector ssl_vector_; 210 SSLVector ssl_vector_;
273 TestCompletionCallback callback; 211 TestCompletionCallback callback;
274 scoped_ptr<HttpNetworkTransaction> trans_; 212 scoped_ptr<HttpNetworkTransaction> trans_;
275 scoped_ptr<HttpNetworkTransaction> trans_http_; 213 scoped_ptr<HttpNetworkTransaction> trans_http_;
276 DataVector data_vector_; 214 DataVector data_vector_;
277 const BoundNetLog& log_; 215 const BoundNetLog& log_;
278 bool add_data_allowed_; 216 bool add_data_allowed_;
(...skipping 16 matching lines...) Expand all
295 233
296 private: 234 private:
297 bool google_get_request_initialized_; 235 bool google_get_request_initialized_;
298 HttpRequestInfo google_get_request_; 236 HttpRequestInfo google_get_request_;
299 }; 237 };
300 238
301 //----------------------------------------------------------------------------- 239 //-----------------------------------------------------------------------------
302 240
303 // Verify HttpNetworkTransaction constructor. 241 // Verify HttpNetworkTransaction constructor.
304 TEST_F(SpdyNetworkTransactionTest, Constructor) { 242 TEST_F(SpdyNetworkTransactionTest, Constructor) {
305 SessionDependencies session_deps; 243 SpdySessionDependencies session_deps;
306 scoped_refptr<HttpNetworkSession> session = 244 scoped_refptr<HttpNetworkSession> session =
307 CreateSession(&session_deps); 245 SpdySessionDependencies::SpdyCreateSession(&session_deps);
308 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 246 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
309 } 247 }
310 248
311 TEST_F(SpdyNetworkTransactionTest, Get) { 249 TEST_F(SpdyNetworkTransactionTest, Get) {
312 // Construct the request. 250 // Construct the request.
313 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 251 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
314 MockWrite writes[] = { CreateMockWrite(*req) }; 252 MockWrite writes[] = { CreateMockWrite(*req) };
315 253
316 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 254 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
317 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 255 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 MockRead(true, 0, 0), // EOF 316 MockRead(true, 0, 0), // EOF
379 }; 317 };
380 318
381 scoped_refptr<OrderedSocketData> data( 319 scoped_refptr<OrderedSocketData> data(
382 new OrderedSocketData(reads, arraysize(reads), 320 new OrderedSocketData(reads, arraysize(reads),
383 writes, arraysize(writes))); 321 writes, arraysize(writes)));
384 322
385 BoundNetLog log; 323 BoundNetLog log;
386 TransactionHelperResult out; 324 TransactionHelperResult out;
387 { 325 {
388 SessionDependencies session_deps; 326 SpdySessionDependencies session_deps;
389 HttpNetworkSession* session = CreateSession(&session_deps); 327 HttpNetworkSession* session =
328 SpdySessionDependencies::SpdyCreateSession(&session_deps);
390 SpdySession::SetSSLMode(false); 329 SpdySession::SetSSLMode(false);
391 scoped_ptr<SpdyNetworkTransaction> trans1( 330 scoped_ptr<SpdyNetworkTransaction> trans1(
392 new SpdyNetworkTransaction(session)); 331 new SpdyNetworkTransaction(session));
393 scoped_ptr<SpdyNetworkTransaction> trans2( 332 scoped_ptr<SpdyNetworkTransaction> trans2(
394 new SpdyNetworkTransaction(session)); 333 new SpdyNetworkTransaction(session));
395 scoped_ptr<SpdyNetworkTransaction> trans3( 334 scoped_ptr<SpdyNetworkTransaction> trans3(
396 new SpdyNetworkTransaction(session)); 335 new SpdyNetworkTransaction(session));
397 336
398 session_deps.socket_factory.AddSocketDataProvider(data); 337 session_deps.socket_factory.AddSocketDataProvider(data);
399 338
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 MockRead(true, 0, 0), // EOF 426 MockRead(true, 0, 0), // EOF
488 }; 427 };
489 428
490 scoped_refptr<OrderedSocketData> data( 429 scoped_refptr<OrderedSocketData> data(
491 new OrderedSocketData(reads, arraysize(reads), 430 new OrderedSocketData(reads, arraysize(reads),
492 writes, arraysize(writes))); 431 writes, arraysize(writes)));
493 432
494 BoundNetLog log; 433 BoundNetLog log;
495 TransactionHelperResult out; 434 TransactionHelperResult out;
496 { 435 {
497 SessionDependencies session_deps; 436 SpdySessionDependencies session_deps;
498 HttpNetworkSession* session = CreateSession(&session_deps); 437 HttpNetworkSession* session =
438 SpdySessionDependencies::SpdyCreateSession(&session_deps);
499 SpdySession::SetSSLMode(false); 439 SpdySession::SetSSLMode(false);
500 scoped_ptr<SpdyNetworkTransaction> trans1( 440 scoped_ptr<SpdyNetworkTransaction> trans1(
501 new SpdyNetworkTransaction(session)); 441 new SpdyNetworkTransaction(session));
502 scoped_ptr<SpdyNetworkTransaction> trans2( 442 scoped_ptr<SpdyNetworkTransaction> trans2(
503 new SpdyNetworkTransaction(session)); 443 new SpdyNetworkTransaction(session));
504 scoped_ptr<SpdyNetworkTransaction> trans3( 444 scoped_ptr<SpdyNetworkTransaction> trans3(
505 new SpdyNetworkTransaction(session)); 445 new SpdyNetworkTransaction(session));
506 446
507 session_deps.socket_factory.AddSocketDataProvider(data); 447 session_deps.socket_factory.AddSocketDataProvider(data);
508 448
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 MockRead(true, 0, 0), // EOF 561 MockRead(true, 0, 0), // EOF
622 }; 562 };
623 563
624 scoped_refptr<OrderedSocketData> data( 564 scoped_refptr<OrderedSocketData> data(
625 new OrderedSocketData(reads, arraysize(reads), 565 new OrderedSocketData(reads, arraysize(reads),
626 writes, arraysize(writes))); 566 writes, arraysize(writes)));
627 567
628 BoundNetLog log; 568 BoundNetLog log;
629 TransactionHelperResult out; 569 TransactionHelperResult out;
630 { 570 {
631 SessionDependencies session_deps; 571 SpdySessionDependencies session_deps;
632 HttpNetworkSession* session = CreateSession(&session_deps); 572 HttpNetworkSession* session =
573 SpdySessionDependencies::SpdyCreateSession(&session_deps);
633 SpdySession::SetSSLMode(false); 574 SpdySession::SetSSLMode(false);
634 scoped_ptr<SpdyNetworkTransaction> trans1( 575 scoped_ptr<SpdyNetworkTransaction> trans1(
635 new SpdyNetworkTransaction(session)); 576 new SpdyNetworkTransaction(session));
636 scoped_ptr<SpdyNetworkTransaction> trans2( 577 scoped_ptr<SpdyNetworkTransaction> trans2(
637 new SpdyNetworkTransaction(session)); 578 new SpdyNetworkTransaction(session));
638 scoped_ptr<SpdyNetworkTransaction> trans3( 579 scoped_ptr<SpdyNetworkTransaction> trans3(
639 new SpdyNetworkTransaction(session)); 580 new SpdyNetworkTransaction(session));
640 scoped_ptr<SpdyNetworkTransaction> trans4( 581 scoped_ptr<SpdyNetworkTransaction> trans4(
641 new SpdyNetworkTransaction(session)); 582 new SpdyNetworkTransaction(session));
642 583
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 MockRead(true, 0, 0), // EOF 702 MockRead(true, 0, 0), // EOF
762 }; 703 };
763 704
764 scoped_refptr<OrderedSocketData> data( 705 scoped_refptr<OrderedSocketData> data(
765 new OrderedSocketData(reads, arraysize(reads), 706 new OrderedSocketData(reads, arraysize(reads),
766 writes, arraysize(writes))); 707 writes, arraysize(writes)));
767 708
768 BoundNetLog log; 709 BoundNetLog log;
769 TransactionHelperResult out; 710 TransactionHelperResult out;
770 { 711 {
771 SessionDependencies session_deps; 712 SpdySessionDependencies session_deps;
772 HttpNetworkSession* session = CreateSession(&session_deps); 713 HttpNetworkSession* session =
714 SpdySessionDependencies::SpdyCreateSession(&session_deps);
773 SpdySession::SetSSLMode(false); 715 SpdySession::SetSSLMode(false);
774 scoped_ptr<SpdyNetworkTransaction> trans1( 716 scoped_ptr<SpdyNetworkTransaction> trans1(
775 new SpdyNetworkTransaction(session)); 717 new SpdyNetworkTransaction(session));
776 scoped_ptr<SpdyNetworkTransaction> trans2( 718 scoped_ptr<SpdyNetworkTransaction> trans2(
777 new SpdyNetworkTransaction(session)); 719 new SpdyNetworkTransaction(session));
778 scoped_ptr<SpdyNetworkTransaction> trans3( 720 scoped_ptr<SpdyNetworkTransaction> trans3(
779 new SpdyNetworkTransaction(session)); 721 new SpdyNetworkTransaction(session));
780 722
781 session_deps.socket_factory.AddSocketDataProvider(data); 723 session_deps.socket_factory.AddSocketDataProvider(data);
782 724
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 EXPECT_TRUE(response->was_fetched_via_spdy); 935 EXPECT_TRUE(response->was_fetched_via_spdy);
994 std::string response_data; 936 std::string response_data;
995 rv = ReadTransaction(trans, &response_data); 937 rv = ReadTransaction(trans, &response_data);
996 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); 938 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv);
997 939
998 helper.VerifyDataConsumed(); 940 helper.VerifyDataConsumed();
999 } 941 }
1000 942
1001 // Test that WINDOW_UPDATE frames change window_size correctly. 943 // Test that WINDOW_UPDATE frames change window_size correctly.
1002 TEST_F(SpdyNetworkTransactionTest, WindowUpdate) { 944 TEST_F(SpdyNetworkTransactionTest, WindowUpdate) {
1003 SessionDependencies session_deps; 945 SpdySessionDependencies session_deps;
1004 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 946 scoped_refptr<HttpNetworkSession> session =
947 SpdySessionDependencies::SpdyCreateSession(&session_deps);
1005 948
1006 // We disable SSL for this test. 949 // We disable SSL for this test.
1007 SpdySession::SetSSLMode(false); 950 SpdySession::SetSSLMode(false);
1008 951
1009 // Setup the request 952 // Setup the request
1010 static const char upload[] = { "hello!" }; 953 static const char upload[] = { "hello!" };
1011 HttpRequestInfo request; 954 HttpRequestInfo request;
1012 request.method = "POST"; 955 request.method = "POST";
1013 request.url = GURL("http://www.google.com/"); 956 request.url = GURL("http://www.google.com/");
1014 request.upload_data = new UploadData(); 957 request.upload_data = new UploadData();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 ASSERT_TRUE(trans->stream_ != NULL); 998 ASSERT_TRUE(trans->stream_ != NULL);
1056 ASSERT_TRUE(trans->stream_->stream() != NULL); 999 ASSERT_TRUE(trans->stream_->stream() != NULL);
1057 EXPECT_EQ(spdy::kInitialWindowSize + kDeltaWindowSize, 1000 EXPECT_EQ(spdy::kInitialWindowSize + kDeltaWindowSize,
1058 trans->stream_->stream()->window_size()); 1001 trans->stream_->stream()->window_size());
1059 EXPECT_TRUE(data->at_read_eof()); 1002 EXPECT_TRUE(data->at_read_eof());
1060 EXPECT_TRUE(data->at_write_eof()); 1003 EXPECT_TRUE(data->at_write_eof());
1061 } 1004 }
1062 1005
1063 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. 1006 // Test that WINDOW_UPDATE frame causing overflow is handled correctly.
1064 TEST_F(SpdyNetworkTransactionTest, WindowUpdateOverflow) { 1007 TEST_F(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
1065 SessionDependencies session_deps; 1008 SpdySessionDependencies session_deps;
1066 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 1009 scoped_refptr<HttpNetworkSession> session =
1010 SpdySessionDependencies::SpdyCreateSession(&session_deps);
1067 1011
1068 // We disable SSL for this test. 1012 // We disable SSL for this test.
1069 SpdySession::SetSSLMode(false); 1013 SpdySession::SetSSLMode(false);
1070 1014
1071 // Setup the request 1015 // Setup the request
1072 static const char upload[] = { "hello!" }; 1016 static const char upload[] = { "hello!" };
1073 HttpRequestInfo request; 1017 HttpRequestInfo request;
1074 request.method = "POST"; 1018 request.method = "POST";
1075 request.url = GURL("http://www.google.com/"); 1019 request.url = GURL("http://www.google.com/");
1076 request.upload_data = new UploadData(); 1020 request.upload_data = new UploadData();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 BoundNetLog()); 1093 BoundNetLog());
1150 helper.AddData(&data); 1094 helper.AddData(&data);
1151 helper.RunPreTestSetup(); 1095 helper.RunPreTestSetup();
1152 HttpNetworkTransaction* trans = helper.trans(); 1096 HttpNetworkTransaction* trans = helper.trans();
1153 1097
1154 TestCompletionCallback callback; 1098 TestCompletionCallback callback;
1155 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 1099 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
1156 EXPECT_EQ(ERR_IO_PENDING, rv); 1100 EXPECT_EQ(ERR_IO_PENDING, rv);
1157 helper.ResetTrans(); // Cancel the transaction. 1101 helper.ResetTrans(); // Cancel the transaction.
1158 1102
1159 // Flush the MessageLoop while the SessionDependencies (in particular, the 1103 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
1160 // MockClientSocketFactory) are still alive. 1104 // MockClientSocketFactory) are still alive.
1161 MessageLoop::current()->RunAllPending(); 1105 MessageLoop::current()->RunAllPending();
1162 helper.VerifyDataNotConsumed(); 1106 helper.VerifyDataNotConsumed();
1163 } 1107 }
1164 1108
1165 class SpdyNetworkTransactionTest::StartTransactionCallback 1109 class SpdyNetworkTransactionTest::StartTransactionCallback
1166 : public CallbackRunner< Tuple1<int> > { 1110 : public CallbackRunner< Tuple1<int> > {
1167 public: 1111 public:
1168 explicit StartTransactionCallback( 1112 explicit StartTransactionCallback(
1169 scoped_refptr<HttpNetworkSession>& session, 1113 scoped_refptr<HttpNetworkSession>& session,
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1827 }
1884 if (rv > 0) { 1828 if (rv > 0) {
1885 content.append(buf->data(), rv); 1829 content.append(buf->data(), rv);
1886 } else if (rv < 0) { 1830 } else if (rv < 0) {
1887 NOTREACHED(); 1831 NOTREACHED();
1888 } 1832 }
1889 } while (rv > 0); 1833 } while (rv > 0);
1890 1834
1891 out.response_data.swap(content); 1835 out.response_data.swap(content);
1892 1836
1893 // Flush the MessageLoop while the SessionDependencies (in particular, the 1837 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
1894 // MockClientSocketFactory) are still alive. 1838 // MockClientSocketFactory) are still alive.
1895 MessageLoop::current()->RunAllPending(); 1839 MessageLoop::current()->RunAllPending();
1896 1840
1897 // Verify that we consumed all test data. 1841 // Verify that we consumed all test data.
1898 helper.VerifyDataConsumed(); 1842 helper.VerifyDataConsumed();
1899 1843
1900 EXPECT_EQ(OK, out.rv); 1844 EXPECT_EQ(OK, out.rv);
1901 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1845 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1902 EXPECT_EQ("goodbye world", out.response_data); 1846 EXPECT_EQ("goodbye world", out.response_data);
1903 } 1847 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 } else if (rv < 0) { 1991 } else if (rv < 0) {
2048 FAIL() << "Unexpected read error: " << rv; 1992 FAIL() << "Unexpected read error: " << rv;
2049 } 1993 }
2050 reads_completed++; 1994 reads_completed++;
2051 } while (rv > 0); 1995 } while (rv > 0);
2052 1996
2053 EXPECT_EQ(3, reads_completed); // Reads are: 14 bytes, 14 bytes, 0 bytes. 1997 EXPECT_EQ(3, reads_completed); // Reads are: 14 bytes, 14 bytes, 0 bytes.
2054 1998
2055 out.response_data.swap(content); 1999 out.response_data.swap(content);
2056 2000
2057 // Flush the MessageLoop while the SessionDependencies (in particular, the 2001 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
2058 // MockClientSocketFactory) are still alive. 2002 // MockClientSocketFactory) are still alive.
2059 MessageLoop::current()->RunAllPending(); 2003 MessageLoop::current()->RunAllPending();
2060 2004
2061 // Verify that we consumed all test data. 2005 // Verify that we consumed all test data.
2062 helper.VerifyDataConsumed(); 2006 helper.VerifyDataConsumed();
2063 2007
2064 EXPECT_EQ(OK, out.rv); 2008 EXPECT_EQ(OK, out.rv);
2065 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 2009 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
2066 EXPECT_EQ("messagemessagemessagemessage", out.response_data); 2010 EXPECT_EQ("messagemessagemessagemessage", out.response_data);
2067 } 2011 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 } else if (rv < 0) { 2082 } else if (rv < 0) {
2139 FAIL() << "Unexpected read error: " << rv; 2083 FAIL() << "Unexpected read error: " << rv;
2140 } 2084 }
2141 reads_completed++; 2085 reads_completed++;
2142 } while (rv > 0); 2086 } while (rv > 0);
2143 2087
2144 EXPECT_EQ(3, reads_completed); 2088 EXPECT_EQ(3, reads_completed);
2145 2089
2146 out.response_data.swap(content); 2090 out.response_data.swap(content);
2147 2091
2148 // Flush the MessageLoop while the SessionDependencies (in particular, the 2092 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
2149 // MockClientSocketFactory) are still alive. 2093 // MockClientSocketFactory) are still alive.
2150 MessageLoop::current()->RunAllPending(); 2094 MessageLoop::current()->RunAllPending();
2151 2095
2152 // Verify that we consumed all test data. 2096 // Verify that we consumed all test data.
2153 helper.VerifyDataConsumed(); 2097 helper.VerifyDataConsumed();
2154 2098
2155 EXPECT_EQ(OK, out.rv); 2099 EXPECT_EQ(OK, out.rv);
2156 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 2100 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
2157 EXPECT_EQ("messagemessagemessagemessage", out.response_data); 2101 EXPECT_EQ("messagemessagemessagemessage", out.response_data);
2158 } 2102 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); 2176 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv);
2233 break; 2177 break;
2234 } 2178 }
2235 reads_completed++; 2179 reads_completed++;
2236 } while (rv > 0); 2180 } while (rv > 0);
2237 2181
2238 EXPECT_EQ(0, reads_completed); 2182 EXPECT_EQ(0, reads_completed);
2239 2183
2240 out.response_data.swap(content); 2184 out.response_data.swap(content);
2241 2185
2242 // Flush the MessageLoop while the SessionDependencies (in particular, the 2186 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
2243 // MockClientSocketFactory) are still alive. 2187 // MockClientSocketFactory) are still alive.
2244 MessageLoop::current()->RunAllPending(); 2188 MessageLoop::current()->RunAllPending();
2245 2189
2246 // Verify that we consumed all test data. 2190 // Verify that we consumed all test data.
2247 helper.VerifyDataConsumed(); 2191 helper.VerifyDataConsumed();
2248 } 2192 }
2249 2193
2250 // Verify the case where we buffer data and cancel the transaction. 2194 // Verify the case where we buffer data and cancel the transaction.
2251 TEST_F(SpdyNetworkTransactionTest, BufferedCancelled) { 2195 TEST_F(SpdyNetworkTransactionTest, BufferedCancelled) {
2252 spdy::SpdyFramer framer; 2196 spdy::SpdyFramer framer;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 EXPECT_TRUE(response->headers != NULL); 2525 EXPECT_TRUE(response->headers != NULL);
2582 EXPECT_TRUE(response->was_fetched_via_spdy); 2526 EXPECT_TRUE(response->was_fetched_via_spdy);
2583 out.rv = ReadTransaction(trans, &out.response_data); 2527 out.rv = ReadTransaction(trans, &out.response_data);
2584 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); 2528 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv);
2585 2529
2586 // Verify that we consumed all test data. 2530 // Verify that we consumed all test data.
2587 helper.VerifyDataConsumed(); 2531 helper.VerifyDataConsumed();
2588 } 2532 }
2589 2533
2590 } // namespace net 2534 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698