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

Side by Side Diff: net/http/http_server_properties_impl_unittest.cc

Issue 188663002: Revert of HttpServerProperties - Implement MRU for AlternateProtocolMap. Persist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_server_properties_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 impl_.Clear(); 199 impl_.Clear();
200 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); 200 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
201 } 201 }
202 202
203 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { 203 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
204 HostPortPair test_host_port_pair1("foo1", 80); 204 HostPortPair test_host_port_pair1("foo1", 80);
205 impl_.SetBrokenAlternateProtocol(test_host_port_pair1); 205 impl_.SetBrokenAlternateProtocol(test_host_port_pair1);
206 HostPortPair test_host_port_pair2("foo2", 80); 206 HostPortPair test_host_port_pair2("foo2", 80);
207 impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3); 207 impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3);
208 208
209 AlternateProtocolMap alternate_protocol_map( 209 AlternateProtocolMap alternate_protocol_map;
210 AlternateProtocolMap::NO_AUTO_EVICT);
211 PortAlternateProtocolPair port_alternate_protocol_pair; 210 PortAlternateProtocolPair port_alternate_protocol_pair;
212 port_alternate_protocol_pair.port = 123; 211 port_alternate_protocol_pair.port = 123;
213 port_alternate_protocol_pair.protocol = NPN_SPDY_3; 212 port_alternate_protocol_pair.protocol = NPN_SPDY_3;
214 alternate_protocol_map.Put(test_host_port_pair2, 213 alternate_protocol_map[test_host_port_pair2] = port_alternate_protocol_pair;
215 port_alternate_protocol_pair);
216 HostPortPair test_host_port_pair3("foo3", 80);
217 port_alternate_protocol_pair.port = 1234;
218 alternate_protocol_map.Put(test_host_port_pair3,
219 port_alternate_protocol_pair);
220 impl_.InitializeAlternateProtocolServers(&alternate_protocol_map); 214 impl_.InitializeAlternateProtocolServers(&alternate_protocol_map);
221 215
222 // Verify test_host_port_pair3 is the MRU server.
223 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map();
224 net::AlternateProtocolMap::const_iterator it = map.begin();
225 it = map.begin();
226 EXPECT_TRUE(it->first.Equals(test_host_port_pair3));
227 EXPECT_EQ(1234, it->second.port);
228 EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
229
230 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1)); 216 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1));
231 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair2)); 217 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair2));
232 port_alternate_protocol_pair = 218 port_alternate_protocol_pair =
233 impl_.GetAlternateProtocol(test_host_port_pair1); 219 impl_.GetAlternateProtocol(test_host_port_pair1);
234 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, port_alternate_protocol_pair.protocol); 220 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, port_alternate_protocol_pair.protocol);
235 port_alternate_protocol_pair = 221 port_alternate_protocol_pair =
236 impl_.GetAlternateProtocol(test_host_port_pair2); 222 impl_.GetAlternateProtocol(test_host_port_pair2);
237 EXPECT_EQ(123, port_alternate_protocol_pair.port); 223 EXPECT_EQ(123, port_alternate_protocol_pair.port);
238 EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol_pair.protocol); 224 EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol_pair.protocol);
239 } 225 }
240 226
241 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) {
242 HostPortPair test_host_port_pair1("foo1", 80);
243 impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3);
244 HostPortPair test_host_port_pair2("foo2", 80);
245 impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3);
246
247 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map();
248 net::AlternateProtocolMap::const_iterator it = map.begin();
249 EXPECT_TRUE(it->first.Equals(test_host_port_pair2));
250 EXPECT_EQ(1234, it->second.port);
251 EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
252
253 // HasAlternateProtocol should reoder the AlternateProtocol map.
254 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1));
255 it = map.begin();
256 EXPECT_TRUE(it->first.Equals(test_host_port_pair1));
257 EXPECT_EQ(443, it->second.port);
258 EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
259 }
260
261 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) {
262 HostPortPair test_host_port_pair1("foo1", 80);
263 impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3);
264 HostPortPair test_host_port_pair2("foo2", 80);
265 impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3);
266
267 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map();
268 net::AlternateProtocolMap::const_iterator it = map.begin();
269 EXPECT_TRUE(it->first.Equals(test_host_port_pair2));
270 EXPECT_EQ(1234, it->second.port);
271 EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
272
273 // GetAlternateProtocol should reoder the AlternateProtocol map.
274 PortAlternateProtocolPair alternate =
275 impl_.GetAlternateProtocol(test_host_port_pair1);
276 EXPECT_EQ(443, alternate.port);
277 EXPECT_EQ(NPN_SPDY_3, alternate.protocol);
278 it = map.begin();
279 EXPECT_TRUE(it->first.Equals(test_host_port_pair1));
280 EXPECT_EQ(443, it->second.port);
281 EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
282 }
283
284 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { 227 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
285 HostPortPair test_host_port_pair("foo", 80); 228 HostPortPair test_host_port_pair("foo", 80);
286 impl_.SetBrokenAlternateProtocol(test_host_port_pair); 229 impl_.SetBrokenAlternateProtocol(test_host_port_pair);
287 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); 230 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair));
288 PortAlternateProtocolPair alternate = 231 PortAlternateProtocolPair alternate =
289 impl_.GetAlternateProtocol(test_host_port_pair); 232 impl_.GetAlternateProtocol(test_host_port_pair);
290 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); 233 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol);
291 234
292 impl_.SetAlternateProtocol( 235 impl_.SetAlternateProtocol(
293 test_host_port_pair, 236 test_host_port_pair,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 EXPECT_EQ(value3, flags_and_value3_ret.second); 429 EXPECT_EQ(value3, flags_and_value3_ret.second);
487 430
488 impl_.Clear(); 431 impl_.Clear();
489 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_google).size()); 432 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_google).size());
490 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_docs).size()); 433 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_docs).size());
491 } 434 }
492 435
493 } // namespace 436 } // namespace
494 437
495 } // namespace net 438 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698