| 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 be5e6b9af1f5e6264505d867e9d0f31d13be6d24..d6c2c1c9e0b6f050ab4d552cd200474e0f55859a 100644
|
| --- a/net/http/http_server_properties_impl_unittest.cc
|
| +++ b/net/http/http_server_properties_impl_unittest.cc
|
| @@ -27,6 +27,11 @@ namespace {
|
|
|
| class HttpServerPropertiesImplTest : public testing::Test {
|
| protected:
|
| + bool HasAlternateProtocol(const HostPortPair& server) {
|
| + const AlternateProtocolInfo alternate = impl_.GetAlternateProtocol(server);
|
| + return alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL;
|
| + }
|
| +
|
| HttpServerPropertiesImpl impl_;
|
| };
|
|
|
| @@ -219,23 +224,23 @@ typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest;
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Basic) {
|
| HostPortPair test_host_port_pair("foo", 80);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0);
|
| - ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| const AlternateProtocolInfo alternate =
|
| impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_EQ(443, alternate.port);
|
| EXPECT_EQ(NPN_SPDY_3, alternate.protocol);
|
|
|
| impl_.Clear();
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, DefaultProbabilityExcluded) {
|
| HostPortPair test_host_port_pair("foo", 80);
|
| impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, .99);
|
|
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Probability) {
|
| @@ -244,7 +249,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Probability) {
|
| HostPortPair test_host_port_pair("foo", 80);
|
| impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, .5);
|
|
|
| - ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| const AlternateProtocolInfo alternate =
|
| impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_EQ(443, alternate.port);
|
| @@ -258,7 +263,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) {
|
| HostPortPair test_host_port_pair("foo", 80);
|
|
|
| impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, .5);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| @@ -284,8 +289,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| EXPECT_EQ(1234, it->second.port);
|
| EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
|
|
|
| - ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1));
|
| - ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair2));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair1));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair2));
|
| alternate = impl_.GetAlternateProtocol(test_host_port_pair1);
|
| EXPECT_TRUE(alternate.is_broken);
|
| alternate = impl_.GetAlternateProtocol(test_host_port_pair2);
|
| @@ -293,26 +298,6 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
|
| EXPECT_EQ(NPN_SPDY_3, alternate.protocol);
|
| }
|
|
|
| -TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) {
|
| - HostPortPair test_host_port_pair1("foo1", 80);
|
| - 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.0);
|
| -
|
| - const AlternateProtocolMap& map = impl_.alternate_protocol_map();
|
| - AlternateProtocolMap::const_iterator it = map.begin();
|
| - EXPECT_TRUE(it->first.Equals(test_host_port_pair2));
|
| - EXPECT_EQ(1234, it->second.port);
|
| - EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
|
| -
|
| - // 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));
|
| - EXPECT_EQ(443, it->second.port);
|
| - EXPECT_EQ(NPN_SPDY_3, it->second.protocol);
|
| -}
|
| -
|
| TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) {
|
| HostPortPair test_host_port_pair1("foo1", 80);
|
| impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1.0);
|
| @@ -340,7 +325,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
|
| HostPortPair test_host_port_pair("foo", 80);
|
| 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));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| AlternateProtocolInfo alternate =
|
| impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_TRUE(alternate.is_broken);
|
| @@ -354,12 +339,12 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {
|
| HostPortPair test_host_port_pair("foo", 80);
|
| 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));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| AlternateProtocolInfo alternate =
|
| impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_TRUE(alternate.is_broken);
|
| impl_.ClearAlternateProtocol(test_host_port_pair);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Forced) {
|
| @@ -370,7 +355,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Forced) {
|
|
|
| // Verify the forced protocol.
|
| HostPortPair test_host_port_pair("foo", 80);
|
| - EXPECT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| AlternateProtocolInfo alternate =
|
| impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_EQ(default_protocol.port, alternate.port);
|
| @@ -378,7 +363,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Forced) {
|
|
|
| // Verify the real protocol overrides the forced protocol.
|
| impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1.0);
|
| - ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| alternate = impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_EQ(443, alternate.port);
|
| EXPECT_EQ(NPN_SPDY_3, alternate.protocol);
|
| @@ -389,22 +374,22 @@ TEST_F(AlternateProtocolServerPropertiesTest, Forced) {
|
|
|
| // Verify the forced protocol is off.
|
| HostPortPair test_host_port_pair2("bar", 80);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair2));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair2));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
|
| HostPortPair test_host_port_pair("foo.c.youtube.com", 80);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
|
|
| HostPortPair canonical_port_pair("bar.c.youtube.com", 80);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(canonical_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(canonical_port_pair));
|
|
|
| AlternateProtocolInfo canonical_protocol(1234, QUIC, 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));
|
| + ASSERT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| AlternateProtocolInfo alternate =
|
| impl_.GetAlternateProtocol(test_host_port_pair);
|
| EXPECT_EQ(canonical_protocol.port, alternate.port);
|
| @@ -427,8 +412,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBelowThreshold) {
|
| impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port,
|
| canonical_protocol.protocol,
|
| canonical_protocol.probability);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(canonical_port_pair));
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(canonical_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalAboveThreshold) {
|
| @@ -441,8 +426,8 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalAboveThreshold) {
|
| impl_.SetAlternateProtocol(canonical_port_pair, canonical_protocol.port,
|
| canonical_protocol.protocol,
|
| canonical_protocol.probability);
|
| - EXPECT_TRUE(impl_.HasAlternateProtocol(canonical_port_pair));
|
| - EXPECT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_TRUE(HasAlternateProtocol(canonical_port_pair));
|
| + EXPECT_TRUE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {
|
| @@ -456,7 +441,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {
|
| canonical_protocol.probability);
|
|
|
| impl_.ClearAlternateProtocol(canonical_port_pair);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) {
|
| @@ -470,7 +455,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) {
|
| canonical_protocol.probability);
|
|
|
| impl_.SetBrokenAlternateProtocol(canonical_port_pair);
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken2) {
|
| @@ -500,7 +485,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) {
|
| canonical_protocol.probability);
|
|
|
| impl_.Clear();
|
| - EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair));
|
| + EXPECT_FALSE(HasAlternateProtocol(test_host_port_pair));
|
| }
|
|
|
| typedef HttpServerPropertiesImplTest SpdySettingsServerPropertiesTest;
|
| @@ -695,37 +680,37 @@ typedef HttpServerPropertiesImplTest SupportsQuicServerPropertiesTest;
|
| TEST_F(SupportsQuicServerPropertiesTest, Initialize) {
|
| HostPortPair quic_server_google("www.google.com", 443);
|
|
|
| - // Check by initializing empty SupportsQuic.
|
| - SupportsQuicMap supports_quic_map;
|
| - impl_.InitializeSupportsQuic(&supports_quic_map);
|
| - SupportsQuic supports_quic = impl_.GetSupportsQuic(quic_server_google);
|
| - EXPECT_FALSE(supports_quic.used_quic);
|
| - EXPECT_EQ("", supports_quic.address);
|
| + // Check by initializing empty address.
|
| + IPAddressNumber initial_address;
|
| + impl_.InitializeSupportsQuic(&initial_address);
|
|
|
| - // Check by initializing with www.google.com:443.
|
| - SupportsQuic supports_quic1(true, "foo");
|
| - supports_quic_map.insert(std::make_pair(quic_server_google, supports_quic1));
|
| - impl_.InitializeSupportsQuic(&supports_quic_map);
|
| + IPAddressNumber address;
|
| + EXPECT_FALSE(impl_.GetSupportsQuic(&address));
|
| + EXPECT_TRUE(address.empty());
|
| +
|
| + // Check by initializing with a valid address.
|
| + CHECK(ParseIPLiteralToNumber("127.0.0.1", &initial_address));
|
| + impl_.InitializeSupportsQuic(&initial_address);
|
|
|
| - SupportsQuic supports_quic2 = impl_.GetSupportsQuic(quic_server_google);
|
| - EXPECT_TRUE(supports_quic2.used_quic);
|
| - EXPECT_EQ("foo", supports_quic2.address);
|
| + EXPECT_TRUE(impl_.GetSupportsQuic(&address));
|
| + EXPECT_EQ(initial_address, address);
|
| }
|
|
|
| TEST_F(SupportsQuicServerPropertiesTest, SetSupportsQuic) {
|
| - HostPortPair test_host_port_pair("foo", 80);
|
| - SupportsQuic supports_quic = impl_.GetSupportsQuic(test_host_port_pair);
|
| - EXPECT_FALSE(supports_quic.used_quic);
|
| - EXPECT_EQ("", supports_quic.address);
|
| - impl_.SetSupportsQuic(test_host_port_pair, true, "foo");
|
| - SupportsQuic supports_quic1 = impl_.GetSupportsQuic(test_host_port_pair);
|
| - EXPECT_TRUE(supports_quic1.used_quic);
|
| - EXPECT_EQ("foo", supports_quic1.address);
|
| + IPAddressNumber address;
|
| + EXPECT_FALSE(impl_.GetSupportsQuic(&address));
|
| + EXPECT_TRUE(address.empty());
|
| +
|
| + IPAddressNumber actual_address;
|
| + CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address));
|
| + impl_.SetSupportsQuic(true, actual_address);
|
| +
|
| + EXPECT_TRUE(impl_.GetSupportsQuic(&address));
|
| + EXPECT_EQ(actual_address, address);
|
|
|
| impl_.Clear();
|
| - SupportsQuic supports_quic2 = impl_.GetSupportsQuic(test_host_port_pair);
|
| - EXPECT_FALSE(supports_quic2.used_quic);
|
| - EXPECT_EQ("", supports_quic2.address);
|
| +
|
| + EXPECT_FALSE(impl_.GetSupportsQuic(&address));
|
| }
|
|
|
| typedef HttpServerPropertiesImplTest ServerNetworkStatsServerPropertiesTest;
|
|
|