| 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 flags_and_value1_ret = it1_ret->second; | 688 flags_and_value1_ret = it1_ret->second; |
| 689 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 689 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
| 690 EXPECT_EQ(value1, flags_and_value1_ret.second); | 690 EXPECT_EQ(value1, flags_and_value1_ret.second); |
| 691 } | 691 } |
| 692 | 692 |
| 693 typedef HttpServerPropertiesImplTest SupportsQuicServerPropertiesTest; | 693 typedef HttpServerPropertiesImplTest SupportsQuicServerPropertiesTest; |
| 694 | 694 |
| 695 TEST_F(SupportsQuicServerPropertiesTest, Initialize) { | 695 TEST_F(SupportsQuicServerPropertiesTest, Initialize) { |
| 696 HostPortPair quic_server_google("www.google.com", 443); | 696 HostPortPair quic_server_google("www.google.com", 443); |
| 697 | 697 |
| 698 // Check by initializing empty SupportsQuic. | 698 // Check by initializing empty address. |
| 699 SupportsQuicMap supports_quic_map; | 699 IPAddressNumber initial_address; |
| 700 impl_.InitializeSupportsQuic(&supports_quic_map); | 700 impl_.InitializeSupportsQuic(&initial_address); |
| 701 SupportsQuic supports_quic = impl_.GetSupportsQuic(quic_server_google); | |
| 702 EXPECT_FALSE(supports_quic.used_quic); | |
| 703 EXPECT_EQ("", supports_quic.address); | |
| 704 | 701 |
| 705 // Check by initializing with www.google.com:443. | 702 IPAddressNumber address; |
| 706 SupportsQuic supports_quic1(true, "foo"); | 703 EXPECT_FALSE(impl_.GetSupportsQuic(&address)); |
| 707 supports_quic_map.insert(std::make_pair(quic_server_google, supports_quic1)); | 704 EXPECT_TRUE(address.empty()); |
| 708 impl_.InitializeSupportsQuic(&supports_quic_map); | |
| 709 | 705 |
| 710 SupportsQuic supports_quic2 = impl_.GetSupportsQuic(quic_server_google); | 706 // Check by initializing with a valid address. |
| 711 EXPECT_TRUE(supports_quic2.used_quic); | 707 CHECK(ParseIPLiteralToNumber("127.0.0.1", &initial_address)); |
| 712 EXPECT_EQ("foo", supports_quic2.address); | 708 impl_.InitializeSupportsQuic(&initial_address); |
| 709 |
| 710 EXPECT_TRUE(impl_.GetSupportsQuic(&address)); |
| 711 EXPECT_EQ(initial_address, address); |
| 713 } | 712 } |
| 714 | 713 |
| 715 TEST_F(SupportsQuicServerPropertiesTest, SetSupportsQuic) { | 714 TEST_F(SupportsQuicServerPropertiesTest, SetSupportsQuic) { |
| 716 HostPortPair test_host_port_pair("foo", 80); | 715 IPAddressNumber address; |
| 717 SupportsQuic supports_quic = impl_.GetSupportsQuic(test_host_port_pair); | 716 EXPECT_FALSE(impl_.GetSupportsQuic(&address)); |
| 718 EXPECT_FALSE(supports_quic.used_quic); | 717 EXPECT_TRUE(address.empty()); |
| 719 EXPECT_EQ("", supports_quic.address); | 718 |
| 720 impl_.SetSupportsQuic(test_host_port_pair, true, "foo"); | 719 IPAddressNumber actual_address; |
| 721 SupportsQuic supports_quic1 = impl_.GetSupportsQuic(test_host_port_pair); | 720 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); |
| 722 EXPECT_TRUE(supports_quic1.used_quic); | 721 impl_.SetSupportsQuic(true, actual_address); |
| 723 EXPECT_EQ("foo", supports_quic1.address); | 722 |
| 723 EXPECT_TRUE(impl_.GetSupportsQuic(&address)); |
| 724 EXPECT_EQ(actual_address, address); |
| 724 | 725 |
| 725 impl_.Clear(); | 726 impl_.Clear(); |
| 726 SupportsQuic supports_quic2 = impl_.GetSupportsQuic(test_host_port_pair); | 727 |
| 727 EXPECT_FALSE(supports_quic2.used_quic); | 728 EXPECT_FALSE(impl_.GetSupportsQuic(&address)); |
| 728 EXPECT_EQ("", supports_quic2.address); | |
| 729 } | 729 } |
| 730 | 730 |
| 731 typedef HttpServerPropertiesImplTest ServerNetworkStatsServerPropertiesTest; | 731 typedef HttpServerPropertiesImplTest ServerNetworkStatsServerPropertiesTest; |
| 732 | 732 |
| 733 TEST_F(ServerNetworkStatsServerPropertiesTest, Initialize) { | 733 TEST_F(ServerNetworkStatsServerPropertiesTest, Initialize) { |
| 734 HostPortPair google_server("www.google.com", 443); | 734 HostPortPair google_server("www.google.com", 443); |
| 735 | 735 |
| 736 // Check by initializing empty ServerNetworkStats. | 736 // Check by initializing empty ServerNetworkStats. |
| 737 ServerNetworkStatsMap server_network_stats_map( | 737 ServerNetworkStatsMap server_network_stats_map( |
| 738 ServerNetworkStatsMap::NO_AUTO_EVICT); | 738 ServerNetworkStatsMap::NO_AUTO_EVICT); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 767 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); | 767 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); |
| 768 | 768 |
| 769 impl_.Clear(); | 769 impl_.Clear(); |
| 770 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); | 770 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); |
| 771 EXPECT_EQ(NULL, stats3); | 771 EXPECT_EQ(NULL, stats3); |
| 772 } | 772 } |
| 773 | 773 |
| 774 } // namespace | 774 } // namespace |
| 775 | 775 |
| 776 } // namespace net | 776 } // namespace net |
| OLD | NEW |