OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11672 rv = callback.WaitForResult(); | 11672 rv = callback.WaitForResult(); |
11673 EXPECT_EQ(OK, rv); | 11673 EXPECT_EQ(OK, rv); |
11674 | 11674 |
11675 HttpRequestHeaders request_headers; | 11675 HttpRequestHeaders request_headers; |
11676 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); | 11676 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); |
11677 std::string foo; | 11677 std::string foo; |
11678 EXPECT_TRUE(request_headers.GetHeader("X-Foo", &foo)); | 11678 EXPECT_TRUE(request_headers.GetHeader("X-Foo", &foo)); |
11679 EXPECT_EQ("bar", foo); | 11679 EXPECT_EQ("bar", foo); |
11680 } | 11680 } |
11681 | 11681 |
11682 // Make sure that SetPriority actually sets the | |
11683 // HttpNetworkTransaction's priority. | |
11684 TEST_P(HttpNetworkTransactionTest, SetPriorityBasic) { | |
11685 scoped_ptr<HttpNetworkTransaction> trans( | |
11686 new HttpNetworkTransaction( | |
11687 DEFAULT_PRIORITY, CreateSession(&session_deps_))); | |
11688 EXPECT_EQ(DEFAULT_PRIORITY, trans->priority_); | |
11689 | |
11690 trans->SetPriority(LOWEST); | |
11691 EXPECT_EQ(LOWEST, trans->priority_); | |
11692 | |
11693 trans->SetPriority(LOW); | |
11694 EXPECT_EQ(LOW, trans->priority_); | |
11695 } | |
11696 | |
11697 namespace { | |
11698 | |
11699 // Fake HttpStreamRequest that simply records calls to SetPriority(). | |
11700 class FakeStreamRequest : public HttpStreamRequest { | |
11701 public: | |
11702 FakeStreamRequest() : priority_(DEFAULT_PRIORITY) {} | |
11703 virtual ~FakeStreamRequest() {} | |
11704 | |
11705 RequestPriority priority() const { return priority_; } | |
11706 | |
11707 virtual int RestartTunnelWithProxyAuth( | |
11708 const AuthCredentials& credentials) OVERRIDE { | |
11709 ADD_FAILURE(); | |
11710 return ERR_UNEXPECTED; | |
11711 } | |
11712 | |
11713 virtual LoadState GetLoadState() const OVERRIDE { | |
11714 ADD_FAILURE(); | |
11715 return LoadState(); | |
11716 } | |
11717 | |
11718 virtual void SetPriority(RequestPriority priority) OVERRIDE { | |
11719 priority_ = priority; | |
11720 } | |
11721 | |
11722 virtual bool was_npn_negotiated() const OVERRIDE { | |
11723 ADD_FAILURE(); | |
11724 return false; | |
11725 } | |
11726 | |
11727 virtual NextProto protocol_negotiated() const OVERRIDE { | |
11728 ADD_FAILURE(); | |
11729 return kProtoUnknown; | |
11730 } | |
11731 | |
11732 virtual bool using_spdy() const OVERRIDE { | |
11733 ADD_FAILURE(); | |
11734 return false; | |
11735 } | |
11736 | |
11737 private: | |
11738 RequestPriority priority_; | |
11739 }; | |
11740 | |
11741 } // namespace | |
11742 | |
11743 // Make sure that HttpNetworkTransaction passes on its priority | |
11744 // updates to its stream request. | |
11745 TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) { | |
11746 scoped_ptr<HttpNetworkTransaction> trans( | |
11747 new HttpNetworkTransaction( | |
11748 DEFAULT_PRIORITY, CreateSession(&session_deps_))); | |
11749 EXPECT_EQ(DEFAULT_PRIORITY, trans->priority_); | |
11750 | |
11751 FakeStreamRequest* request = new FakeStreamRequest(); | |
11752 trans->stream_request_.reset(request); | |
11753 | |
11754 trans->SetPriority(MEDIUM); | |
11755 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
| |
11756 } | |
11757 | |
11682 } // namespace net | 11758 } // namespace net |
OLD | NEW |