Index: net/http/http_server_properties_impl_unittest.cc |
diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc |
index 1675833881861ccfe32357e2248d7f3943e107f3..be5e6b9af1f5e6264505d867e9d0f31d13be6d24 100644 |
--- a/net/http/http_server_properties_impl_unittest.cc |
+++ b/net/http/http_server_properties_impl_unittest.cc |
@@ -41,18 +41,18 @@ TEST_F(SpdyServerPropertiesTest, Initialize) { |
// Check by initializing NULL spdy servers. |
impl_.InitializeSpdyServers(NULL, true); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); |
// Check by initializing empty spdy servers. |
std::vector<std::string> spdy_servers; |
impl_.InitializeSpdyServers(&spdy_servers, true); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); |
// Check by initializing with www.google.com:443 spdy server. |
std::vector<std::string> spdy_servers1; |
spdy_servers1.push_back(spdy_server_g); |
impl_.InitializeSpdyServers(&spdy_servers1, true); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
// Check by initializing with www.google.com:443 and docs.google.com:443 spdy |
// servers. |
@@ -71,55 +71,38 @@ TEST_F(SpdyServerPropertiesTest, Initialize) { |
std::string string_value_d; |
ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_d)); |
ASSERT_EQ(spdy_server_d, string_value_d); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_docs)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
} |
-TEST_F(SpdyServerPropertiesTest, SupportsSpdyTest) { |
+TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) { |
HostPortPair spdy_server_empty(std::string(), 443); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_empty)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty)); |
// Add www.google.com:443 as supporting SPDY. |
HostPortPair spdy_server_google("www.google.com", 443); |
impl_.SetSupportsSpdy(spdy_server_google, true); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
// Add mail.google.com:443 as not supporting SPDY. |
HostPortPair spdy_server_mail("mail.google.com", 443); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_mail)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); |
// Add docs.google.com:443 as supporting SPDY. |
HostPortPair spdy_server_docs("docs.google.com", 443); |
impl_.SetSupportsSpdy(spdy_server_docs, true); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_docs)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
- // Verify all the entries are the same after additions. |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_mail)); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_docs)); |
-} |
- |
-TEST_F(SpdyServerPropertiesTest, SetSupportsSpdy) { |
- HostPortPair spdy_server_empty(std::string(), 443); |
- impl_.SetSupportsSpdy(spdy_server_empty, true); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_empty)); |
- |
- // Add www.google.com:443 as supporting SPDY. |
- HostPortPair spdy_server_google("www.google.com", 443); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); |
- impl_.SetSupportsSpdy(spdy_server_google, true); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
+ // Add www.youtube.com:443 as supporting QUIC. |
+ HostPortPair quic_server_youtube("www.youtube.com", 443); |
+ impl_.SetAlternateProtocol(quic_server_youtube, 443, QUIC, 1); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube)); |
- // Make www.google.com:443 as not supporting SPDY. |
- impl_.SetSupportsSpdy(spdy_server_google, false); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); |
- |
- // Add mail.google.com:443 as supporting SPDY. |
- HostPortPair spdy_server_mail("mail.google.com", 443); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_mail)); |
- impl_.SetSupportsSpdy(spdy_server_mail, true); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_mail)); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); |
+ // Verify all the entries are the same after additions. |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube)); |
} |
TEST_F(SpdyServerPropertiesTest, Clear) { |
@@ -129,12 +112,12 @@ TEST_F(SpdyServerPropertiesTest, Clear) { |
HostPortPair spdy_server_mail("mail.google.com", 443); |
impl_.SetSupportsSpdy(spdy_server_mail, true); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_mail)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail)); |
impl_.Clear(); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); |
- EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_mail)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); |
} |
TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) { |
@@ -223,7 +206,7 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) { |
// Get www.google.com:443 should reorder SpdyServerHostPortMap. Verify that it |
// is www.google.com:443 is the MRU server. |
- EXPECT_TRUE(impl_.SupportsSpdy(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
ASSERT_EQ(2U, spdy_server_list.GetSize()); |
ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
@@ -237,7 +220,7 @@ typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest; |
TEST_F(AlternateProtocolServerPropertiesTest, Basic) { |
HostPortPair test_host_port_pair("foo", 80); |
EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
- impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0); |
ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
const AlternateProtocolInfo alternate = |
impl_.GetAlternateProtocol(test_host_port_pair); |
@@ -280,10 +263,10 @@ TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) { |
TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { |
HostPortPair test_host_port_pair1("foo1", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1.0); |
impl_.SetBrokenAlternateProtocol(test_host_port_pair1); |
HostPortPair test_host_port_pair2("foo2", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3, 1.0); |
AlternateProtocolMap alternate_protocol_map( |
AlternateProtocolMap::NO_AUTO_EVICT); |
@@ -297,7 +280,6 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { |
// Verify test_host_port_pair3 is the MRU server. |
const AlternateProtocolMap& map = impl_.alternate_protocol_map(); |
AlternateProtocolMap::const_iterator it = map.begin(); |
- it = map.begin(); |
EXPECT_TRUE(it->first.Equals(test_host_port_pair3)); |
EXPECT_EQ(1234, it->second.port); |
EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
@@ -313,9 +295,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { |
TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) { |
HostPortPair test_host_port_pair1("foo1", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1.0); |
HostPortPair test_host_port_pair2("foo2", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3, 1.0); |
const AlternateProtocolMap& map = impl_.alternate_protocol_map(); |
AlternateProtocolMap::const_iterator it = map.begin(); |
@@ -323,7 +305,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) { |
EXPECT_EQ(1234, it->second.port); |
EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
- // HasAlternateProtocol should reoder the AlternateProtocol map. |
+ // HasAlternateProtocol should reorder the AlternateProtocol map. |
ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1)); |
it = map.begin(); |
EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); |
@@ -333,9 +315,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) { |
TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) { |
HostPortPair test_host_port_pair1("foo1", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1.0); |
HostPortPair test_host_port_pair2("foo2", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3, 1.0); |
const AlternateProtocolMap& map = impl_.alternate_protocol_map(); |
AlternateProtocolMap::const_iterator it = map.begin(); |
@@ -343,7 +325,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) { |
EXPECT_EQ(1234, it->second.port); |
EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
- // GetAlternateProtocol should reoder the AlternateProtocol map. |
+ // GetAlternateProtocol should reorder the AlternateProtocol map. |
AlternateProtocolInfo alternate = |
impl_.GetAlternateProtocol(test_host_port_pair1); |
EXPECT_EQ(443, alternate.port); |
@@ -356,25 +338,21 @@ TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) { |
TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { |
HostPortPair test_host_port_pair("foo", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0); |
impl_.SetBrokenAlternateProtocol(test_host_port_pair); |
ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
AlternateProtocolInfo alternate = |
impl_.GetAlternateProtocol(test_host_port_pair); |
EXPECT_TRUE(alternate.is_broken); |
- impl_.SetAlternateProtocol( |
- test_host_port_pair, |
- 1234, |
- NPN_SPDY_3, |
- 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair, 1234, NPN_SPDY_3, 1.0); |
alternate = impl_.GetAlternateProtocol(test_host_port_pair); |
EXPECT_TRUE(alternate.is_broken) << "Second attempt should be ignored."; |
} |
TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { |
HostPortPair test_host_port_pair("foo", 80); |
- impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0); |
impl_.SetBrokenAlternateProtocol(test_host_port_pair); |
ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
AlternateProtocolInfo alternate = |
@@ -399,7 +377,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Forced) { |
EXPECT_EQ(default_protocol.protocol, alternate.protocol); |
// Verify the real protocol overrides the forced protocol. |
- impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1); |
+ impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0); |
ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
alternate = impl_.GetAlternateProtocol(test_host_port_pair); |
EXPECT_EQ(443, alternate.port); |
@@ -423,10 +401,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) { |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
- canonical_protocol.protocol, |
- 1); |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
+ canonical_protocol.protocol, 1.0); |
// Verify the forced protocol. |
ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
AlternateProtocolInfo alternate = |
@@ -435,8 +411,10 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) { |
EXPECT_EQ(canonical_protocol.protocol, alternate.protocol); |
// Verify the canonical suffix. |
- EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(test_host_port_pair)); |
- EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(canonical_port_pair)); |
+ EXPECT_EQ(".c.youtube.com", |
+ impl_.GetCanonicalSuffix(test_host_port_pair.host())); |
+ EXPECT_EQ(".c.youtube.com", |
+ impl_.GetCanonicalSuffix(canonical_port_pair.host())); |
} |
TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBelowThreshold) { |
@@ -446,8 +424,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBelowThreshold) { |
HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 0.01); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
canonical_protocol.protocol, |
canonical_protocol.probability); |
EXPECT_FALSE(impl_.HasAlternateProtocol(canonical_port_pair)); |
@@ -461,8 +438,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalAboveThreshold) { |
HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 0.03); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
canonical_protocol.protocol, |
canonical_protocol.probability); |
EXPECT_TRUE(impl_.HasAlternateProtocol(canonical_port_pair)); |
@@ -475,8 +451,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) { |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
canonical_protocol.protocol, |
canonical_protocol.probability); |
@@ -490,8 +465,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) { |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
canonical_protocol.protocol, |
canonical_protocol.probability); |
@@ -505,8 +479,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken2) { |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
canonical_protocol.protocol, |
canonical_protocol.probability); |
@@ -522,8 +495,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) { |
AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); |
- impl_.SetAlternateProtocol(canonical_port_pair, |
- canonical_protocol.port, |
+ impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port, |
canonical_protocol.protocol, |
canonical_protocol.probability); |
@@ -696,7 +668,7 @@ TEST_F(SpdySettingsServerPropertiesTest, MRUOfGetSpdySettings) { |
EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value2_ret.first); |
EXPECT_EQ(value2, flags_and_value2_ret.second); |
- // GetSpdySettings should reoder the SpdySettingsMap. |
+ // GetSpdySettings should reorder the SpdySettingsMap. |
const SettingsMap& settings_map1_ret = |
impl_.GetSpdySettings(spdy_server_google); |
ASSERT_EQ(1U, settings_map1_ret.size()); |