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

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

Issue 11415219: Move a number of static variables SPDY to HttpNetworkSession::Params. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix flip_in_mem_edsm_server Created 8 years 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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 27 matching lines...) Expand all
38 SPDYNPN, 38 SPDYNPN,
39 SPDYNOSSL, 39 SPDYNOSSL,
40 SPDYSSL, 40 SPDYSSL,
41 }; 41 };
42 42
43 class SpdyNetworkTransactionSpdy2Test 43 class SpdyNetworkTransactionSpdy2Test
44 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> { 44 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> {
45 protected: 45 protected:
46 46
47 virtual void SetUp() { 47 virtual void SetUp() {
48 SpdySession::set_default_protocol(kProtoSPDY2);
49 google_get_request_initialized_ = false; 48 google_get_request_initialized_ = false;
50 google_post_request_initialized_ = false; 49 google_post_request_initialized_ = false;
51 google_chunked_post_request_initialized_ = false; 50 google_chunked_post_request_initialized_ = false;
52 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
53 } 52 }
54 53
55 virtual void TearDown() { 54 virtual void TearDown() {
56 UploadDataStream::ResetMergeChunks(); 55 UploadDataStream::ResetMergeChunks();
57 // Empty the current queue. 56 // Empty the current queue.
58 MessageLoop::current()->RunUntilIdle(); 57 MessageLoop::current()->RunUntilIdle();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 568
570 private: 569 private:
571 scoped_ptr<UploadDataStream> upload_data_stream_; 570 scoped_ptr<UploadDataStream> upload_data_stream_;
572 bool google_get_request_initialized_; 571 bool google_get_request_initialized_;
573 bool google_post_request_initialized_; 572 bool google_post_request_initialized_;
574 bool google_chunked_post_request_initialized_; 573 bool google_chunked_post_request_initialized_;
575 HttpRequestInfo google_get_request_; 574 HttpRequestInfo google_get_request_;
576 HttpRequestInfo google_post_request_; 575 HttpRequestInfo google_post_request_;
577 HttpRequestInfo google_chunked_post_request_; 576 HttpRequestInfo google_chunked_post_request_;
578 HttpRequestInfo google_get_push_request_; 577 HttpRequestInfo google_get_push_request_;
579 SpdyTestStateHelper spdy_state_;
580 base::ScopedTempDir temp_dir_; 578 base::ScopedTempDir temp_dir_;
581 }; 579 };
582 580
583 //----------------------------------------------------------------------------- 581 //-----------------------------------------------------------------------------
584 // All tests are run with three different connection types: SPDY after NPN 582 // All tests are run with three different connection types: SPDY after NPN
585 // negotiation, SPDY without SSL, and SPDY with SSL. 583 // negotiation, SPDY without SSL, and SPDY with SSL.
586 INSTANTIATE_TEST_CASE_P(Spdy, 584 INSTANTIATE_TEST_CASE_P(Spdy,
587 SpdyNetworkTransactionSpdy2Test, 585 SpdyNetworkTransactionSpdy2Test,
588 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); 586 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN));
589 587
(...skipping 2936 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 helper.RunToCompletion(&data); 3524 helper.RunToCompletion(&data);
3527 TransactionHelperResult out = helper.output(); 3525 TransactionHelperResult out = helper.output();
3528 EXPECT_EQ(OK, out.rv); 3526 EXPECT_EQ(OK, out.rv);
3529 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 3527 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
3530 EXPECT_EQ("hello!", out.response_data); 3528 EXPECT_EQ("hello!", out.response_data);
3531 } 3529 }
3532 3530
3533 // In this test, we enable compression, but get a uncompressed SynReply from 3531 // In this test, we enable compression, but get a uncompressed SynReply from
3534 // the server. Verify that teardown is all clean. 3532 // the server. Verify that teardown is all clean.
3535 TEST_P(SpdyNetworkTransactionSpdy2Test, DecompressFailureOnSynReply) { 3533 TEST_P(SpdyNetworkTransactionSpdy2Test, DecompressFailureOnSynReply) {
3536 // For this test, we turn on the normal compression.
3537 BufferedSpdyFramer::set_enable_compression_default(true);
3538
3539 scoped_ptr<SpdyFrame> compressed( 3534 scoped_ptr<SpdyFrame> compressed(
3540 ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); 3535 ConstructSpdyGet(NULL, 0, true, 1, LOWEST));
3541 scoped_ptr<SpdyFrame> rst( 3536 scoped_ptr<SpdyFrame> rst(
3542 ConstructSpdyRstStream(1, PROTOCOL_ERROR)); 3537 ConstructSpdyRstStream(1, PROTOCOL_ERROR));
3543 MockWrite writes[] = { 3538 MockWrite writes[] = {
3544 CreateMockWrite(*compressed), 3539 CreateMockWrite(*compressed),
3545 }; 3540 };
3546 3541
3547 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 3542 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
3548 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 3543 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
3549 MockRead reads[] = { 3544 MockRead reads[] = {
3550 CreateMockRead(*resp), 3545 CreateMockRead(*resp),
3551 }; 3546 };
3552 3547
3553 DelayedSocketData data(1, reads, arraysize(reads), 3548 DelayedSocketData data(1, reads, arraysize(reads),
3554 writes, arraysize(writes)); 3549 writes, arraysize(writes));
3550 SpdySessionDependencies* session_deps = new SpdySessionDependencies();
3551 session_deps->enable_compression = true;
3555 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3552 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3556 BoundNetLog(), GetParam(), NULL); 3553 BoundNetLog(), GetParam(), session_deps);
3557 helper.RunToCompletion(&data); 3554 helper.RunToCompletion(&data);
3558 TransactionHelperResult out = helper.output(); 3555 TransactionHelperResult out = helper.output();
3559 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 3556 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
3560 data.Reset(); 3557 data.Reset();
3561 } 3558 }
3562 3559
3563 // Test that the NetLog contains good data for a simple GET request. 3560 // Test that the NetLog contains good data for a simple GET request.
3564 TEST_P(SpdyNetworkTransactionSpdy2Test, NetLog) { 3561 TEST_P(SpdyNetworkTransactionSpdy2Test, NetLog) {
3565 static const char* const kExtraHeaders[] = { 3562 static const char* const kExtraHeaders[] = {
3566 "user-agent", "Chrome", 3563 "user-agent", "Chrome",
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 EXPECT_NE(header_list->end(), header_list->Find(header)) << 3639 EXPECT_NE(header_list->end(), header_list->Find(header)) <<
3643 "Header not found: " << *it; 3640 "Header not found: " << *it;
3644 } 3641 }
3645 } 3642 }
3646 3643
3647 // Since we buffer the IO from the stream to the renderer, this test verifies 3644 // Since we buffer the IO from the stream to the renderer, this test verifies
3648 // that when we read out the maximum amount of data (e.g. we received 50 bytes 3645 // that when we read out the maximum amount of data (e.g. we received 50 bytes
3649 // on the network, but issued a Read for only 5 of those bytes) that the data 3646 // on the network, but issued a Read for only 5 of those bytes) that the data
3650 // flow still works correctly. 3647 // flow still works correctly.
3651 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) { 3648 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) {
3652 BufferedSpdyFramer framer(2); 3649 BufferedSpdyFramer framer(2, false);
3653 3650
3654 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3651 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3655 MockWrite writes[] = { CreateMockWrite(*req) }; 3652 MockWrite writes[] = { CreateMockWrite(*req) };
3656 3653
3657 // 2 data frames in a single read. 3654 // 2 data frames in a single read.
3658 scoped_ptr<SpdyFrame> data_frame_1( 3655 scoped_ptr<SpdyFrame> data_frame_1(
3659 framer.CreateDataFrame(1, "goodby", 6, DATA_FLAG_NONE)); 3656 framer.CreateDataFrame(1, "goodby", 6, DATA_FLAG_NONE));
3660 scoped_ptr<SpdyFrame> data_frame_2( 3657 scoped_ptr<SpdyFrame> data_frame_2(
3661 framer.CreateDataFrame(1, "e worl", 6, DATA_FLAG_NONE)); 3658 framer.CreateDataFrame(1, "e worl", 6, DATA_FLAG_NONE));
3662 const SpdyFrame* data_frames[2] = { 3659 const SpdyFrame* data_frames[2] = {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3735 3732
3736 EXPECT_EQ(OK, out.rv); 3733 EXPECT_EQ(OK, out.rv);
3737 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 3734 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
3738 EXPECT_EQ("goodbye world", out.response_data); 3735 EXPECT_EQ("goodbye world", out.response_data);
3739 } 3736 }
3740 3737
3741 // Verify that basic buffering works; when multiple data frames arrive 3738 // Verify that basic buffering works; when multiple data frames arrive
3742 // at the same time, ensure that we don't notify a read completion for 3739 // at the same time, ensure that we don't notify a read completion for
3743 // each data frame individually. 3740 // each data frame individually.
3744 TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) { 3741 TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) {
3745 BufferedSpdyFramer framer(2); 3742 BufferedSpdyFramer framer(2, false);
3746 3743
3747 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3744 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3748 MockWrite writes[] = { CreateMockWrite(*req) }; 3745 MockWrite writes[] = { CreateMockWrite(*req) };
3749 3746
3750 // 4 data frames in a single read. 3747 // 4 data frames in a single read.
3751 scoped_ptr<SpdyFrame> data_frame( 3748 scoped_ptr<SpdyFrame> data_frame(
3752 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); 3749 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
3753 scoped_ptr<SpdyFrame> data_frame_fin( 3750 scoped_ptr<SpdyFrame> data_frame_fin(
3754 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); 3751 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN));
3755 const SpdyFrame* data_frames[4] = { 3752 const SpdyFrame* data_frames[4] = {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3829 // Verify that we consumed all test data. 3826 // Verify that we consumed all test data.
3830 helper.VerifyDataConsumed(); 3827 helper.VerifyDataConsumed();
3831 3828
3832 EXPECT_EQ(OK, out.rv); 3829 EXPECT_EQ(OK, out.rv);
3833 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 3830 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
3834 EXPECT_EQ("messagemessagemessagemessage", out.response_data); 3831 EXPECT_EQ("messagemessagemessagemessage", out.response_data);
3835 } 3832 }
3836 3833
3837 // Verify the case where we buffer data but read it after it has been buffered. 3834 // Verify the case where we buffer data but read it after it has been buffered.
3838 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { 3835 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) {
3839 BufferedSpdyFramer framer(2); 3836 BufferedSpdyFramer framer(2, false);
3840 3837
3841 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3838 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3842 MockWrite writes[] = { CreateMockWrite(*req) }; 3839 MockWrite writes[] = { CreateMockWrite(*req) };
3843 3840
3844 // 5 data frames in a single read. 3841 // 5 data frames in a single read.
3845 scoped_ptr<SpdyFrame> syn_reply( 3842 scoped_ptr<SpdyFrame> syn_reply(
3846 ConstructSpdyGetSynReply(NULL, 0, 1)); 3843 ConstructSpdyGetSynReply(NULL, 0, 1));
3847 syn_reply->set_flags(CONTROL_FLAG_NONE); // turn off FIN bit 3844 syn_reply->set_flags(CONTROL_FLAG_NONE); // turn off FIN bit
3848 scoped_ptr<SpdyFrame> data_frame( 3845 scoped_ptr<SpdyFrame> data_frame(
3849 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); 3846 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3920 // Verify that we consumed all test data. 3917 // Verify that we consumed all test data.
3921 helper.VerifyDataConsumed(); 3918 helper.VerifyDataConsumed();
3922 3919
3923 EXPECT_EQ(OK, out.rv); 3920 EXPECT_EQ(OK, out.rv);
3924 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 3921 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
3925 EXPECT_EQ("messagemessagemessagemessage", out.response_data); 3922 EXPECT_EQ("messagemessagemessagemessage", out.response_data);
3926 } 3923 }
3927 3924
3928 // Verify the case where we buffer data and close the connection. 3925 // Verify the case where we buffer data and close the connection.
3929 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedClosed) { 3926 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedClosed) {
3930 BufferedSpdyFramer framer(2); 3927 BufferedSpdyFramer framer(2, false);
3931 3928
3932 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3929 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3933 MockWrite writes[] = { CreateMockWrite(*req) }; 3930 MockWrite writes[] = { CreateMockWrite(*req) };
3934 3931
3935 // All data frames in a single read. 3932 // All data frames in a single read.
3936 // NOTE: We don't FIN the stream. 3933 // NOTE: We don't FIN the stream.
3937 scoped_ptr<SpdyFrame> data_frame( 3934 scoped_ptr<SpdyFrame> data_frame(
3938 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); 3935 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
3939 const SpdyFrame* data_frames[4] = { 3936 const SpdyFrame* data_frames[4] = {
3940 data_frame.get(), 3937 data_frame.get(),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4010 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the 4007 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
4011 // MockClientSocketFactory) are still alive. 4008 // MockClientSocketFactory) are still alive.
4012 MessageLoop::current()->RunUntilIdle(); 4009 MessageLoop::current()->RunUntilIdle();
4013 4010
4014 // Verify that we consumed all test data. 4011 // Verify that we consumed all test data.
4015 helper.VerifyDataConsumed(); 4012 helper.VerifyDataConsumed();
4016 } 4013 }
4017 4014
4018 // Verify the case where we buffer data and cancel the transaction. 4015 // Verify the case where we buffer data and cancel the transaction.
4019 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedCancelled) { 4016 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedCancelled) {
4020 BufferedSpdyFramer framer(2); 4017 BufferedSpdyFramer framer(2, false);
4021 4018
4022 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4019 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4023 MockWrite writes[] = { CreateMockWrite(*req) }; 4020 MockWrite writes[] = { CreateMockWrite(*req) };
4024 4021
4025 // NOTE: We don't FIN the stream. 4022 // NOTE: We don't FIN the stream.
4026 scoped_ptr<SpdyFrame> data_frame( 4023 scoped_ptr<SpdyFrame> data_frame(
4027 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); 4024 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
4028 4025
4029 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 4026 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
4030 MockRead reads[] = { 4027 MockRead reads[] = {
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
5769 // And now we can allow everything else to run to completion. 5766 // And now we can allow everything else to run to completion.
5770 data.SetStop(10); 5767 data.SetStop(10);
5771 data.Run(); 5768 data.Run();
5772 EXPECT_EQ(OK, callback2.WaitForResult()); 5769 EXPECT_EQ(OK, callback2.WaitForResult());
5773 EXPECT_EQ(OK, callback3.WaitForResult()); 5770 EXPECT_EQ(OK, callback3.WaitForResult());
5774 5771
5775 helper.VerifyDataConsumed(); 5772 helper.VerifyDataConsumed();
5776 } 5773 }
5777 5774
5778 } // namespace net 5775 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream_spdy3_unittest.cc ('k') | net/spdy/spdy_network_transaction_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698