Index: net/http/http_network_transaction_unittest.cc |
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc |
index 64e0026668c38ad94ba47f18adfb61ee85b9704a..a565b4ab8202d34e38c154ecce6aaa2238709015 100644 |
--- a/net/http/http_network_transaction_unittest.cc |
+++ b/net/http/http_network_transaction_unittest.cc |
@@ -11679,4 +11679,80 @@ TEST_P(HttpNetworkTransactionTest, GetFullRequestHeadersIncludesExtraHeader) { |
EXPECT_EQ("bar", foo); |
} |
+// Make sure that SetPriority actually sets the |
+// HttpNetworkTransaction's priority. |
+TEST_P(HttpNetworkTransactionTest, SetPriorityBasic) { |
+ scoped_ptr<HttpNetworkTransaction> trans( |
+ new HttpNetworkTransaction( |
+ DEFAULT_PRIORITY, CreateSession(&session_deps_))); |
+ EXPECT_EQ(DEFAULT_PRIORITY, trans->priority_); |
+ |
+ trans->SetPriority(LOWEST); |
+ EXPECT_EQ(LOWEST, trans->priority_); |
+ |
+ trans->SetPriority(LOW); |
+ EXPECT_EQ(LOW, trans->priority_); |
+} |
+ |
+namespace { |
+ |
+// Fake HttpStreamRequest that simply records calls to SetPriority(). |
+class FakeStreamRequest : public HttpStreamRequest { |
+ public: |
+ FakeStreamRequest() : priority_(DEFAULT_PRIORITY) {} |
+ virtual ~FakeStreamRequest() {} |
+ |
+ RequestPriority priority() const { return priority_; } |
+ |
+ virtual int RestartTunnelWithProxyAuth( |
+ const AuthCredentials& credentials) OVERRIDE { |
+ ADD_FAILURE(); |
+ return ERR_UNEXPECTED; |
+ } |
+ |
+ virtual LoadState GetLoadState() const OVERRIDE { |
+ ADD_FAILURE(); |
+ return LoadState(); |
+ } |
+ |
+ virtual void SetPriority(RequestPriority priority) OVERRIDE { |
+ priority_ = priority; |
+ } |
+ |
+ virtual bool was_npn_negotiated() const OVERRIDE { |
+ ADD_FAILURE(); |
+ return false; |
+ } |
+ |
+ virtual NextProto protocol_negotiated() const OVERRIDE { |
+ ADD_FAILURE(); |
+ return kProtoUnknown; |
+ } |
+ |
+ virtual bool using_spdy() const OVERRIDE { |
+ ADD_FAILURE(); |
+ return false; |
+ } |
+ |
+ private: |
+ RequestPriority priority_; |
+}; |
+ |
+} // namespace |
+ |
+// Make sure that HttpNetworkTransaction passes on its priority |
+// updates to its stream request. |
+TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) { |
+ scoped_ptr<HttpNetworkTransaction> trans( |
+ new HttpNetworkTransaction( |
+ DEFAULT_PRIORITY, CreateSession(&session_deps_))); |
+ EXPECT_EQ(DEFAULT_PRIORITY, trans->priority_); |
+ |
+ FakeStreamRequest* request = new FakeStreamRequest(); |
+ trans->stream_request_.reset(request); |
+ |
+ trans->SetPriority(MEDIUM); |
+ EXPECT_EQ(MEDIUM, request->priority()); |
mmenke
2013/07/23 18:33:33
Again, these requests that just write directly to
akalin
2013/08/09 18:53:35
Ah, I was missing HttpNetworkSessionPeer. Rewrote
|
+} |
+ |
} // namespace net |