OLD | NEW |
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0); | 342 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0); |
343 impl_.SetBrokenAlternateProtocol(test_host_port_pair); | 343 impl_.SetBrokenAlternateProtocol(test_host_port_pair); |
344 ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair)); | 344 ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair)); |
345 const AlternativeService alternative_service(NPN_SPDY_3, | 345 const AlternativeService alternative_service(NPN_SPDY_3, |
346 test_host_port_pair.host(), 443); | 346 test_host_port_pair.host(), 443); |
347 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); | 347 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); |
348 impl_.ClearAlternateProtocol(test_host_port_pair); | 348 impl_.ClearAlternateProtocol(test_host_port_pair); |
349 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); | 349 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); |
350 } | 350 } |
351 | 351 |
| 352 TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) { |
| 353 HostPortPair host_port_pair("foo", 80); |
| 354 impl_.SetAlternateProtocol(host_port_pair, 443, NPN_SPDY_4, 1.0); |
| 355 |
| 356 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); |
| 357 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); |
| 358 EXPECT_FALSE(impl_.WasAlternateProtocolRecentlyBroken(host_port_pair)); |
| 359 |
| 360 impl_.MarkAlternativeServiceRecentlyBroken(alternative_service); |
| 361 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); |
| 362 EXPECT_TRUE(impl_.WasAlternateProtocolRecentlyBroken(host_port_pair)); |
| 363 |
| 364 impl_.ConfirmAlternateProtocol(host_port_pair); |
| 365 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); |
| 366 EXPECT_FALSE(impl_.WasAlternateProtocolRecentlyBroken(host_port_pair)); |
| 367 } |
| 368 |
352 TEST_F(AlternateProtocolServerPropertiesTest, Forced) { | 369 TEST_F(AlternateProtocolServerPropertiesTest, Forced) { |
353 // Test forced alternate protocols. | 370 // Test forced alternate protocols. |
354 | 371 |
355 AlternateProtocolInfo default_protocol(1234, NPN_SPDY_3, 1); | 372 AlternateProtocolInfo default_protocol(1234, NPN_SPDY_3, 1); |
356 HttpServerPropertiesImpl::ForceAlternateProtocol(default_protocol); | 373 HttpServerPropertiesImpl::ForceAlternateProtocol(default_protocol); |
357 | 374 |
358 // Verify the forced protocol. | 375 // Verify the forced protocol. |
359 HostPortPair test_host_port_pair("foo", 80); | 376 HostPortPair test_host_port_pair("foo", 80); |
360 EXPECT_TRUE(HasAlternateProtocol(test_host_port_pair)); | 377 EXPECT_TRUE(HasAlternateProtocol(test_host_port_pair)); |
361 AlternateProtocolInfo alternate = | 378 AlternateProtocolInfo alternate = |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); | 755 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); |
739 | 756 |
740 impl_.Clear(); | 757 impl_.Clear(); |
741 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); | 758 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); |
742 EXPECT_EQ(NULL, stats3); | 759 EXPECT_EQ(NULL, stats3); |
743 } | 760 } |
744 | 761 |
745 } // namespace | 762 } // namespace |
746 | 763 |
747 } // namespace net | 764 } // namespace net |
OLD | NEW |