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

Unified Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 3050016: Implement prefetching in chrome (Closed)
Patch Set: merge to 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/client_socket_pool_base_unittest.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_network_transaction_unittest.cc
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 8da5389d40bd89bb8e4e774c559dc39493ff13b5..b151012065fdcbff17a0be6476176627de8b1c92 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -289,6 +289,59 @@ TEST_P(SpdyNetworkTransactionTest, Get) {
EXPECT_EQ("hello!", out.response_data);
}
+TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) {
+ for (RequestPriority p = HIGHEST; p < NUM_PRIORITIES;
+ p = RequestPriority(p+1)) {
+ // Construct the request.
+ scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, p));
+ MockWrite writes[] = { CreateMockWrite(*req) };
+
+ const int spdy_prio = reinterpret_cast<spdy::SpdySynStreamControlFrame*>(
+ req.get())->priority();
+ // this repeats the RequestPriority-->SpdyPriority mapping from
+ // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make
+ // sure it's being done right.
+ switch(p) {
+ case HIGHEST:
+ EXPECT_EQ(0, spdy_prio);
+ break;
+ case MEDIUM:
+ EXPECT_EQ(1, spdy_prio);
+ break;
+ case LOW:
+ case LOWEST:
+ EXPECT_EQ(2, spdy_prio);
+ break;
+ case IDLE:
+ EXPECT_EQ(3, spdy_prio);
+ break;
+ default:
+ FAIL();
+ }
+
+ scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
+ MockRead reads[] = {
+ CreateMockRead(*resp),
+ CreateMockRead(*body),
+ MockRead(true, 0, 0) // EOF
+ };
+
+ scoped_refptr<DelayedSocketData> data(
+ new DelayedSocketData(1, reads, arraysize(reads),
+ writes, arraysize(writes)));
+ HttpRequestInfo http_req = CreateGetRequest();
+ http_req.priority = p;
+
+ NormalSpdyTransactionHelper helper(http_req, BoundNetLog(), GetParam());
+ helper.RunToCompletion(data.get());
+ TransactionHelperResult out = helper.output();
+ EXPECT_EQ(OK, out.rv);
+ EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
+ EXPECT_EQ("hello!", out.response_data);
+ }
+}
+
// Start three gets simultaniously; making sure that multiplexed
// streams work properly.
@@ -1413,7 +1466,8 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
spdy::SYN_REPLY, // Syn Reply
1, // Stream ID
0, // Associated Stream ID
- SPDY_PRIORITY_LOWEST, // Priority
+ net::ConvertRequestPriorityToSpdyPriority(LOWEST),
+ // Priority
spdy::CONTROL_FLAG_NONE, // Control Flags
false, // Compressed
spdy::INVALID, // Status
@@ -1581,7 +1635,8 @@ TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) {
spdy::SYN_REPLY, // Kind = SynReply
1, // Stream ID
0, // Associated stream ID
- SPDY_PRIORITY_LOWEST, // Priority
+ net::ConvertRequestPriorityToSpdyPriority(LOWEST),
+ // Priority
spdy::CONTROL_FLAG_NONE, // Control Flags
false, // Compressed
spdy::INVALID, // Status
@@ -2342,7 +2397,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) {
spdy::SYN_REPLY, // Syn Reply
1, // Stream ID
0, // Associated Stream ID
- SPDY_PRIORITY_LOWEST, // Priority
+ net::ConvertRequestPriorityToSpdyPriority(LOWEST),
+ // Priority
spdy::CONTROL_FLAG_NONE, // Control Flags
false, // Compressed
spdy::INVALID, // Status
@@ -2446,7 +2502,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
spdy::SYN_REPLY, // Syn Reply
1, // Stream ID
0, // Associated Stream ID
- SPDY_PRIORITY_LOWEST, // Priority
+ net::ConvertRequestPriorityToSpdyPriority(LOWEST),
+ // Priority
spdy::CONTROL_FLAG_NONE, // Control Flags
false, // Compressed
spdy::INVALID, // Status
« no previous file with comments | « net/socket/client_socket_pool_base_unittest.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698