OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_pipelined_host_pool.h" | 5 #include "net/http/http_pipelined_host_pool.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/base/ssl_config_service.h" | 8 #include "net/base/ssl_config_service.h" |
9 #include "net/http/http_pipelined_host.h" | 9 #include "net/http/http_pipelined_host.h" |
10 #include "net/http/http_server_properties_impl.h" | |
10 #include "net/proxy/proxy_info.h" | 11 #include "net/proxy/proxy_info.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 using testing::_; | 15 using testing::_; |
15 using testing::Ref; | 16 using testing::Ref; |
16 using testing::Return; | 17 using testing::Return; |
17 using testing::ReturnNull; | 18 using testing::ReturnNull; |
18 | 19 |
19 namespace net { | 20 namespace net { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 private: | 60 private: |
60 HostPortPair origin_; | 61 HostPortPair origin_; |
61 }; | 62 }; |
62 | 63 |
63 class HttpPipelinedHostPoolTest : public testing::Test { | 64 class HttpPipelinedHostPoolTest : public testing::Test { |
64 public: | 65 public: |
65 HttpPipelinedHostPoolTest() | 66 HttpPipelinedHostPoolTest() |
66 : origin_("host", 123), | 67 : origin_("host", 123), |
67 factory_(new MockHostFactory), // Owned by pool_. | 68 factory_(new MockHostFactory), // Owned by pool_. |
68 host_(new MockHost(origin_)), // Owned by pool_. | 69 host_(new MockHost(origin_)), // Owned by pool_. |
69 pool_(new HttpPipelinedHostPool(&delegate_, factory_)), | 70 http_server_properties_(new HttpServerPropertiesImpl), |
71 pool_(new HttpPipelinedHostPool(&delegate_, factory_, | |
72 http_server_properties_.get())), | |
70 was_npn_negotiated_(false) { | 73 was_npn_negotiated_(false) { |
71 } | 74 } |
72 | 75 |
73 void CreateDummyStream() { | 76 void CreateDummyStream() { |
74 EXPECT_CALL(*host_, CreateStreamOnNewPipeline(kDummyConnection, | 77 EXPECT_CALL(*host_, CreateStreamOnNewPipeline(kDummyConnection, |
75 Ref(ssl_config_), | 78 Ref(ssl_config_), |
76 Ref(proxy_info_), | 79 Ref(proxy_info_), |
77 Ref(net_log_), | 80 Ref(net_log_), |
78 was_npn_negotiated_)) | 81 was_npn_negotiated_)) |
79 .Times(1) | 82 .Times(1) |
80 .WillOnce(Return(kDummyStream)); | 83 .WillOnce(Return(kDummyStream)); |
81 EXPECT_EQ(kDummyStream, | 84 EXPECT_EQ(kDummyStream, |
82 pool_->CreateStreamOnNewPipeline(origin_, kDummyConnection, | 85 pool_->CreateStreamOnNewPipeline(origin_, kDummyConnection, |
83 ssl_config_, proxy_info_, | 86 ssl_config_, proxy_info_, |
84 net_log_, was_npn_negotiated_)); | 87 net_log_, was_npn_negotiated_)); |
85 } | 88 } |
86 | 89 |
87 HostPortPair origin_; | 90 HostPortPair origin_; |
88 MockPoolDelegate delegate_; | 91 MockPoolDelegate delegate_; |
89 MockHostFactory* factory_; | 92 MockHostFactory* factory_; |
90 MockHost* host_; | 93 MockHost* host_; |
94 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_; | |
mmenke
2011/12/02 21:52:10
You might want to explicitly query this in a test
James Simonsen
2011/12/03 03:16:00
Done.
| |
91 scoped_ptr<HttpPipelinedHostPool> pool_; | 95 scoped_ptr<HttpPipelinedHostPool> pool_; |
92 | 96 |
93 const SSLConfig ssl_config_; | 97 const SSLConfig ssl_config_; |
94 const ProxyInfo proxy_info_; | 98 const ProxyInfo proxy_info_; |
95 const BoundNetLog net_log_; | 99 const BoundNetLog net_log_; |
96 bool was_npn_negotiated_; | 100 bool was_npn_negotiated_; |
97 }; | 101 }; |
98 | 102 |
99 TEST_F(HttpPipelinedHostPoolTest, DefaultUnknown) { | 103 TEST_F(HttpPipelinedHostPoolTest, DefaultUnknown) { |
100 EXPECT_TRUE(pool_->IsHostEligibleForPipelining(origin_)); | 104 EXPECT_TRUE(pool_->IsHostEligibleForPipelining(origin_)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 .Times(1) | 180 .Times(1) |
177 .WillOnce(Return(host_)); | 181 .WillOnce(Return(host_)); |
178 | 182 |
179 CreateDummyStream(); | 183 CreateDummyStream(); |
180 pool_->OnHostIdle(host_); | 184 pool_->OnHostIdle(host_); |
181 } | 185 } |
182 | 186 |
183 } // anonymous namespace | 187 } // anonymous namespace |
184 | 188 |
185 } // namespace net | 189 } // namespace net |
OLD | NEW |