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

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

Issue 1043973002: Introduce AlternativeServiceInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Early return. Created 5 years, 8 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
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 265 }
266 266
267 TEST_F(AlternateProtocolServerPropertiesTest, Probability) { 267 TEST_F(AlternateProtocolServerPropertiesTest, Probability) {
268 impl_.SetAlternateProtocolProbabilityThreshold(0.25); 268 impl_.SetAlternateProtocolProbabilityThreshold(0.25);
269 269
270 HostPortPair test_host_port_pair("foo", 80); 270 HostPortPair test_host_port_pair("foo", 80);
271 const AlternativeService alternative_service(NPN_SPDY_3, "foo", 443); 271 const AlternativeService alternative_service(NPN_SPDY_3, "foo", 443);
272 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5); 272 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5);
273 EXPECT_TRUE(HasAlternativeService(test_host_port_pair)); 273 EXPECT_TRUE(HasAlternativeService(test_host_port_pair));
274 274
275 AlternateProtocolMap::const_iterator it = 275 AlternativeServiceMap::const_iterator it =
276 impl_.alternate_protocol_map().Peek(test_host_port_pair); 276 impl_.alternative_service_map().Peek(test_host_port_pair);
277 EXPECT_TRUE(it != impl_.alternate_protocol_map().end()); 277 ASSERT_TRUE(it != impl_.alternative_service_map().end());
278 EXPECT_EQ(443, it->second.port); 278 EXPECT_EQ(443, it->second.alternative_service.port);
279 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); 279 EXPECT_EQ(NPN_SPDY_3, it->second.alternative_service.protocol);
280 EXPECT_EQ(0.5, it->second.probability); 280 EXPECT_EQ(0.5, it->second.probability);
281 } 281 }
282 282
283 TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) { 283 TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) {
284 impl_.SetAlternateProtocolProbabilityThreshold(0.75); 284 impl_.SetAlternateProtocolProbabilityThreshold(0.75);
285 285
286 HostPortPair test_host_port_pair("foo", 80); 286 HostPortPair test_host_port_pair("foo", 80);
287 const AlternativeService alternative_service(NPN_SPDY_3, "foo", 443); 287 const AlternativeService alternative_service(NPN_SPDY_3, "foo", 443);
288 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5); 288 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5);
289 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); 289 EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
290 } 290 }
291 291
292 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { 292 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
293 HostPortPair test_host_port_pair1("foo1", 80); 293 HostPortPair test_host_port_pair1("foo1", 80);
294 const AlternativeService alternative_service1(NPN_SPDY_3, "foo1", 443); 294 const AlternativeService alternative_service1(NPN_SPDY_3, "foo1", 443);
295 impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0); 295 impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0);
296 impl_.MarkAlternativeServiceBroken(alternative_service1); 296 impl_.MarkAlternativeServiceBroken(alternative_service1);
297 297
298 HostPortPair test_host_port_pair2("foo2", 80); 298 HostPortPair test_host_port_pair2("foo2", 80);
299 const AlternativeService alternative_service2(NPN_SPDY_3, "foo2", 443); 299 const AlternativeService alternative_service2(NPN_SPDY_3, "foo2", 443);
300 impl_.SetAlternativeService(test_host_port_pair2, alternative_service2, 1.0); 300 impl_.SetAlternativeService(test_host_port_pair2, alternative_service2, 1.0);
301 301
302 AlternateProtocolMap alternate_protocol_map( 302 AlternativeServiceMap alternative_service_map(
303 AlternateProtocolMap::NO_AUTO_EVICT); 303 AlternativeServiceMap::NO_AUTO_EVICT);
304 AlternateProtocolInfo alternate(123, NPN_SPDY_3, 1); 304 AlternativeServiceInfo alternative_service_info(NPN_SPDY_3, "bar", 123, 1.0);
305 alternate_protocol_map.Put(test_host_port_pair2, alternate); 305 alternative_service_map.Put(test_host_port_pair2, alternative_service_info);
306 HostPortPair test_host_port_pair3("foo3", 80); 306 HostPortPair test_host_port_pair3("foo3", 80);
307 alternate.port = 1234; 307 alternative_service_info.alternative_service.port = 1234;
308 alternate_protocol_map.Put(test_host_port_pair3, alternate); 308 alternative_service_map.Put(test_host_port_pair3, alternative_service_info);
309 impl_.InitializeAlternateProtocolServers(&alternate_protocol_map); 309 impl_.InitializeAlternativeServiceServers(&alternative_service_map);
310 310
311 // Verify test_host_port_pair3 is the MRU server. 311 // Verify test_host_port_pair3 is the MRU server.
312 const AlternateProtocolMap& map = impl_.alternate_protocol_map(); 312 const AlternativeServiceMap& map = impl_.alternative_service_map();
313 AlternateProtocolMap::const_iterator it = map.begin(); 313 AlternativeServiceMap::const_iterator it = map.begin();
314 ASSERT_TRUE(it != map.end());
314 EXPECT_TRUE(it->first.Equals(test_host_port_pair3)); 315 EXPECT_TRUE(it->first.Equals(test_host_port_pair3));
315 EXPECT_EQ(1234, it->second.port); 316 EXPECT_EQ(NPN_SPDY_3, it->second.alternative_service.protocol);
316 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); 317 EXPECT_EQ(1234, it->second.alternative_service.port);
317 318
318 ASSERT_TRUE(HasAlternativeService(test_host_port_pair1)); 319 ASSERT_TRUE(HasAlternativeService(test_host_port_pair1));
319 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 320 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
320 AlternativeService alternative_service = 321 const AlternativeService alternative_service =
321 impl_.GetAlternativeService(test_host_port_pair2); 322 impl_.GetAlternativeService(test_host_port_pair2);
323 EXPECT_EQ(NPN_SPDY_3, alternative_service.protocol);
322 EXPECT_EQ(123, alternative_service.port); 324 EXPECT_EQ(123, alternative_service.port);
323 EXPECT_EQ(NPN_SPDY_3, alternative_service.protocol);
324 } 325 }
325 326
326 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) { 327 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) {
327 HostPortPair test_host_port_pair1("foo1", 80); 328 HostPortPair test_host_port_pair1("foo1", 80);
328 const AlternativeService alternative_service1(NPN_SPDY_3, "foo1", 443); 329 const AlternativeService alternative_service1(NPN_SPDY_3, "foo1", 443);
329 impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0); 330 impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0);
330 HostPortPair test_host_port_pair2("foo2", 80); 331 HostPortPair test_host_port_pair2("foo2", 80);
331 const AlternativeService alternative_service2(NPN_SPDY_3, "foo2", 1234); 332 const AlternativeService alternative_service2(NPN_SPDY_3, "foo2", 1234);
332 impl_.SetAlternativeService(test_host_port_pair2, alternative_service2, 1.0); 333 impl_.SetAlternativeService(test_host_port_pair2, alternative_service2, 1.0);
333 334
334 const AlternateProtocolMap& map = impl_.alternate_protocol_map(); 335 const AlternativeServiceMap& map = impl_.alternative_service_map();
335 AlternateProtocolMap::const_iterator it = map.begin(); 336 AlternativeServiceMap::const_iterator it = map.begin();
336 EXPECT_TRUE(it->first.Equals(test_host_port_pair2)); 337 EXPECT_TRUE(it->first.Equals(test_host_port_pair2));
337 EXPECT_EQ(1234, it->second.port); 338 EXPECT_EQ(NPN_SPDY_3, it->second.alternative_service.protocol);
338 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); 339 EXPECT_EQ(1234, it->second.alternative_service.port);
339 340
340 // GetAlternativeService should reorder the AlternateProtocol map. 341 // GetAlternativeService should reorder the AlternateProtocol map.
341 const AlternativeService alternative_service = 342 const AlternativeService alternative_service =
342 impl_.GetAlternativeService(test_host_port_pair1); 343 impl_.GetAlternativeService(test_host_port_pair1);
343 EXPECT_EQ(443, alternative_service.port); 344 EXPECT_EQ(443, alternative_service.port);
344 EXPECT_EQ(NPN_SPDY_3, alternative_service.protocol); 345 EXPECT_EQ(NPN_SPDY_3, alternative_service.protocol);
345 it = map.begin(); 346 it = map.begin();
346 EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); 347 EXPECT_TRUE(it->first.Equals(test_host_port_pair1));
347 EXPECT_EQ(443, it->second.port); 348 EXPECT_EQ(NPN_SPDY_3, it->second.alternative_service.protocol);
348 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); 349 EXPECT_EQ(443, it->second.alternative_service.port);
349 } 350 }
350 351
351 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { 352 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
352 HostPortPair test_host_port_pair("foo", 80); 353 HostPortPair test_host_port_pair("foo", 80);
353 const AlternativeService alternative_service1(NPN_SPDY_3, "foo", 443); 354 const AlternativeService alternative_service1(NPN_SPDY_3, "foo", 443);
354 impl_.SetAlternativeService(test_host_port_pair, alternative_service1, 1.0); 355 impl_.SetAlternativeService(test_host_port_pair, alternative_service1, 1.0);
355 impl_.MarkAlternativeServiceBroken(alternative_service1); 356 impl_.MarkAlternativeServiceBroken(alternative_service1);
356 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); 357 ASSERT_TRUE(HasAlternativeService(test_host_port_pair));
357 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 358 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
358 359
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); 788 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond());
788 789
789 impl_.Clear(); 790 impl_.Clear();
790 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); 791 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server);
791 EXPECT_EQ(NULL, stats3); 792 EXPECT_EQ(NULL, stats3);
792 } 793 }
793 794
794 } // namespace 795 } // namespace
795 796
796 } // namespace net 797 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698