diff options
author | mlloyd@chromium.org <mlloyd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-28 21:41:38 +0000 |
---|---|---|
committer | mlloyd@chromium.org <mlloyd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-28 21:41:38 +0000 |
commit | 75f30cc2d6e90120b4ac43fcea1c38e783299f6e (patch) | |
tree | 53baa194842805393bb5ad720dcccfbf24af2e7e /net/http | |
parent | 0d03f958e30b7e6915b73f61cbe3ef79af2916dd (diff) | |
download | chromium_src-75f30cc2d6e90120b4ac43fcea1c38e783299f6e.zip chromium_src-75f30cc2d6e90120b4ac43fcea1c38e783299f6e.tar.gz chromium_src-75f30cc2d6e90120b4ac43fcea1c38e783299f6e.tar.bz2 |
Refactors SPDY frame construction methods out of
spdy_network_transaction_unittest.cc
to promote code reuse. Removes the kGetSyn and kGetSynReply binary
SPDY frame constants and replaces them with calls to factory methods,
for better clarity and to reduce maintenance costs going forward.
Also adds some helper methods for constructing mock reads and writes
from SpdyFrames.
TEST=net_unittests pass.
BUG=None
Review URL: http://codereview.chromium.org/2881001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51049 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 37d6f60..e0a679b 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -5150,14 +5150,12 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); - MockWrite spdy_writes[] = { - MockWrite(true, reinterpret_cast<const char*>(kGetSyn), - arraysize(kGetSyn)), - }; + scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0)); + MockWrite spdy_writes[] = { CreateMockWrite(req.get()) }; + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0)); MockRead spdy_reads[] = { - MockRead(true, reinterpret_cast<const char*>(kGetSynReply), - arraysize(kGetSynReply)), + CreateMockRead(resp.get()), MockRead(true, reinterpret_cast<const char*>(kGetBodyFrame), arraysize(kGetBodyFrame)), MockRead(true, 0, 0), @@ -5281,20 +5279,20 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); + scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0)); MockWrite spdy_writes[] = { MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" "Host: www.google.com\r\n" "Proxy-Connection: keep-alive\r\n\r\n"), // 0 - MockWrite(true, reinterpret_cast<const char*>(kGetSyn), - arraysize(kGetSyn)), // 3 + CreateMockWrite(req.get()) // 3 }; const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0)); MockRead spdy_reads[] = { MockRead(true, kCONNECTResponse, arraysize(kCONNECTResponse) - 1, 1), // 1 - MockRead(true, reinterpret_cast<const char*>(kGetSynReply), // 2, 4 - arraysize(kGetSynReply), 4), + CreateMockRead(resp.get(), 4), // 2, 4 MockRead(true, reinterpret_cast<const char*>(kGetBodyFrame), // 5 arraysize(kGetBodyFrame), 4), MockRead(true, 0, 0, 4), // 6 @@ -5382,14 +5380,12 @@ TEST_F(HttpNetworkTransactionTest, // Make sure we use ssl for spdy here. SpdySession::SetSSLMode(true); - MockWrite spdy_writes[] = { - MockWrite(true, reinterpret_cast<const char*>(kGetSyn), - arraysize(kGetSyn)), - }; + scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0)); + MockWrite spdy_writes[] = { CreateMockWrite(req.get()) }; + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0)); MockRead spdy_reads[] = { - MockRead(true, reinterpret_cast<const char*>(kGetSynReply), - arraysize(kGetSynReply)), + CreateMockRead(resp.get()), MockRead(true, reinterpret_cast<const char*>(kGetBodyFrame), arraysize(kGetBodyFrame)), MockRead(true, 0, 0), @@ -6123,10 +6119,8 @@ TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); - MockWrite spdy_writes[] = { - MockWrite(true, reinterpret_cast<const char*>(kGetSyn), - arraysize(kGetSyn)), - }; + scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0)); + MockWrite spdy_writes[] = { CreateMockWrite(req.get()) }; MockRead spdy_reads[] = { MockRead(false, 0, 0) // Not async - return 0 immediately. |