| Index: net/http/http_server_properties_manager_unittest.cc
|
| diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc
|
| index 99647b3fef9aedeb01cecc864cc8ccb49e1fbe73..01bf01d8f7263b974e682e7c538cd8d9a30f5402 100644
|
| --- a/net/http/http_server_properties_manager_unittest.cc
|
| +++ b/net/http/http_server_properties_manager_unittest.cc
|
| @@ -156,12 +156,14 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| // Set supports_spdy for www.google.com:80.
|
| server_pref_dict->SetBoolean("supports_spdy", true);
|
|
|
| - // Set up alternate_protocol for www.google.com:80.
|
| + // Set up alternative_services for www.google.com:80.
|
| base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
|
| alternate_protocol->SetInteger("port", 443);
|
| alternate_protocol->SetString("protocol_str", "npn-spdy/3");
|
| - server_pref_dict->SetWithoutPathExpansion("alternate_protocol",
|
| - alternate_protocol);
|
| + base::ListValue* alternative_services = new base::ListValue;
|
| + alternative_services->Append(alternate_protocol);
|
| + server_pref_dict->SetWithoutPathExpansion("alternative_services",
|
| + alternative_services);
|
|
|
| // Set up SupportsQuic for www.google.com:80.
|
| base::DictionaryValue* supports_quic = new base::DictionaryValue;
|
| @@ -184,13 +186,14 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| // Set supports_spdy for mail.google.com:80
|
| server_pref_dict1->SetBoolean("supports_spdy", true);
|
|
|
| - // Set up alternate_protocol for mail.google.com:80
|
| + // Set up alternative_services for mail.google.com:80
|
| base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue;
|
| alternate_protocol1->SetInteger("port", 444);
|
| alternate_protocol1->SetString("protocol_str", "npn-spdy/3.1");
|
| -
|
| - server_pref_dict1->SetWithoutPathExpansion("alternate_protocol",
|
| - alternate_protocol1);
|
| + base::ListValue* alternative_services1 = new base::ListValue;
|
| + alternative_services1->Append(alternate_protocol1);
|
| + server_pref_dict1->SetWithoutPathExpansion("alternative_services",
|
| + alternative_services1);
|
|
|
| // Set up SupportsQuic for mail.google.com:80
|
| base::DictionaryValue* supports_quic1 = new base::DictionaryValue;
|
| @@ -231,14 +234,16 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| // Verify AlternateProtocol.
|
| ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(google_server));
|
| ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(mail_server));
|
| - AlternateProtocolInfo port_alternate_protocol =
|
| - http_server_props_manager_->GetAlternateProtocol(google_server);
|
| - EXPECT_EQ(443, port_alternate_protocol.port);
|
| - EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol.protocol);
|
| - port_alternate_protocol =
|
| - http_server_props_manager_->GetAlternateProtocol(mail_server);
|
| - EXPECT_EQ(444, port_alternate_protocol.port);
|
| - EXPECT_EQ(NPN_SPDY_3_1, port_alternate_protocol.protocol);
|
| + AlternateProtocols port_alternate_protocols =
|
| + http_server_props_manager_->GetAlternateProtocols(google_server);
|
| + ASSERT_EQ(1u, port_alternate_protocols.size());
|
| + EXPECT_EQ(443, port_alternate_protocols[0].port);
|
| + EXPECT_EQ(NPN_SPDY_3, port_alternate_protocols[0].protocol);
|
| + port_alternate_protocols =
|
| + http_server_props_manager_->GetAlternateProtocols(mail_server);
|
| + ASSERT_EQ(1u, port_alternate_protocols.size());
|
| + EXPECT_EQ(444, port_alternate_protocols[0].port);
|
| + EXPECT_EQ(NPN_SPDY_3_1, port_alternate_protocols[0].protocol);
|
|
|
| // Verify SupportsQuic.
|
| SupportsQuic supports_quic2 =
|
| @@ -268,12 +273,14 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| // Set supports_spdy for www.google.com:65536.
|
| server_pref_dict->SetBoolean("supports_spdy", true);
|
|
|
| - // Set up alternate_protocol for www.google.com:65536.
|
| + // Set up alternative_services for www.google.com:65536.
|
| base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
|
| alternate_protocol->SetInteger("port", 80);
|
| alternate_protocol->SetString("protocol_str", "npn-spdy/3");
|
| - server_pref_dict->SetWithoutPathExpansion("alternate_protocol",
|
| - alternate_protocol);
|
| + base::ListValue* alternative_services = new base::ListValue;
|
| + alternative_services->Append(alternate_protocol);
|
| + server_pref_dict->SetWithoutPathExpansion("alternative_services",
|
| + alternative_services);
|
|
|
| // Set up SupportsQuic for www.google.com:65536.
|
| base::DictionaryValue* supports_quic = new base::DictionaryValue;
|
| @@ -327,12 +334,14 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| // Set supports_spdy for www.google.com:80.
|
| server_pref_dict->SetBoolean("supports_spdy", true);
|
|
|
| - // Set up alternate_protocol for www.google.com:80.
|
| + // Set up alternative_services for www.google.com:80.
|
| base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
|
| alternate_protocol->SetInteger("port", 65536);
|
| alternate_protocol->SetString("protocol_str", "npn-spdy/3");
|
| - server_pref_dict->SetWithoutPathExpansion("alternate_protocol",
|
| - alternate_protocol);
|
| + base::ListValue* alternative_services = new base::ListValue;
|
| + alternative_services->Append(alternate_protocol);
|
| + server_pref_dict->SetWithoutPathExpansion("alternative_services",
|
| + alternative_services);
|
|
|
| // Set the server preference for www.google.com:80.
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| @@ -480,7 +489,7 @@ TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) {
|
| HostPortPair spdy_server_mail("mail.google.com", 80);
|
| EXPECT_FALSE(
|
| http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
|
| - http_server_props_manager_->SetAlternateProtocol(spdy_server_mail, 443,
|
| + http_server_props_manager_->AddAlternateProtocol(spdy_server_mail, 443,
|
| NPN_SPDY_3, 1);
|
|
|
| // Run the task.
|
| @@ -489,10 +498,11 @@ TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) {
|
|
|
| ASSERT_TRUE(
|
| http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
|
| - AlternateProtocolInfo port_alternate_protocol =
|
| - http_server_props_manager_->GetAlternateProtocol(spdy_server_mail);
|
| - EXPECT_EQ(443, port_alternate_protocol.port);
|
| - EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol.protocol);
|
| + AlternateProtocols port_alternate_protocols =
|
| + http_server_props_manager_->GetAlternateProtocols(spdy_server_mail);
|
| + ASSERT_EQ(1u, port_alternate_protocols.size());
|
| + EXPECT_EQ(443, port_alternate_protocols[0].port);
|
| + EXPECT_EQ(NPN_SPDY_3, port_alternate_protocols[0].protocol);
|
| }
|
|
|
| TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) {
|
| @@ -540,7 +550,7 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) {
|
|
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| - http_server_props_manager_->SetAlternateProtocol(spdy_server_mail, 443,
|
| + http_server_props_manager_->AddAlternateProtocol(spdy_server_mail, 443,
|
| NPN_SPDY_3, 1);
|
| http_server_props_manager_->SetSupportsQuic(spdy_server_mail, true, "foo");
|
| ServerNetworkStats stats;
|
| @@ -603,7 +613,7 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| -// crbug.com/444956: Add 200 alternate_protocol servers followed by
|
| +// https://crbug.com/444956: Add 200 alternate_protocol servers followed by
|
| // supports_quic and verify we have read supports_quic from prefs.
|
| TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| ExpectCacheUpdate();
|
| @@ -615,9 +625,11 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
|
| alternate_protocol->SetInteger("port", i);
|
| alternate_protocol->SetString("protocol_str", "npn-spdy/3");
|
| + base::ListValue* alternative_services = new base::ListValue;
|
| + alternative_services->Append(alternate_protocol);
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| - server_pref_dict->SetWithoutPathExpansion("alternate_protocol",
|
| - alternate_protocol);
|
| + server_pref_dict->SetWithoutPathExpansion("alternative_services",
|
| + alternative_services);
|
| servers_dict->SetWithoutPathExpansion(StringPrintf("www.google.com:%d", i),
|
| server_pref_dict);
|
| }
|
| @@ -650,18 +662,18 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| for (int i = 0; i < 200; ++i) {
|
| std::string server = StringPrintf("www.google.com:%d", i);
|
| ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
|
| - net::HostPortPair::FromString(server)));
|
| - net::AlternateProtocolInfo port_alternate_protocol =
|
| - http_server_props_manager_->GetAlternateProtocol(
|
| - net::HostPortPair::FromString(server));
|
| - EXPECT_EQ(i, port_alternate_protocol.port);
|
| - EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol);
|
| + HostPortPair::FromString(server)));
|
| + AlternateProtocols port_alternate_protocols =
|
| + http_server_props_manager_->GetAlternateProtocols(
|
| + HostPortPair::FromString(server));
|
| + EXPECT_EQ(1u, port_alternate_protocols.size());
|
| + EXPECT_EQ(i, port_alternate_protocols[0].port);
|
| + EXPECT_EQ(NPN_SPDY_3, port_alternate_protocols[0].protocol);
|
| }
|
|
|
| // Verify SupportsQuic.
|
| - net::SupportsQuic supports_quic1 =
|
| - http_server_props_manager_->GetSupportsQuic(
|
| - net::HostPortPair::FromString("mail.google.com:80"));
|
| + SupportsQuic supports_quic1 = http_server_props_manager_->GetSupportsQuic(
|
| + HostPortPair::FromString("mail.google.com:80"));
|
| EXPECT_TRUE(supports_quic1.used_quic);
|
| EXPECT_EQ("bar", supports_quic1.address);
|
| }
|
|
|