diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 03:40:38 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 03:40:38 +0000 |
commit | dca629cedc3ed6b52909e6a9e4e02242a08e45c7 (patch) | |
tree | 30558ddfb3394b9d244dc44217fe3d1f3f50d211 /net | |
parent | b1c37fc29acdd561962de77b868dafe1f9a804ee (diff) | |
download | chromium_src-dca629cedc3ed6b52909e6a9e4e02242a08e45c7.zip chromium_src-dca629cedc3ed6b52909e6a9e4e02242a08e45c7.tar.gz chromium_src-dca629cedc3ed6b52909e6a9e4e02242a08e45c7.tar.bz2 |
Created a new class SpdyTestStateHelper to serve as a helper to manage the state of a number of SPDY global variables.
Review URL: http://codereview.chromium.org/9817014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
28 files changed, 105 insertions, 120 deletions
diff --git a/net/base/run_all_unittests.cc b/net/base/run_all_unittests.cc index bcadda0..c00d9d1 100644 --- a/net/base/run_all_unittests.cc +++ b/net/base/run_all_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,6 @@ int main(int argc, char** argv) { base::StatisticsRecorder recorder; NetTestSuite test_suite(argc, argv); ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - SpdySession::set_enable_ping_based_connection_checking(false); #if defined(OS_WIN) // We want to be sure to init NSPR on the main thread. diff --git a/net/http/http_network_transaction_spdy21_unittest.cc b/net/http/http_network_transaction_spdy21_unittest.cc index fed205f..78ffa15 100644 --- a/net/http/http_network_transaction_spdy21_unittest.cc +++ b/net/http/http_network_transaction_spdy21_unittest.cc @@ -177,13 +177,11 @@ class HttpNetworkTransactionSpdy21Test : public PlatformTest { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY21); NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - spdy::SpdyFramer::set_enable_compression_default(false); } virtual void TearDown() { NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - spdy::SpdyFramer::set_enable_compression_default(true); // Empty the current queue. MessageLoop::current()->RunAllPending(); PlatformTest::TearDown(); @@ -273,6 +271,9 @@ class HttpNetworkTransactionSpdy21Test : public PlatformTest { int expected_status); void ConnectStatusHelper(const MockRead& status); + + private: + SpdyTestStateHelper spdy_state_; }; namespace { diff --git a/net/http/http_network_transaction_spdy2_unittest.cc b/net/http/http_network_transaction_spdy2_unittest.cc index 49d5ae5..934a96a 100644 --- a/net/http/http_network_transaction_spdy2_unittest.cc +++ b/net/http/http_network_transaction_spdy2_unittest.cc @@ -177,13 +177,11 @@ class HttpNetworkTransactionSpdy2Test : public PlatformTest { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - spdy::SpdyFramer::set_enable_compression_default(false); } virtual void TearDown() { NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - spdy::SpdyFramer::set_enable_compression_default(true); // Empty the current queue. MessageLoop::current()->RunAllPending(); PlatformTest::TearDown(); @@ -273,6 +271,9 @@ class HttpNetworkTransactionSpdy2Test : public PlatformTest { int expected_status); void ConnectStatusHelper(const MockRead& status); + + private: + SpdyTestStateHelper spdy_state_; }; namespace { diff --git a/net/http/http_network_transaction_spdy3_unittest.cc b/net/http/http_network_transaction_spdy3_unittest.cc index 4052959..8612f4c 100644 --- a/net/http/http_network_transaction_spdy3_unittest.cc +++ b/net/http/http_network_transaction_spdy3_unittest.cc @@ -178,13 +178,11 @@ class HttpNetworkTransactionSpdy3Test : public PlatformTest { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - spdy::SpdyFramer::set_enable_compression_default(false); } virtual void TearDown() { NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - spdy::SpdyFramer::set_enable_compression_default(true); // Empty the current queue. MessageLoop::current()->RunAllPending(); PlatformTest::TearDown(); @@ -274,6 +272,9 @@ class HttpNetworkTransactionSpdy3Test : public PlatformTest { int expected_status); void ConnectStatusHelper(const MockRead& status); + + private: + SpdyTestStateHelper spdy_state_; }; namespace { diff --git a/net/http/http_proxy_client_socket_pool_spdy21_unittest.cc b/net/http/http_proxy_client_socket_pool_spdy21_unittest.cc index ba0b9e1..3ff5e14 100644 --- a/net/http/http_proxy_client_socket_pool_spdy21_unittest.cc +++ b/net/http/http_proxy_client_socket_pool_spdy21_unittest.cc @@ -175,7 +175,6 @@ class HttpProxyClientSocketPoolSpdy21Test : public TestWithHttpParam { } void InitializeSpdySsl() { - spdy::SpdyFramer::set_enable_compression_default(false); ssl_data_->SetNextProto(SSLClientSocket::kProtoSPDY21); } @@ -210,6 +209,7 @@ class HttpProxyClientSocketPoolSpdy21Test : public TestWithHttpParam { HttpServerPropertiesImpl http_server_properties_; const scoped_refptr<HttpNetworkSession> session_; ClientSocketPoolHistograms http_proxy_histograms_; + SpdyTestStateHelper spdy_state_; protected: scoped_ptr<SSLSocketDataProvider> ssl_data_; diff --git a/net/http/http_proxy_client_socket_pool_spdy2_unittest.cc b/net/http/http_proxy_client_socket_pool_spdy2_unittest.cc index 00e55b3..b564d62 100644 --- a/net/http/http_proxy_client_socket_pool_spdy2_unittest.cc +++ b/net/http/http_proxy_client_socket_pool_spdy2_unittest.cc @@ -175,7 +175,6 @@ class HttpProxyClientSocketPoolSpdy2Test : public TestWithHttpParam { } void InitializeSpdySsl() { - spdy::SpdyFramer::set_enable_compression_default(false); ssl_data_->SetNextProto(SSLClientSocket::kProtoSPDY2); } @@ -210,6 +209,7 @@ class HttpProxyClientSocketPoolSpdy2Test : public TestWithHttpParam { HttpServerPropertiesImpl http_server_properties_; const scoped_refptr<HttpNetworkSession> session_; ClientSocketPoolHistograms http_proxy_histograms_; + SpdyTestStateHelper spdy_state_; protected: scoped_ptr<SSLSocketDataProvider> ssl_data_; diff --git a/net/http/http_proxy_client_socket_pool_spdy3_unittest.cc b/net/http/http_proxy_client_socket_pool_spdy3_unittest.cc index 4aead906..82f7ab0 100644 --- a/net/http/http_proxy_client_socket_pool_spdy3_unittest.cc +++ b/net/http/http_proxy_client_socket_pool_spdy3_unittest.cc @@ -176,7 +176,6 @@ class HttpProxyClientSocketPoolSpdy3Test : public TestWithHttpParam { } void InitializeSpdySsl() { - spdy::SpdyFramer::set_enable_compression_default(false); ssl_data_->SetNextProto(SSLClientSocket::kProtoSPDY3); } @@ -211,6 +210,7 @@ class HttpProxyClientSocketPoolSpdy3Test : public TestWithHttpParam { HttpServerPropertiesImpl http_server_properties_; const scoped_refptr<HttpNetworkSession> session_; ClientSocketPoolHistograms http_proxy_histograms_; + SpdyTestStateHelper spdy_state_; protected: scoped_ptr<SSLSocketDataProvider> ssl_data_; diff --git a/net/spdy/buffered_spdy_framer_spdy2_unittest.cc b/net/spdy/buffered_spdy_framer_spdy2_unittest.cc index b001fba..f627da2 100644 --- a/net/spdy/buffered_spdy_framer_spdy2_unittest.cc +++ b/net/spdy/buffered_spdy_framer_spdy2_unittest.cc @@ -143,10 +143,6 @@ class TestBufferedSpdyVisitor : public BufferedSpdyFramerVisitorInterface { class BufferedSpdyFramerSpdy2Test : public PlatformTest { protected: - void EnableCompression(bool enabled) { - SpdyFramer::set_enable_compression_default(enabled); - } - // Returns true if the two header blocks have equivalent content. bool CompareHeaderBlocks(const SpdyHeaderBlock* expected, const SpdyHeaderBlock* actual) { @@ -173,11 +169,12 @@ class BufferedSpdyFramerSpdy2Test : public PlatformTest { } return true; } + + private: + SpdyTestStateHelper spdy_state_; }; TEST_F(BufferedSpdyFramerSpdy2Test, OnSetting) { - EnableCompression(false); - SpdyFramer framer(2); SpdySettings settings; settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); @@ -194,8 +191,6 @@ TEST_F(BufferedSpdyFramerSpdy2Test, OnSetting) { } TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynStreamHeaderBlock) { - EnableCompression(false); - SpdyHeaderBlock headers; headers["aa"] = "vv"; headers["bb"] = "ww"; @@ -221,8 +216,6 @@ TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynStreamHeaderBlock) { } TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynReplyHeaderBlock) { - EnableCompression(false); - SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; @@ -246,8 +239,6 @@ TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynReplyHeaderBlock) { } TEST_F(BufferedSpdyFramerSpdy2Test, ReadHeadersHeaderBlock) { - EnableCompression(false); - SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; diff --git a/net/spdy/buffered_spdy_framer_spdy3_unittest.cc b/net/spdy/buffered_spdy_framer_spdy3_unittest.cc index e18c688..27f8717 100644 --- a/net/spdy/buffered_spdy_framer_spdy3_unittest.cc +++ b/net/spdy/buffered_spdy_framer_spdy3_unittest.cc @@ -143,10 +143,6 @@ class TestBufferedSpdyVisitor : public BufferedSpdyFramerVisitorInterface { class BufferedSpdyFramerSpdy3Test : public PlatformTest { protected: - void EnableCompression(bool enabled) { - SpdyFramer::set_enable_compression_default(enabled); - } - // Returns true if the two header blocks have equivalent content. bool CompareHeaderBlocks(const SpdyHeaderBlock* expected, const SpdyHeaderBlock* actual) { @@ -173,11 +169,12 @@ class BufferedSpdyFramerSpdy3Test : public PlatformTest { } return true; } + + private: + SpdyTestStateHelper spdy_state_; }; TEST_F(BufferedSpdyFramerSpdy3Test, OnSetting) { - EnableCompression(false); - SpdyFramer framer(3); SpdySettings settings; settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); @@ -194,8 +191,6 @@ TEST_F(BufferedSpdyFramerSpdy3Test, OnSetting) { } TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynStreamHeaderBlock) { - EnableCompression(false); - SpdyHeaderBlock headers; headers["aa"] = "vv"; headers["bb"] = "ww"; @@ -221,8 +216,6 @@ TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynStreamHeaderBlock) { } TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynReplyHeaderBlock) { - EnableCompression(false); - SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; @@ -246,8 +239,6 @@ TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynReplyHeaderBlock) { } TEST_F(BufferedSpdyFramerSpdy3Test, ReadHeadersHeaderBlock) { - EnableCompression(false); - SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; diff --git a/net/spdy/spdy_http_stream_spdy2_unittest.cc b/net/spdy/spdy_http_stream_spdy2_unittest.cc index 1b5662a..b7704a8 100644 --- a/net/spdy/spdy_http_stream_spdy2_unittest.cc +++ b/net/spdy/spdy_http_stream_spdy2_unittest.cc @@ -25,10 +25,6 @@ class SpdyHttpStreamSpdy2Test : public testing::Test { protected: SpdyHttpStreamSpdy2Test() {} - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } - virtual void SetUp() { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); } @@ -68,11 +64,12 @@ class SpdyHttpStreamSpdy2Test : public testing::Test { scoped_refptr<HttpNetworkSession> http_session_; scoped_refptr<SpdySession> session_; scoped_refptr<TransportSocketParams> transport_params_; + + private: + SpdyTestStateHelper spdy_state_; }; TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) { - EnableCompression(false); - scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req.get(), 1), @@ -119,7 +116,6 @@ TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) { } TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) { - EnableCompression(false); UploadDataStream::set_merge_chunks(false); scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); @@ -182,8 +178,6 @@ TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) { // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 TEST_F(SpdyHttpStreamSpdy2Test, SpdyURLTest) { - EnableCompression(false); - const char * const full_url = "http://www.google.com/foo?query=what#anchor"; const char * const base_url = "http://www.google.com/foo?query=what"; scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); diff --git a/net/spdy/spdy_http_stream_spdy3_unittest.cc b/net/spdy/spdy_http_stream_spdy3_unittest.cc index 68a958c..a42050d 100644 --- a/net/spdy/spdy_http_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_http_stream_spdy3_unittest.cc @@ -25,10 +25,6 @@ class SpdyHttpStreamSpdy3Test : public testing::Test { protected: SpdyHttpStreamSpdy3Test() {} - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } - virtual void SetUp() { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); } @@ -74,11 +70,12 @@ class SpdyHttpStreamSpdy3Test : public testing::Test { scoped_refptr<HttpNetworkSession> http_session_; scoped_refptr<SpdySession> session_; scoped_refptr<TransportSocketParams> transport_params_; + + private: + SpdyTestStateHelper spdy_state_; }; TEST_F(SpdyHttpStreamSpdy3Test, SendRequest) { - EnableCompression(false); - scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req.get(), 1), @@ -125,7 +122,6 @@ TEST_F(SpdyHttpStreamSpdy3Test, SendRequest) { } TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) { - EnableCompression(false); UploadDataStream::set_merge_chunks(false); scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); @@ -188,8 +184,6 @@ TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) { // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) { - EnableCompression(false); - const char * const full_url = "http://www.google.com/foo?query=what#anchor"; const char * const base_url = "http://www.google.com/foo?query=what"; scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); @@ -297,8 +291,6 @@ void SpdyHttpStreamSpdy3Test::TestSendCredentials( const std::string& cert, const std::string& proof, SSLClientCertType type) { - EnableCompression(false); - spdy::SpdyCredential cred; cred.slot = 1; cred.proof = proof; diff --git a/net/spdy/spdy_network_transaction_spdy21_unittest.cc b/net/spdy/spdy_network_transaction_spdy21_unittest.cc index 444b203..efae94b 100644 --- a/net/spdy/spdy_network_transaction_spdy21_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy21_unittest.cc @@ -39,8 +39,6 @@ class SpdyNetworkTransactionSpdy21Test protected: virtual void SetUp() { - // By default, all tests turn off compression. - EnableCompression(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY21); google_get_request_initialized_ = false; google_post_request_initialized_ = false; @@ -59,10 +57,6 @@ class SpdyNetworkTransactionSpdy21Test HttpResponseInfo response_info; }; - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } - // A helper class that handles all the initial npn/ssl setup. class NormalSpdyTransactionHelper { public: @@ -529,6 +523,7 @@ class SpdyNetworkTransactionSpdy21Test HttpRequestInfo google_post_request_; HttpRequestInfo google_chunked_post_request_; HttpRequestInfo google_get_push_request_; + SpdyTestStateHelper spdy_state_; }; //----------------------------------------------------------------------------- @@ -1055,8 +1050,6 @@ TEST_P(SpdyNetworkTransactionSpdy21Test, ThreeGetsWithMaxConcurrent) { // user specified priority, we expect to see them inverted in // the response from the server. TEST_P(SpdyNetworkTransactionSpdy21Test, FourGetsWithMaxConcurrentPriority) { - SpdySession::set_enable_ping_based_connection_checking(false); - // Construct the request. scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); @@ -3808,7 +3801,7 @@ TEST_P(SpdyNetworkTransactionSpdy21Test, PartialWrite) { // the server. Verify that teardown is all clean. TEST_P(SpdyNetworkTransactionSpdy21Test, DecompressFailureOnSynReply) { // For this test, we turn on the normal compression. - EnableCompression(true); + spdy::SpdyFramer::set_enable_compression_default(true); scoped_ptr<spdy::SpdyFrame> compressed( ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); @@ -3833,8 +3826,6 @@ TEST_P(SpdyNetworkTransactionSpdy21Test, DecompressFailureOnSynReply) { TransactionHelperResult out = helper.output(); EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); data->Reset(); - - EnableCompression(false); } // Test that the NetLog contains good data for a simple GET request. diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc index 6ce7afe..40b0c6a 100644 --- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc @@ -39,8 +39,6 @@ class SpdyNetworkTransactionSpdy2Test protected: virtual void SetUp() { - // By default, all tests turn off compression. - EnableCompression(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); google_get_request_initialized_ = false; google_post_request_initialized_ = false; @@ -59,10 +57,6 @@ class SpdyNetworkTransactionSpdy2Test HttpResponseInfo response_info; }; - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } - // A helper class that handles all the initial npn/ssl setup. class NormalSpdyTransactionHelper { public: @@ -529,6 +523,7 @@ class SpdyNetworkTransactionSpdy2Test HttpRequestInfo google_post_request_; HttpRequestInfo google_chunked_post_request_; HttpRequestInfo google_get_push_request_; + SpdyTestStateHelper spdy_state_; }; //----------------------------------------------------------------------------- @@ -1055,8 +1050,6 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrent) { // user specified priority, we expect to see them inverted in // the response from the server. TEST_P(SpdyNetworkTransactionSpdy2Test, FourGetsWithMaxConcurrentPriority) { - SpdySession::set_enable_ping_based_connection_checking(false); - // Construct the request. scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); @@ -3444,7 +3437,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, PartialWrite) { // the server. Verify that teardown is all clean. TEST_P(SpdyNetworkTransactionSpdy2Test, DecompressFailureOnSynReply) { // For this test, we turn on the normal compression. - EnableCompression(true); + spdy::SpdyFramer::set_enable_compression_default(true); scoped_ptr<spdy::SpdyFrame> compressed( ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); @@ -3469,8 +3462,6 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, DecompressFailureOnSynReply) { TransactionHelperResult out = helper.output(); EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); data->Reset(); - - EnableCompression(false); } // Test that the NetLog contains good data for a simple GET request. diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc index 16cf9fb..6d038c6 100644 --- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc @@ -39,8 +39,6 @@ class SpdyNetworkTransactionSpdy3Test protected: virtual void SetUp() { - // By default, all tests turn off compression. - EnableCompression(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); google_get_request_initialized_ = false; google_post_request_initialized_ = false; @@ -59,10 +57,6 @@ class SpdyNetworkTransactionSpdy3Test HttpResponseInfo response_info; }; - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } - // A helper class that handles all the initial npn/ssl setup. class NormalSpdyTransactionHelper { public: @@ -530,6 +524,7 @@ class SpdyNetworkTransactionSpdy3Test HttpRequestInfo google_post_request_; HttpRequestInfo google_chunked_post_request_; HttpRequestInfo google_get_push_request_; + SpdyTestStateHelper spdy_state_; }; //----------------------------------------------------------------------------- @@ -1056,8 +1051,6 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, ThreeGetsWithMaxConcurrent) { // user specified priority, we expect to see them inverted in // the response from the server. TEST_P(SpdyNetworkTransactionSpdy3Test, FourGetsWithMaxConcurrentPriority) { - SpdySession::set_enable_ping_based_connection_checking(false); - // Construct the request. scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); @@ -3808,7 +3801,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, PartialWrite) { // the server. Verify that teardown is all clean. TEST_P(SpdyNetworkTransactionSpdy3Test, DecompressFailureOnSynReply) { // For this test, we turn on the normal compression. - EnableCompression(true); + spdy::SpdyFramer::set_enable_compression_default(true); scoped_ptr<spdy::SpdyFrame> compressed( ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); @@ -3833,8 +3826,6 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, DecompressFailureOnSynReply) { TransactionHelperResult out = helper.output(); EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); data->Reset(); - - EnableCompression(false); } // Test that the NetLog contains good data for a simple GET request. diff --git a/net/spdy/spdy_proxy_client_socket_spdy2_unittest.cc b/net/spdy/spdy_proxy_client_socket_spdy2_unittest.cc index 88c09f6..ce3adc7 100644 --- a/net/spdy/spdy_proxy_client_socket_spdy2_unittest.cc +++ b/net/spdy/spdy_proxy_client_socket_spdy2_unittest.cc @@ -128,6 +128,7 @@ class SpdyProxyClientSocketSpdy2Test : public PlatformTest { ProxyServer proxy_; HostPortProxyPair endpoint_host_port_proxy_pair_; scoped_refptr<TransportSocketParams> transport_params_; + SpdyTestStateHelper spdy_state_; DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocketSpdy2Test); }; @@ -159,7 +160,6 @@ void SpdyProxyClientSocketSpdy2Test::TearDown() { if (session_ != NULL) session_->spdy_session_pool()->CloseAllSessions(); - spdy::SpdyFramer::set_enable_compression_default(true); // Empty the current queue. MessageLoop::current()->RunAllPending(); PlatformTest::TearDown(); @@ -179,7 +179,6 @@ void SpdyProxyClientSocketSpdy2Test::Initialize(MockRead* reads, session_ = SpdySessionDependencies::SpdyCreateSessionDeterministic( &session_deps_); - spdy::SpdyFramer::set_enable_compression_default(false); // Creates a new spdy session spdy_session_ = diff --git a/net/spdy/spdy_proxy_client_socket_spdy3_unittest.cc b/net/spdy/spdy_proxy_client_socket_spdy3_unittest.cc index 35ae107..023b022 100644 --- a/net/spdy/spdy_proxy_client_socket_spdy3_unittest.cc +++ b/net/spdy/spdy_proxy_client_socket_spdy3_unittest.cc @@ -128,6 +128,7 @@ class SpdyProxyClientSocketSpdy3Test : public PlatformTest { ProxyServer proxy_; HostPortProxyPair endpoint_host_port_proxy_pair_; scoped_refptr<TransportSocketParams> transport_params_; + SpdyTestStateHelper spdy_state_; DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocketSpdy3Test); }; @@ -159,7 +160,6 @@ void SpdyProxyClientSocketSpdy3Test::TearDown() { if (session_ != NULL) session_->spdy_session_pool()->CloseAllSessions(); - spdy::SpdyFramer::set_enable_compression_default(true); // Empty the current queue. MessageLoop::current()->RunAllPending(); PlatformTest::TearDown(); @@ -179,7 +179,6 @@ void SpdyProxyClientSocketSpdy3Test::Initialize(MockRead* reads, session_ = SpdySessionDependencies::SpdyCreateSessionDeterministic( &session_deps_); - spdy::SpdyFramer::set_enable_compression_default(false); // Creates a new spdy session spdy_session_ = diff --git a/net/spdy/spdy_session_spdy2_unittest.cc b/net/spdy/spdy_session_spdy2_unittest.cc index 65312bd..8d87ca7 100644 --- a/net/spdy/spdy_session_spdy2_unittest.cc +++ b/net/spdy/spdy_session_spdy2_unittest.cc @@ -20,19 +20,13 @@ namespace net { // TODO(cbentzel): Expose compression setter/getter in public SpdySession // interface rather than going through all these contortions. class SpdySessionSpdy2Test : public PlatformTest { - public: - static void TurnOffCompression() { - spdy::SpdyFramer::set_enable_compression_default(false); - } protected: virtual void SetUp() { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); } - virtual void TearDown() { - // Wanted to be 100% sure PING is disabled. - SpdySession::set_enable_ping_based_connection_checking(false); - } + private: + SpdyTestStateHelper spdy_state_; }; class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { diff --git a/net/spdy/spdy_session_spdy3_unittest.cc b/net/spdy/spdy_session_spdy3_unittest.cc index 59cc5959..8386a95 100644 --- a/net/spdy/spdy_session_spdy3_unittest.cc +++ b/net/spdy/spdy_session_spdy3_unittest.cc @@ -20,19 +20,13 @@ namespace net { // TODO(cbentzel): Expose compression setter/getter in public SpdySession // interface rather than going through all these contortions. class SpdySessionSpdy3Test : public PlatformTest { - public: - static void TurnOffCompression() { - spdy::SpdyFramer::set_enable_compression_default(false); - } protected: virtual void SetUp() { SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); } - virtual void TearDown() { - // Wanted to be 100% sure PING is disabled. - SpdySession::set_enable_ping_based_connection_checking(false); - } + private: + SpdyTestStateHelper spdy_state_; }; class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { diff --git a/net/spdy/spdy_stream_spdy2_unittest.cc b/net/spdy/spdy_stream_spdy2_unittest.cc index 9837071..b2a7a13 100644 --- a/net/spdy/spdy_stream_spdy2_unittest.cc +++ b/net/spdy/spdy_stream_spdy2_unittest.cc @@ -105,7 +105,6 @@ class SpdyStreamSpdy2Test : public testing::Test { } scoped_refptr<SpdySession> CreateSpdySession() { - spdy::SpdyFramer::set_enable_compression_default(false); HostPortPair host_port_pair("www.google.com", 80); HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); scoped_refptr<SpdySession> session( @@ -122,6 +121,9 @@ class SpdyStreamSpdy2Test : public testing::Test { } scoped_refptr<HttpNetworkSession> session_; + + private: + SpdyTestStateHelper spdy_state_; }; TEST_F(SpdyStreamSpdy2Test, SendDataAfterOpen) { diff --git a/net/spdy/spdy_stream_spdy3_unittest.cc b/net/spdy/spdy_stream_spdy3_unittest.cc index d456a43..9545284 100644 --- a/net/spdy/spdy_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_stream_spdy3_unittest.cc @@ -105,7 +105,6 @@ class SpdyStreamSpdy3Test : public testing::Test { } scoped_refptr<SpdySession> CreateSpdySession() { - spdy::SpdyFramer::set_enable_compression_default(false); HostPortPair host_port_pair("www.google.com", 80); HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); scoped_refptr<SpdySession> session( @@ -122,6 +121,9 @@ class SpdyStreamSpdy3Test : public testing::Test { } scoped_refptr<HttpNetworkSession> session_; + + private: + SpdyTestStateHelper spdy_state_; }; TEST_F(SpdyStreamSpdy3Test, SendDataAfterOpen) { diff --git a/net/spdy/spdy_test_util_spdy2.cc b/net/spdy/spdy_test_util_spdy2.cc index 9c095f4..1f82401 100644 --- a/net/spdy/spdy_test_util_spdy2.cc +++ b/net/spdy/spdy_test_util_spdy2.cc @@ -16,6 +16,7 @@ #include "net/http/http_server_properties_impl.h" #include "net/spdy/buffered_spdy_framer.h" #include "net/spdy/spdy_http_utils.h" +#include "net/spdy/spdy_session.h" namespace net { namespace test_spdy2 { @@ -1007,5 +1008,19 @@ const SpdyHeaderInfo MakeSpdyHeader(spdy::SpdyControlType type) { return kHeader; } +SpdyTestStateHelper::SpdyTestStateHelper() { + // Pings can be non-deterministic, because they are sent via timer. + SpdySession::set_enable_ping_based_connection_checking(false); + // Compression is per-session which makes it impossible to create + // SPDY frames with static methods. + spdy::SpdyFramer::set_enable_compression_default(false); +} + +SpdyTestStateHelper::~SpdyTestStateHelper() { + SpdySession::ResetStaticSettingsToInit(); + // TODO(rch): save/restore this value + spdy::SpdyFramer::set_enable_compression_default(true); +} + } // namespace test_spdy2 } // namespace net diff --git a/net/spdy/spdy_test_util_spdy2.h b/net/spdy/spdy_test_util_spdy2.h index a18a37b..7a0a59e 100644 --- a/net/spdy/spdy_test_util_spdy2.h +++ b/net/spdy/spdy_test_util_spdy2.h @@ -414,6 +414,16 @@ class SpdySessionPoolPeer { DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); }; +// Helper to manage the state of a number of SPDY global variables. +class SpdyTestStateHelper { + public: + SpdyTestStateHelper(); + ~SpdyTestStateHelper(); + + private: + DISALLOW_COPY_AND_ASSIGN(SpdyTestStateHelper); +}; + } // namespace test_spdy2 } // namespace net diff --git a/net/spdy/spdy_test_util_spdy3.cc b/net/spdy/spdy_test_util_spdy3.cc index f0d7e49..67ec3eb 100644 --- a/net/spdy/spdy_test_util_spdy3.cc +++ b/net/spdy/spdy_test_util_spdy3.cc @@ -15,6 +15,7 @@ #include "net/http/http_server_properties_impl.h" #include "net/spdy/buffered_spdy_framer.h" #include "net/spdy/spdy_http_utils.h" +#include "net/spdy/spdy_session.h" namespace net { @@ -1007,6 +1008,20 @@ const SpdyHeaderInfo MakeSpdyHeader(spdy::SpdyControlType type) { return kHeader; } +SpdyTestStateHelper::SpdyTestStateHelper() { + // Pings can be non-deterministic, because they are sent via timer. + SpdySession::set_enable_ping_based_connection_checking(false); + // Compression is per-session which makes it impossible to create + // SPDY frames with static methods. + spdy::SpdyFramer::set_enable_compression_default(false); +} + +SpdyTestStateHelper::~SpdyTestStateHelper() { + SpdySession::ResetStaticSettingsToInit(); + // TODO(rch): save/restore this value + spdy::SpdyFramer::set_enable_compression_default(true); +} + } // namespace test_spdy3 } // namespace net diff --git a/net/spdy/spdy_test_util_spdy3.h b/net/spdy/spdy_test_util_spdy3.h index 7f0d184..896617c 100644 --- a/net/spdy/spdy_test_util_spdy3.h +++ b/net/spdy/spdy_test_util_spdy3.h @@ -414,6 +414,16 @@ class SpdySessionPoolPeer { DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); }; +// Helper to manage the state of a number of SPDY global variables. +class SpdyTestStateHelper { + public: + SpdyTestStateHelper(); + ~SpdyTestStateHelper(); + + private: + DISALLOW_COPY_AND_ASSIGN(SpdyTestStateHelper); +}; + } // namespace test_spdy3 } // namespace net diff --git a/net/spdy/spdy_websocket_stream_spdy2_unittest.cc b/net/spdy/spdy_websocket_stream_spdy2_unittest.cc index 1fceb14..59d533d 100644 --- a/net/spdy/spdy_websocket_stream_spdy2_unittest.cc +++ b/net/spdy/spdy_websocket_stream_spdy2_unittest.cc @@ -189,7 +189,6 @@ class SpdyWebSocketStreamSpdy2Test : public testing::Test { virtual ~SpdyWebSocketStreamSpdy2Test() {} virtual void SetUp() { - EnableCompression(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); host_port_pair_.set_host("example.com"); @@ -213,9 +212,6 @@ class SpdyWebSocketStreamSpdy2Test : public testing::Test { MessageLoop::current()->RunAllPending(); } - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } void Prepare(spdy::SpdyStreamId stream_id) { stream_id_ = stream_id; @@ -317,6 +313,9 @@ class SpdyWebSocketStreamSpdy2Test : public testing::Test { static const char kClosingFrame[]; static const size_t kMessageFrameLength; static const size_t kClosingFrameLength; + + private: + SpdyTestStateHelper spdy_state_; }; const char SpdyWebSocketStreamSpdy2Test::kMessageFrame[] = "\0hello\xff"; diff --git a/net/spdy/spdy_websocket_stream_spdy3_unittest.cc b/net/spdy/spdy_websocket_stream_spdy3_unittest.cc index 737c9fa..d5a9f71 100644 --- a/net/spdy/spdy_websocket_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_websocket_stream_spdy3_unittest.cc @@ -189,7 +189,6 @@ class SpdyWebSocketStreamSpdy3Test : public testing::Test { virtual ~SpdyWebSocketStreamSpdy3Test() {} virtual void SetUp() { - EnableCompression(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); host_port_pair_.set_host("example.com"); @@ -213,9 +212,6 @@ class SpdyWebSocketStreamSpdy3Test : public testing::Test { MessageLoop::current()->RunAllPending(); } - void EnableCompression(bool enabled) { - spdy::SpdyFramer::set_enable_compression_default(enabled); - } void Prepare(spdy::SpdyStreamId stream_id) { stream_id_ = stream_id; @@ -317,6 +313,9 @@ class SpdyWebSocketStreamSpdy3Test : public testing::Test { static const char kClosingFrame[]; static const size_t kMessageFrameLength; static const size_t kClosingFrameLength; + + private: + SpdyTestStateHelper spdy_state_; }; const char SpdyWebSocketStreamSpdy3Test::kMessageFrame[] = "\0hello\xff"; diff --git a/net/websockets/websocket_job_spdy2_unittest.cc b/net/websockets/websocket_job_spdy2_unittest.cc index 2053fcf..da47d43 100644 --- a/net/websockets/websocket_job_spdy2_unittest.cc +++ b/net/websockets/websocket_job_spdy2_unittest.cc @@ -319,7 +319,6 @@ namespace net { class WebSocketJobSpdy2Test : public PlatformTest { public: virtual void SetUp() { - spdy::SpdyFramer::set_enable_compression_default(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); stream_type_ = STREAM_INVALID; cookie_store_ = new MockCookieStore; @@ -475,6 +474,9 @@ class WebSocketJobSpdy2Test : public PlatformTest { static const size_t kHandshakeResponseWithCookieLength; static const size_t kDataHelloLength; static const size_t kDataWorldLength; + + private: + SpdyTestStateHelper spdy_state_; }; const char WebSocketJobSpdy2Test::kHandshakeRequestWithoutCookie[] = diff --git a/net/websockets/websocket_job_spdy3_unittest.cc b/net/websockets/websocket_job_spdy3_unittest.cc index 7dd462d..7f7491c 100644 --- a/net/websockets/websocket_job_spdy3_unittest.cc +++ b/net/websockets/websocket_job_spdy3_unittest.cc @@ -319,7 +319,6 @@ namespace net { class WebSocketJobSpdy3Test : public PlatformTest { public: virtual void SetUp() { - spdy::SpdyFramer::set_enable_compression_default(false); SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); stream_type_ = STREAM_INVALID; cookie_store_ = new MockCookieStore; @@ -475,6 +474,9 @@ class WebSocketJobSpdy3Test : public PlatformTest { static const size_t kHandshakeResponseWithCookieLength; static const size_t kDataHelloLength; static const size_t kDataWorldLength; + + private: + SpdyTestStateHelper spdy_state_; }; const char WebSocketJobSpdy3Test::kHandshakeRequestWithoutCookie[] = |