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

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

Issue 1124563003: Revert some other possible suspects of a 0.43% size increase of setup.exe: https://build.chromium.o… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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) 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void FinishDefaultTestWithoutVerification() { 261 void FinishDefaultTestWithoutVerification() {
262 output_.rv = callback_.WaitForResult(); 262 output_.rv = callback_.WaitForResult();
263 if (output_.rv != OK) 263 if (output_.rv != OK)
264 session_->spdy_session_pool()->CloseCurrentSessions(ERR_ABORTED); 264 session_->spdy_session_pool()->CloseCurrentSessions(ERR_ABORTED);
265 } 265 }
266 266
267 // Most tests will want to call this function. In particular, the MockReads 267 // Most tests will want to call this function. In particular, the MockReads
268 // should end with an empty read, and that read needs to be processed to 268 // should end with an empty read, and that read needs to be processed to
269 // ensure proper deletion of the spdy_session_pool. 269 // ensure proper deletion of the spdy_session_pool.
270 void VerifyDataConsumed() { 270 void VerifyDataConsumed() {
271 for (const SocketDataProvider* provider : data_vector_) { 271 for (DataVector::iterator it = data_vector_.begin();
272 EXPECT_TRUE(provider->AllReadDataConsumed()); 272 it != data_vector_.end(); ++it) {
273 EXPECT_TRUE(provider->AllWriteDataConsumed()); 273 EXPECT_TRUE((*it)->at_read_eof()) << "Read count: "
274 << (*it)->read_count()
275 << " Read index: "
276 << (*it)->read_index();
277 EXPECT_TRUE((*it)->at_write_eof()) << "Write count: "
278 << (*it)->write_count()
279 << " Write index: "
280 << (*it)->write_index();
274 } 281 }
275 } 282 }
276 283
277 // Occasionally a test will expect to error out before certain reads are 284 // Occasionally a test will expect to error out before certain reads are
278 // processed. In that case we want to explicitly ensure that the reads were 285 // processed. In that case we want to explicitly ensure that the reads were
279 // not processed. 286 // not processed.
280 void VerifyDataNotConsumed() { 287 void VerifyDataNotConsumed() {
281 for (const SocketDataProvider* provider : data_vector_) { 288 for (DataVector::iterator it = data_vector_.begin();
282 EXPECT_FALSE(provider->AllReadDataConsumed()); 289 it != data_vector_.end(); ++it) {
283 EXPECT_FALSE(provider->AllWriteDataConsumed()); 290 EXPECT_TRUE(!(*it)->at_read_eof()) << "Read count: "
291 << (*it)->read_count()
292 << " Read index: "
293 << (*it)->read_index();
294 EXPECT_TRUE(!(*it)->at_write_eof()) << "Write count: "
295 << (*it)->write_count()
296 << " Write index: "
297 << (*it)->write_index();
284 } 298 }
285 } 299 }
286 300
287 void RunToCompletion(SocketDataProvider* data) { 301 void RunToCompletion(SocketDataProvider* data) {
288 RunPreTestSetup(); 302 RunPreTestSetup();
289 AddData(data); 303 AddData(data);
290 RunDefaultTest(); 304 RunDefaultTest();
291 VerifyDataConsumed(); 305 VerifyDataConsumed();
292 } 306 }
293 307
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // the results into a single string. 634 // the results into a single string.
621 635
622 // Read the server push body. 636 // Read the server push body.
623 std::string result2; 637 std::string result2;
624 ReadResult(trans2.get(), data, &result2); 638 ReadResult(trans2.get(), data, &result2);
625 // Read the response body. 639 // Read the response body.
626 std::string result; 640 std::string result;
627 ReadResult(trans, data, &result); 641 ReadResult(trans, data, &result);
628 642
629 // Verify that we consumed all test data. 643 // Verify that we consumed all test data.
630 EXPECT_TRUE(data->AllReadDataConsumed()); 644 EXPECT_TRUE(data->at_read_eof());
631 EXPECT_TRUE(data->AllWriteDataConsumed()); 645 EXPECT_TRUE(data->at_write_eof());
632 646
633 // Verify that the received push data is same as the expected push data. 647 // Verify that the received push data is same as the expected push data.
634 EXPECT_EQ(result2.compare(expected), 0) << "Received data: " 648 EXPECT_EQ(result2.compare(expected), 0) << "Received data: "
635 << result2 649 << result2
636 << "||||| Expected data: " 650 << "||||| Expected data: "
637 << expected; 651 << expected;
638 652
639 // Verify the SYN_REPLY. 653 // Verify the SYN_REPLY.
640 // Copy the response info, because trans goes away. 654 // Copy the response info, because trans goes away.
641 *response = *trans->GetResponseInfo(); 655 *response = *trans->GetResponseInfo();
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 EXPECT_EQ(1, d.received_redirect_count()); 2448 EXPECT_EQ(1, d.received_redirect_count());
2435 2449
2436 r->FollowDeferredRedirect(); 2450 r->FollowDeferredRedirect();
2437 base::RunLoop().Run(); 2451 base::RunLoop().Run();
2438 EXPECT_EQ(1, d.response_started_count()); 2452 EXPECT_EQ(1, d.response_started_count());
2439 EXPECT_FALSE(d.received_data_before_response()); 2453 EXPECT_FALSE(d.received_data_before_response());
2440 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status()); 2454 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status());
2441 std::string contents("hello!"); 2455 std::string contents("hello!");
2442 EXPECT_EQ(contents, d.data_received()); 2456 EXPECT_EQ(contents, d.data_received());
2443 } 2457 }
2444 EXPECT_TRUE(data.AllReadDataConsumed()); 2458 EXPECT_TRUE(data.at_read_eof());
2445 EXPECT_TRUE(data.AllWriteDataConsumed()); 2459 EXPECT_TRUE(data.at_write_eof());
2446 EXPECT_TRUE(data2.AllReadDataConsumed()); 2460 EXPECT_TRUE(data2.at_read_eof());
2447 EXPECT_TRUE(data2.AllWriteDataConsumed()); 2461 EXPECT_TRUE(data2.at_write_eof());
2448 } 2462 }
2449 2463
2450 // Send a spdy request to www.example.org. Get a pushed stream that redirects to 2464 // Send a spdy request to www.example.org. Get a pushed stream that redirects to
2451 // www.foo.com. 2465 // www.foo.com.
2452 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { 2466 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) {
2453 scoped_ptr<SpdyHeaderBlock> headers( 2467 scoped_ptr<SpdyHeaderBlock> headers(
2454 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); 2468 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl()));
2455 (*headers)["user-agent"] = ""; 2469 (*headers)["user-agent"] = "";
2456 (*headers)["accept-encoding"] = "gzip, deflate"; 2470 (*headers)["accept-encoding"] = "gzip, deflate";
2457 2471
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 EXPECT_EQ(1, d2.received_redirect_count()); 2540 EXPECT_EQ(1, d2.received_redirect_count());
2527 2541
2528 r2->FollowDeferredRedirect(); 2542 r2->FollowDeferredRedirect();
2529 base::RunLoop().Run(); 2543 base::RunLoop().Run();
2530 EXPECT_EQ(1, d2.response_started_count()); 2544 EXPECT_EQ(1, d2.response_started_count());
2531 EXPECT_FALSE(d2.received_data_before_response()); 2545 EXPECT_FALSE(d2.received_data_before_response());
2532 EXPECT_EQ(URLRequestStatus::SUCCESS, r2->status().status()); 2546 EXPECT_EQ(URLRequestStatus::SUCCESS, r2->status().status());
2533 std::string contents2("hello!"); 2547 std::string contents2("hello!");
2534 EXPECT_EQ(contents2, d2.data_received()); 2548 EXPECT_EQ(contents2, d2.data_received());
2535 } 2549 }
2536 EXPECT_TRUE(data.AllReadDataConsumed()); 2550 data.CompleteRead();
2537 EXPECT_TRUE(data.AllWriteDataConsumed()); 2551 data2.CompleteRead();
2538 EXPECT_TRUE(data2.AllReadDataConsumed()); 2552 EXPECT_TRUE(data.at_read_eof());
2539 EXPECT_TRUE(data2.AllWriteDataConsumed()); 2553 EXPECT_TRUE(data.at_write_eof());
2554 EXPECT_TRUE(data2.at_read_eof());
2555 EXPECT_TRUE(data2.at_write_eof());
2540 } 2556 }
2541 2557
2542 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { 2558 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) {
2543 scoped_ptr<SpdyFrame> stream1_syn( 2559 scoped_ptr<SpdyFrame> stream1_syn(
2544 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 2560 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
2545 scoped_ptr<SpdyFrame> stream1_body( 2561 scoped_ptr<SpdyFrame> stream1_body(
2546 spdy_util_.ConstructSpdyBodyFrame(1, true)); 2562 spdy_util_.ConstructSpdyBodyFrame(1, true));
2547 MockWrite writes[] = { 2563 MockWrite writes[] = {
2548 CreateMockWrite(*stream1_syn, 0), 2564 CreateMockWrite(*stream1_syn, 0),
2549 }; 2565 };
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 2718
2703 // Start the transaction with basic parameters. 2719 // Start the transaction with basic parameters.
2704 TestCompletionCallback callback; 2720 TestCompletionCallback callback;
2705 int rv = trans->Start( 2721 int rv = trans->Start(
2706 &CreateGetRequest(), callback.callback(), BoundNetLog()); 2722 &CreateGetRequest(), callback.callback(), BoundNetLog());
2707 EXPECT_EQ(ERR_IO_PENDING, rv); 2723 EXPECT_EQ(ERR_IO_PENDING, rv);
2708 rv = callback.WaitForResult(); 2724 rv = callback.WaitForResult();
2709 EXPECT_EQ(OK, rv); 2725 EXPECT_EQ(OK, rv);
2710 2726
2711 // Verify that we consumed all test data. 2727 // Verify that we consumed all test data.
2712 EXPECT_TRUE(data.AllReadDataConsumed()); 2728 EXPECT_TRUE(data.at_read_eof()) << "Read count: "
2713 EXPECT_TRUE(data.AllWriteDataConsumed()); 2729 << data.read_count()
2730 << " Read index: "
2731 << data.read_index();
2732 EXPECT_TRUE(data.at_write_eof()) << "Write count: "
2733 << data.write_count()
2734 << " Write index: "
2735 << data.write_index();
2714 2736
2715 // Verify the SYN_REPLY. 2737 // Verify the SYN_REPLY.
2716 HttpResponseInfo response = *trans->GetResponseInfo(); 2738 HttpResponseInfo response = *trans->GetResponseInfo();
2717 EXPECT_TRUE(response.headers.get() != NULL); 2739 EXPECT_TRUE(response.headers.get() != NULL);
2718 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 2740 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
2719 } 2741 }
2720 2742
2721 // Verify that we don't leak streams and that we properly send a reset 2743 // Verify that we don't leak streams and that we properly send a reset
2722 // if the server pushes the same stream twice. 2744 // if the server pushes the same stream twice.
2723 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { 2745 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 2936
2915 // Start the transaction with basic parameters. 2937 // Start the transaction with basic parameters.
2916 TestCompletionCallback callback; 2938 TestCompletionCallback callback;
2917 int rv = trans->Start( 2939 int rv = trans->Start(
2918 &CreateGetRequest(), callback.callback(), BoundNetLog()); 2940 &CreateGetRequest(), callback.callback(), BoundNetLog());
2919 EXPECT_EQ(ERR_IO_PENDING, rv); 2941 EXPECT_EQ(ERR_IO_PENDING, rv);
2920 rv = callback.WaitForResult(); 2942 rv = callback.WaitForResult();
2921 EXPECT_EQ(OK, rv); 2943 EXPECT_EQ(OK, rv);
2922 2944
2923 // Verify that we consumed all test data. 2945 // Verify that we consumed all test data.
2924 EXPECT_TRUE(data.AllReadDataConsumed()); 2946 EXPECT_TRUE(data.at_read_eof()) << "Read count: "
2925 EXPECT_TRUE(data.AllWriteDataConsumed()); 2947 << data.read_count()
2948 << " Read index: "
2949 << data.read_index();
2950 EXPECT_TRUE(data.at_write_eof()) << "Write count: "
2951 << data.write_count()
2952 << " Write index: "
2953 << data.write_index();
2926 2954
2927 // Verify the SYN_REPLY. 2955 // Verify the SYN_REPLY.
2928 HttpResponseInfo response = *trans->GetResponseInfo(); 2956 HttpResponseInfo response = *trans->GetResponseInfo();
2929 EXPECT_TRUE(response.headers.get() != NULL); 2957 EXPECT_TRUE(response.headers.get() != NULL);
2930 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 2958 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
2931 } 2959 }
2932 2960
2933 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { 2961 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
2934 scoped_ptr<SpdyFrame> stream1_syn( 2962 scoped_ptr<SpdyFrame> stream1_syn(
2935 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 2963 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
(...skipping 27 matching lines...) Expand all
2963 2991
2964 // Start the transaction with basic parameters. 2992 // Start the transaction with basic parameters.
2965 TestCompletionCallback callback; 2993 TestCompletionCallback callback;
2966 int rv = trans->Start( 2994 int rv = trans->Start(
2967 &CreateGetRequest(), callback.callback(), BoundNetLog()); 2995 &CreateGetRequest(), callback.callback(), BoundNetLog());
2968 EXPECT_EQ(ERR_IO_PENDING, rv); 2996 EXPECT_EQ(ERR_IO_PENDING, rv);
2969 rv = callback.WaitForResult(); 2997 rv = callback.WaitForResult();
2970 EXPECT_EQ(OK, rv); 2998 EXPECT_EQ(OK, rv);
2971 2999
2972 // Verify that we consumed all test data. 3000 // Verify that we consumed all test data.
2973 EXPECT_TRUE(data.AllReadDataConsumed()); 3001 EXPECT_TRUE(data.at_read_eof()) << "Read count: "
2974 EXPECT_TRUE(data.AllWriteDataConsumed()); 3002 << data.read_count()
3003 << " Read index: "
3004 << data.read_index();
3005 EXPECT_TRUE(data.at_write_eof()) << "Write count: "
3006 << data.write_count()
3007 << " Write index: "
3008 << data.write_index();
2975 3009
2976 // Verify the SYN_REPLY. 3010 // Verify the SYN_REPLY.
2977 HttpResponseInfo response = *trans->GetResponseInfo(); 3011 HttpResponseInfo response = *trans->GetResponseInfo();
2978 EXPECT_TRUE(response.headers.get() != NULL); 3012 EXPECT_TRUE(response.headers.get() != NULL);
2979 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3013 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
2980 } 3014 }
2981 3015
2982 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { 3016 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
2983 scoped_ptr<SpdyFrame> stream1_syn( 3017 scoped_ptr<SpdyFrame> stream1_syn(
2984 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 3018 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 3050
3017 // Start the transaction with basic parameters. 3051 // Start the transaction with basic parameters.
3018 TestCompletionCallback callback; 3052 TestCompletionCallback callback;
3019 int rv = trans->Start( 3053 int rv = trans->Start(
3020 &CreateGetRequest(), callback.callback(), BoundNetLog()); 3054 &CreateGetRequest(), callback.callback(), BoundNetLog());
3021 EXPECT_EQ(ERR_IO_PENDING, rv); 3055 EXPECT_EQ(ERR_IO_PENDING, rv);
3022 rv = callback.WaitForResult(); 3056 rv = callback.WaitForResult();
3023 EXPECT_EQ(OK, rv); 3057 EXPECT_EQ(OK, rv);
3024 3058
3025 // Verify that we consumed all test data. 3059 // Verify that we consumed all test data.
3026 EXPECT_TRUE(data.AllReadDataConsumed()); 3060 EXPECT_TRUE(data.at_read_eof()) << "Read count: "
3027 EXPECT_TRUE(data.AllWriteDataConsumed()); 3061 << data.read_count()
3062 << " Read index: "
3063 << data.read_index();
3064 EXPECT_TRUE(data.at_write_eof()) << "Write count: "
3065 << data.write_count()
3066 << " Write index: "
3067 << data.write_index();
3028 3068
3029 // Verify the SYN_REPLY. 3069 // Verify the SYN_REPLY.
3030 HttpResponseInfo response = *trans->GetResponseInfo(); 3070 HttpResponseInfo response = *trans->GetResponseInfo();
3031 EXPECT_TRUE(response.headers.get() != NULL); 3071 EXPECT_TRUE(response.headers.get() != NULL);
3032 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3072 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3033 } 3073 }
3034 3074
3035 // Verify that various SynReply headers parse correctly through the 3075 // Verify that various SynReply headers parse correctly through the
3036 // HTTP layer. 3076 // HTTP layer.
3037 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { 3077 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
3482 writes, arraysize(writes)); 3522 writes, arraysize(writes));
3483 3523
3484 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, 3524 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
3485 BoundNetLog(), GetParam(), NULL); 3525 BoundNetLog(), GetParam(), NULL);
3486 helper.SetDeterministic(); 3526 helper.SetDeterministic();
3487 helper.RunPreTestSetup(); 3527 helper.RunPreTestSetup();
3488 helper.AddDeterministicData(&data); 3528 helper.AddDeterministicData(&data);
3489 EXPECT_TRUE(helper.StartDefaultTest()); 3529 EXPECT_TRUE(helper.StartDefaultTest());
3490 data.RunFor(2); 3530 data.RunFor(2);
3491 helper.FinishDefaultTest(); 3531 helper.FinishDefaultTest();
3492 EXPECT_TRUE(data.AllWriteDataConsumed()); 3532 EXPECT_TRUE(data.at_write_eof());
3493 EXPECT_TRUE(!data.AllReadDataConsumed()); 3533 EXPECT_TRUE(!data.at_read_eof());
3494 TransactionHelperResult out = helper.output(); 3534 TransactionHelperResult out = helper.output();
3495 EXPECT_EQ(ERR_FAILED, out.rv); 3535 EXPECT_EQ(ERR_FAILED, out.rv);
3496 } 3536 }
3497 3537
3498 // Test that partial writes work. 3538 // Test that partial writes work.
3499 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { 3539 TEST_P(SpdyNetworkTransactionTest, PartialWrite) {
3500 // Chop the SYN_STREAM frame into 5 chunks. 3540 // Chop the SYN_STREAM frame into 5 chunks.
3501 scoped_ptr<SpdyFrame> req( 3541 scoped_ptr<SpdyFrame> req(
3502 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 3542 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
3503 const int kChunks = 5; 3543 const int kChunks = 5;
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
5180 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5220 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5181 5221
5182 // Verify the pushed stream. 5222 // Verify the pushed stream.
5183 EXPECT_TRUE(response2.headers.get() != NULL); 5223 EXPECT_TRUE(response2.headers.get() != NULL);
5184 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5224 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5185 5225
5186 // Read the final EOF (which will close the session) 5226 // Read the final EOF (which will close the session)
5187 data.RunFor(1); 5227 data.RunFor(1);
5188 5228
5189 // Verify that we consumed all test data. 5229 // Verify that we consumed all test data.
5190 EXPECT_TRUE(data.AllReadDataConsumed()); 5230 EXPECT_TRUE(data.at_read_eof());
5191 EXPECT_TRUE(data.AllWriteDataConsumed()); 5231 EXPECT_TRUE(data.at_write_eof());
5192 } 5232 }
5193 5233
5194 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames 5234 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames
5195 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { 5235 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
5196 // We push a stream and attempt to claim it before the headers come down. 5236 // We push a stream and attempt to claim it before the headers come down.
5197 scoped_ptr<SpdyFrame> stream1_syn( 5237 scoped_ptr<SpdyFrame> stream1_syn(
5198 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 5238 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
5199 scoped_ptr<SpdyFrame> stream1_body( 5239 scoped_ptr<SpdyFrame> stream1_body(
5200 spdy_util_.ConstructSpdyBodyFrame(1, true)); 5240 spdy_util_.ConstructSpdyBodyFrame(1, true));
5201 MockWrite writes[] = { 5241 MockWrite writes[] = {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 // Verify we got all the headers from all header blocks. 5360 // Verify we got all the headers from all header blocks.
5321 if (spdy_util_.spdy_version() < SPDY4) 5361 if (spdy_util_.spdy_version() < SPDY4)
5322 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); 5362 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta"));
5323 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5363 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5324 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5364 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5325 5365
5326 // Read the final EOF (which will close the session) 5366 // Read the final EOF (which will close the session)
5327 data.RunFor(1); 5367 data.RunFor(1);
5328 5368
5329 // Verify that we consumed all test data. 5369 // Verify that we consumed all test data.
5330 EXPECT_TRUE(data.AllReadDataConsumed()); 5370 EXPECT_TRUE(data.at_read_eof());
5331 EXPECT_TRUE(data.AllWriteDataConsumed()); 5371 EXPECT_TRUE(data.at_write_eof());
5332 } 5372 }
5333 5373
5334 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { 5374 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) {
5335 // We push a stream and attempt to claim it before the headers come down. 5375 // We push a stream and attempt to claim it before the headers come down.
5336 scoped_ptr<SpdyFrame> stream1_syn( 5376 scoped_ptr<SpdyFrame> stream1_syn(
5337 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 5377 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
5338 scoped_ptr<SpdyFrame> stream1_body( 5378 scoped_ptr<SpdyFrame> stream1_body(
5339 spdy_util_.ConstructSpdyBodyFrame(1, true)); 5379 spdy_util_.ConstructSpdyBodyFrame(1, true));
5340 MockWrite writes[] = { 5380 MockWrite writes[] = {
5341 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), 5381 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5427 VerifyStreamsClosed(helper); 5467 VerifyStreamsClosed(helper);
5428 5468
5429 // Verify the SYN_REPLY. 5469 // Verify the SYN_REPLY.
5430 EXPECT_TRUE(response.headers.get() != NULL); 5470 EXPECT_TRUE(response.headers.get() != NULL);
5431 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5471 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5432 5472
5433 // Read the final EOF (which will close the session). 5473 // Read the final EOF (which will close the session).
5434 data.RunFor(1); 5474 data.RunFor(1);
5435 5475
5436 // Verify that we consumed all test data. 5476 // Verify that we consumed all test data.
5437 EXPECT_TRUE(data.AllReadDataConsumed()); 5477 EXPECT_TRUE(data.at_read_eof());
5438 EXPECT_TRUE(data.AllWriteDataConsumed()); 5478 EXPECT_TRUE(data.at_write_eof());
5439 } 5479 }
5440 5480
5441 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { 5481 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) {
5442 scoped_ptr<SpdyFrame> req( 5482 scoped_ptr<SpdyFrame> req(
5443 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 5483 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
5444 scoped_ptr<SpdyFrame> rst( 5484 scoped_ptr<SpdyFrame> rst(
5445 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); 5485 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
5446 MockWrite writes[] = { 5486 MockWrite writes[] = {
5447 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4), 5487 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4),
5448 }; 5488 };
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
5613 5653
5614 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5654 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5615 EXPECT_EQ(ERR_IO_PENDING, rv); 5655 EXPECT_EQ(ERR_IO_PENDING, rv);
5616 rv = callback.WaitForResult(); 5656 rv = callback.WaitForResult();
5617 5657
5618 // Read the response body. 5658 // Read the response body.
5619 std::string result; 5659 std::string result;
5620 ReadResult(trans, &data, &result); 5660 ReadResult(trans, &data, &result);
5621 5661
5622 // Verify that we consumed all test data. 5662 // Verify that we consumed all test data.
5623 EXPECT_TRUE(data.AllReadDataConsumed()); 5663 EXPECT_TRUE(data.at_read_eof());
5624 EXPECT_TRUE(data.AllWriteDataConsumed()); 5664 EXPECT_TRUE(data.at_write_eof());
5625 5665
5626 // Verify the SYN_REPLY. 5666 // Verify the SYN_REPLY.
5627 // Copy the response info, because trans goes away. 5667 // Copy the response info, because trans goes away.
5628 response = *trans->GetResponseInfo(); 5668 response = *trans->GetResponseInfo();
5629 5669
5630 VerifyStreamsClosed(helper); 5670 VerifyStreamsClosed(helper);
5631 5671
5632 // Verify the SYN_REPLY. 5672 // Verify the SYN_REPLY.
5633 EXPECT_TRUE(response.headers.get() != NULL); 5673 EXPECT_TRUE(response.headers.get() != NULL);
5634 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5674 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5667 5707
5668 // Start the transaction with basic parameters. 5708 // Start the transaction with basic parameters.
5669 TestCompletionCallback callback; 5709 TestCompletionCallback callback;
5670 int rv = trans->Start( 5710 int rv = trans->Start(
5671 &CreateGetRequest(), callback.callback(), BoundNetLog()); 5711 &CreateGetRequest(), callback.callback(), BoundNetLog());
5672 EXPECT_EQ(ERR_IO_PENDING, rv); 5712 EXPECT_EQ(ERR_IO_PENDING, rv);
5673 rv = callback.WaitForResult(); 5713 rv = callback.WaitForResult();
5674 EXPECT_EQ(OK, rv); 5714 EXPECT_EQ(OK, rv);
5675 5715
5676 // Verify that we consumed all test data. 5716 // Verify that we consumed all test data.
5677 EXPECT_TRUE(data.AllReadDataConsumed()); 5717 EXPECT_TRUE(data.at_read_eof()) << "Read count: "
5678 EXPECT_TRUE(data.AllWriteDataConsumed()); 5718 << data.read_count()
5719 << " Read index: "
5720 << data.read_index();
5721 EXPECT_TRUE(data.at_write_eof()) << "Write count: "
5722 << data.write_count()
5723 << " Write index: "
5724 << data.write_index();
5679 5725
5680 // Verify the SYN_REPLY. 5726 // Verify the SYN_REPLY.
5681 HttpResponseInfo response = *trans->GetResponseInfo(); 5727 HttpResponseInfo response = *trans->GetResponseInfo();
5682 EXPECT_TRUE(response.headers.get() != NULL); 5728 EXPECT_TRUE(response.headers.get() != NULL);
5683 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5729 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5684 } 5730 }
5685 5731
5686 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { 5732 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) {
5687 // This first request will start to establish the SpdySession. 5733 // This first request will start to establish the SpdySession.
5688 // Then we will start the second (MEDIUM priority) and then third 5734 // Then we will start the second (MEDIUM priority) and then third
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
6601 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 6647 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
6602 scoped_ptr<SSLSocketDataProvider> ssl_provider( 6648 scoped_ptr<SSLSocketDataProvider> ssl_provider(
6603 new SSLSocketDataProvider(ASYNC, OK)); 6649 new SSLSocketDataProvider(ASYNC, OK));
6604 // Set to TLS_RSA_WITH_NULL_MD5 6650 // Set to TLS_RSA_WITH_NULL_MD5
6605 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 6651 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
6606 6652
6607 RunTLSUsageCheckTest(ssl_provider.Pass()); 6653 RunTLSUsageCheckTest(ssl_provider.Pass());
6608 } 6654 }
6609 6655
6610 } // namespace net 6656 } // 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