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

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

Issue 1205633002: Set alternative service even if it is broken. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extend test. Created 5 years, 6 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') | no next file » | 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); 358 ASSERT_TRUE(HasAlternativeService(test_host_port_pair));
359 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 359 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
360 360
361 const AlternativeService alternative_service2(NPN_SPDY_4, "foo", 1234); 361 const AlternativeService alternative_service2(NPN_SPDY_4, "foo", 1234);
362 impl_.SetAlternativeService(test_host_port_pair, alternative_service2, 1.0); 362 impl_.SetAlternativeService(test_host_port_pair, alternative_service2, 1.0);
363 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 363 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
364 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service2)); 364 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service2));
365 EXPECT_EQ(1234, impl_.GetAlternativeService(test_host_port_pair).port); 365 EXPECT_EQ(1234, impl_.GetAlternativeService(test_host_port_pair).port);
366 } 366 }
367 367
368 // A broken alternative service in the mapping carries meaningful information,
369 // therefore it should not be ignored by SetAlternativeService(). In
370 // particular, an alternative service mapped to an origin shadows alternative
371 // services of canonical hosts.
372 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {
373 HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
374 HostPortPair canonical_port_pair("bar.c.youtube.com", 80);
375 AlternativeService canonical_altsvc(QUIC, "bar.c.youtube.com", 1234);
376 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 1.0);
377 EXPECT_TRUE(impl_.GetAlternativeService(test_host_port_pair) ==
378 canonical_altsvc);
379
380 const AlternativeService broken_alternative_service(NPN_SPDY_4, "foo", 443);
381 impl_.MarkAlternativeServiceBroken(broken_alternative_service);
382 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
383
384 impl_.SetAlternativeService(test_host_port_pair, broken_alternative_service,
385 1.0);
386 ASSERT_TRUE(impl_.GetAlternativeService(test_host_port_pair) ==
Ryan Hamilton 2015/06/24 21:08:32 nit: Does ASSERT_EQ() work?
Bence 2015/06/25 11:24:34 Oops, it does work. Sorry, I thought I need to in
387 broken_alternative_service);
388 }
Ryan Hamilton 2015/06/24 21:08:32 Can you also verify that: EXPECT_TRUE(impl_.IsAlt
Bence 2015/06/25 11:24:34 Done.
389
368 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { 390 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {
369 HostPortPair test_host_port_pair("foo", 80); 391 HostPortPair test_host_port_pair("foo", 80);
370 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); 392 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443);
371 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 1.0); 393 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 1.0);
372 impl_.MarkAlternativeServiceBroken(alternative_service); 394 impl_.MarkAlternativeServiceBroken(alternative_service);
373 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); 395 ASSERT_TRUE(HasAlternativeService(test_host_port_pair));
374 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 396 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
375 impl_.ClearAlternativeService(test_host_port_pair); 397 impl_.ClearAlternativeService(test_host_port_pair);
376 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 398 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
377 } 399 }
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); 811 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond());
790 812
791 impl_.Clear(); 813 impl_.Clear();
792 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); 814 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server);
793 EXPECT_EQ(NULL, stats3); 815 EXPECT_EQ(NULL, stats3);
794 } 816 }
795 817
796 } // namespace 818 } // namespace
797 819
798 } // namespace net 820 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698