| 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 16df3f3cb6bce081c3bcd6011509944816041926..3c5906323486070dfdb6a2dab66e6b094c824771 100644
|
| --- a/net/http/http_server_properties_manager_unittest.cc
|
| +++ b/net/http/http_server_properties_manager_unittest.cc
|
| @@ -143,7 +143,7 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager {
|
|
|
| // TODO(rtenneti): After we stop supporting version 3 and everyone has migrated
|
| // to version 4, delete the following code.
|
| -static const int kHttpServerPropertiesVersions[] = {3, 4};
|
| +static const int kHttpServerPropertiesVersions[] = {3, 4, 5};
|
|
|
| class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> {
|
| protected:
|
| @@ -206,7 +206,7 @@ class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> {
|
| UpdatePrefsFromCacheOnNetworkThreadConcrete));
|
| }
|
|
|
| - bool HasAlternativeService(const HostPortPair& server) {
|
| + bool HasAlternativeService(const url::SchemeHostPort& server) {
|
| const AlternativeServiceVector alternative_service_vector =
|
| http_server_props_manager_->GetAlternativeServices(server);
|
| return !alternative_service_vector.empty();
|
| @@ -233,13 +233,15 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| // it twice. Only expect a single cache update.
|
|
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| - HostPortPair google_server("www.google.com", 80);
|
| - HostPortPair mail_server("mail.google.com", 80);
|
| + url::SchemeHostPort google_server(GetParam() >= 5 ? "http" : "https",
|
| + "www.google.com", 80);
|
| + url::SchemeHostPort mail_server(GetParam() >= 5 ? "http" : "https",
|
| + "mail.google.com", 80);
|
|
|
| - // Set supports_spdy for www.google.com:80.
|
| + // Set supports_spdy for http://www.google.com:80.
|
| server_pref_dict->SetBoolean("supports_spdy", true);
|
|
|
| - // Set up alternative_services for www.google.com:80.
|
| + // Set up alternative_services for http://www.google.com:80.
|
| base::DictionaryValue* alternative_service_dict0 = new base::DictionaryValue;
|
| alternative_service_dict0->SetInteger("port", 443);
|
| alternative_service_dict0->SetString("protocol_str", "npn-h2");
|
| @@ -252,16 +254,18 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| server_pref_dict->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list0);
|
|
|
| - // Set up ServerNetworkStats for www.google.com:80.
|
| + // Set up ServerNetworkStats for http://www.google.com:80.
|
| base::DictionaryValue* stats = new base::DictionaryValue;
|
| stats->SetInteger("srtt", 10);
|
| server_pref_dict->SetWithoutPathExpansion("network_stats", stats);
|
|
|
| - // Set the server preference for www.google.com:80.
|
| + // Set the server preference for http://www.google.com:80.
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| - servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| + servers_dict->SetWithoutPathExpansion(
|
| + GetParam() >= 5 ? "http://www.google.com" : "www.google.com:80",
|
| + server_pref_dict);
|
| base::ListValue* servers_list = nullptr;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| servers_list = new base::ListValue;
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| @@ -283,18 +287,25 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| server_pref_dict1->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list1);
|
|
|
| - // Set up ServerNetworkStats for mail.google.com:80 and it is the MRU server.
|
| + // Set up ServerNetworkStats for http://mail.google.com:80 and it is the MRU
|
| + // server.
|
| base::DictionaryValue* stats1 = new base::DictionaryValue;
|
| stats1->SetInteger("srtt", 20);
|
| server_pref_dict1->SetWithoutPathExpansion("network_stats", stats1);
|
| - // Set the server preference for mail.google.com:80.
|
| - servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| - server_pref_dict1);
|
| + // Set the server preference for http://mail.google.com:80.
|
| + servers_dict->SetWithoutPathExpansion(
|
| + GetParam() >= 5 ? "http://mail.google.com" : "mail.google.com:80",
|
| + server_pref_dict1);
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -351,11 +362,15 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| EXPECT_TRUE(
|
| http_server_props_manager_->SupportsRequestPriority(google_server));
|
| EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(mail_server));
|
| - EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(
|
| - HostPortPair::FromString("foo.google.com:1337")));
|
| + HostPortPair foo_host_port_pair =
|
| + HostPortPair::FromString("foo.google.com:1337");
|
| + url::SchemeHostPort foo_server("http", foo_host_port_pair.host(),
|
| + foo_host_port_pair.port());
|
| +
|
| + EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(foo_server));
|
|
|
| // Verify alternative service.
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| const AlternativeServiceMap& map =
|
| http_server_props_manager_->alternative_service_map();
|
| ASSERT_EQ(2u, map.size());
|
| @@ -457,11 +472,16 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| servers_dict->SetWithoutPathExpansion("www.google.com:65536",
|
| server_pref_dict);
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| base::ListValue* servers_list = new base::ListValue;
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -489,13 +509,16 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| // Verify that nothing is set.
|
| - EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(
|
| - HostPortPair::FromString("www.google.com:65536")));
|
| + HostPortPair google_host_port_pair =
|
| + HostPortPair::FromString("www.google.com:65536");
|
| + url::SchemeHostPort gooler_server("http", google_host_port_pair.host(),
|
| + google_host_port_pair.port());
|
| +
|
| EXPECT_FALSE(
|
| - HasAlternativeService(HostPortPair::FromString("www.google.com:65536")));
|
| + http_server_props_manager_->SupportsRequestPriority(gooler_server));
|
| + EXPECT_FALSE(HasAlternativeService(gooler_server));
|
| const ServerNetworkStats* stats1 =
|
| - http_server_props_manager_->GetServerNetworkStats(
|
| - HostPortPair::FromString("www.google.com:65536"));
|
| + http_server_props_manager_->GetServerNetworkStats(gooler_server);
|
| EXPECT_EQ(nullptr, stats1);
|
| EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size());
|
| }
|
| @@ -524,11 +547,16 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| base::ListValue* servers_list = new base::ListValue;
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -546,7 +574,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
|
|
| // Verify alternative service is not set.
|
| EXPECT_FALSE(
|
| - HasAlternativeService(HostPortPair::FromString("www.google.com:80")));
|
| + HasAlternativeService(url::SchemeHostPort("http", "www.google.com", 80)));
|
| }
|
|
|
| TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| @@ -557,18 +585,17 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| // ScheduleUpdatePrefsOnNetworkThread.
|
|
|
| // Add mail.google.com:443 as a supporting spdy server.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server("https", "mail.google.com", 443);
|
| EXPECT_FALSE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| - http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| + http_server_props_manager_->SupportsRequestPriority(spdy_server));
|
| + http_server_props_manager_->SetSupportsSpdy(spdy_server, true);
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once.
|
| - http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| + http_server_props_manager_->SetSupportsSpdy(spdy_server, true);
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
|
|
| - EXPECT_TRUE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| + EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server));
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| @@ -577,7 +604,7 @@ TEST_P(HttpServerPropertiesManagerTest, SetSpdySetting) {
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| // Add SpdySetting for mail.google.com:443.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| @@ -604,7 +631,7 @@ TEST_P(HttpServerPropertiesManagerTest, ClearSpdySetting) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| // Add SpdySetting for mail.google.com:443.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| @@ -643,7 +670,7 @@ TEST_P(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| // Add SpdySetting for mail.google.com:443.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| @@ -680,7 +707,7 @@ TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| + url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com",
|
| 443);
|
| @@ -704,7 +731,7 @@ TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| + url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| const AlternativeService alternative_service1(NPN_HTTP_2, "mail.google.com",
|
| @@ -732,7 +759,7 @@ TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| }
|
|
|
| TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| + url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com",
|
| 443);
|
| @@ -751,7 +778,7 @@ TEST_P(HttpServerPropertiesManagerTest, ClearAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| + url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 443);
|
| http_server_props_manager_->SetAlternativeService(
|
| @@ -771,7 +798,7 @@ TEST_P(HttpServerPropertiesManagerTest, ClearAlternativeServices) {
|
| TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
|
| ExpectPrefsUpdate();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| + url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 443);
|
|
|
| @@ -838,7 +865,7 @@ TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair mail_server("mail.google.com", 80);
|
| + url::SchemeHostPort mail_server("http", "mail.google.com", 80);
|
| const ServerNetworkStats* stats =
|
| http_server_props_manager_->GetServerNetworkStats(mail_server);
|
| EXPECT_EQ(nullptr, stats);
|
| @@ -883,16 +910,16 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| - http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| + url::SchemeHostPort spdy_server("https", "mail.google.com", 443);
|
| + http_server_props_manager_->SetSupportsSpdy(spdy_server, true);
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 1234);
|
| http_server_props_manager_->SetAlternativeService(
|
| - spdy_server_mail, alternative_service, one_day_from_now_);
|
| + spdy_server, alternative_service, one_day_from_now_);
|
| IPAddress actual_address(127, 0, 0, 1);
|
| http_server_props_manager_->SetSupportsQuic(true, actual_address);
|
| ServerNetworkStats stats;
|
| stats.srtt = base::TimeDelta::FromMicroseconds(10);
|
| - http_server_props_manager_->SetServerNetworkStats(spdy_server_mail, stats);
|
| + http_server_props_manager_->SetServerNetworkStats(spdy_server, stats);
|
|
|
| QuicServerId mail_quic_server_id("mail.google.com", 80);
|
| std::string quic_server_info1("quic_server_info1");
|
| @@ -902,27 +929,25 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| - http_server_props_manager_->SetSpdySetting(spdy_server_mail, id1, flags1,
|
| - value1);
|
| + http_server_props_manager_->SetSpdySetting(spdy_server, id1, flags1, value1);
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
|
|
| - EXPECT_TRUE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_TRUE(HasAlternativeService(spdy_server_mail));
|
| + EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(spdy_server));
|
| + EXPECT_TRUE(HasAlternativeService(spdy_server));
|
| IPAddress address;
|
| EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address));
|
| EXPECT_EQ(actual_address, address);
|
| const ServerNetworkStats* stats1 =
|
| - http_server_props_manager_->GetServerNetworkStats(spdy_server_mail);
|
| + http_server_props_manager_->GetServerNetworkStats(spdy_server);
|
| EXPECT_EQ(10, stats1->srtt.ToInternalValue());
|
| EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo(
|
| mail_quic_server_id));
|
|
|
| // Check SPDY settings values.
|
| const SettingsMap& settings_map1_ret =
|
| - http_server_props_manager_->GetSpdySettings(spdy_server_mail);
|
| + http_server_props_manager_->GetSpdySettings(spdy_server);
|
| ASSERT_EQ(1U, settings_map1_ret.size());
|
| SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1);
|
| EXPECT_TRUE(it1_ret != settings_map1_ret.end());
|
| @@ -939,17 +964,17 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| base::RunLoop().Run();
|
|
|
| EXPECT_FALSE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + http_server_props_manager_->SupportsRequestPriority(spdy_server));
|
| + EXPECT_FALSE(HasAlternativeService(spdy_server));
|
| EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address));
|
| const ServerNetworkStats* stats2 =
|
| - http_server_props_manager_->GetServerNetworkStats(spdy_server_mail);
|
| + http_server_props_manager_->GetServerNetworkStats(spdy_server);
|
| EXPECT_EQ(nullptr, stats2);
|
| EXPECT_EQ(nullptr,
|
| http_server_props_manager_->GetQuicServerInfo(mail_quic_server_id));
|
|
|
| const SettingsMap& settings_map2_ret =
|
| - http_server_props_manager_->GetSpdySettings(spdy_server_mail);
|
| + http_server_props_manager_->GetSpdySettings(spdy_server);
|
| EXPECT_EQ(0U, settings_map2_ret.size());
|
|
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| @@ -962,10 +987,10 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
|
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| base::ListValue* servers_list = nullptr;
|
| - if (GetParam() == 4)
|
| + if (GetParam() >= 4)
|
| servers_list = new base::ListValue;
|
|
|
| - for (int i = 0; i < 200; ++i) {
|
| + for (int i = 1; i <= 200; ++i) {
|
| // Set up alternative_service for www.google.com:i.
|
| base::DictionaryValue* alternative_service_dict = new base::DictionaryValue;
|
| alternative_service_dict->SetString("protocol_str", "quic");
|
| @@ -975,29 +1000,39 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| server_pref_dict->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list);
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 5) {
|
| + servers_dict->SetWithoutPathExpansion(
|
| + StringPrintf("http://www.google.com:%d", i), server_pref_dict);
|
| + } else {
|
| servers_dict->SetWithoutPathExpansion(
|
| StringPrintf("www.google.com:%d", i), server_pref_dict);
|
| + }
|
| + if (GetParam() >= 4) {
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| servers_dict = new base::DictionaryValue;
|
| - } else {
|
| - servers_dict->SetWithoutPathExpansion(
|
| - StringPrintf("www.google.com:%d", i), server_pref_dict);
|
| }
|
| }
|
|
|
| - // Set the preference for mail.google.com server.
|
| + // Set the server preference for http://mail.google.com server.
|
| base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue;
|
| -
|
| - // Set the server preference for mail.google.com:80.
|
| - servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| - server_pref_dict1);
|
| + if (GetParam() >= 5) {
|
| + servers_dict->SetWithoutPathExpansion("http://mail.google.com",
|
| + server_pref_dict1);
|
| + } else {
|
| + servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| + server_pref_dict1);
|
| + }
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -1021,11 +1056,16 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| // Verify alternative service.
|
| - for (int i = 0; i < 200; ++i) {
|
| - std::string server = StringPrintf("www.google.com:%d", i);
|
| + for (int i = 1; i <= 200; ++i) {
|
| + GURL server_gurl;
|
| + if (GetParam() >= 5) {
|
| + server_gurl = GURL(StringPrintf("http://www.google.com:%d", i));
|
| + } else {
|
| + server_gurl = GURL(StringPrintf("https://www.google.com:%d", i));
|
| + }
|
| + url::SchemeHostPort server(server_gurl);
|
| AlternativeServiceVector alternative_service_vector =
|
| - http_server_props_manager_->GetAlternativeServices(
|
| - HostPortPair::FromString(server));
|
| + http_server_props_manager_->GetAlternativeServices(server);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
|
| EXPECT_EQ(i, alternative_service_vector[0].port);
|
| @@ -1040,8 +1080,8 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| - const HostPortPair server_www("www.google.com", 80);
|
| - const HostPortPair server_mail("mail.google.com", 80);
|
| + const url::SchemeHostPort server_www("http", "www.google.com", 80);
|
| + const url::SchemeHostPort server_mail("http", "mail.google.com", 80);
|
|
|
| // Set alternate protocol.
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| @@ -1091,18 +1131,18 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| "{\"quic_servers\":{\"https://"
|
| "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}},"
|
| "\"servers\":["
|
| - "{\"www.google.com:80\":{"
|
| + "{\"http://www.google.com\":{"
|
| "\"alternative_service\":[{\"expiration\":\"13756212000000000\","
|
| "\"port\":443,\"protocol_str\":\"npn-h2\"},"
|
| "{\"expiration\":\"13758804000000000\",\"host\":\"www.google.com\","
|
| "\"port\":1234,\"protocol_str\":\"npn-h2\"}]}},"
|
| - "{\"mail.google.com:80\":{\"alternative_service\":[{"
|
| + "{\"http://mail.google.com\":{\"alternative_service\":[{"
|
| "\"expiration\":\"9223372036854775807\",\"host\":\"foo.google.com\","
|
| "\"port\":444,\"protocol_str\":\"npn-spdy/3.1\"}],"
|
| "\"network_stats\":{\"srtt\":42}}}"
|
| "],"
|
| "\"supports_quic\":{\"address\":\"127.0.0.1\",\"used_quic\":true},"
|
| - "\"version\":4}";
|
| + "\"version\":5}";
|
|
|
| const base::Value* http_server_properties =
|
| &pref_delegate_->GetServerProperties();
|
| @@ -1123,13 +1163,12 @@ TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
|
| base::DictionaryValue* server_dict;
|
| ASSERT_TRUE(server_value->GetAsDictionary(&server_dict));
|
|
|
| - const HostPortPair host_port_pair("example.com", 443);
|
| + const url::SchemeHostPort server("https", "example.com", 443);
|
| AlternativeServiceMap alternative_service_map(/*max_size=*/5);
|
| EXPECT_TRUE(http_server_props_manager_->AddToAlternativeServiceMap(
|
| - host_port_pair, *server_dict, &alternative_service_map));
|
| + server, *server_dict, &alternative_service_map));
|
|
|
| - AlternativeServiceMap::iterator it =
|
| - alternative_service_map.Get(host_port_pair);
|
| + AlternativeServiceMap::iterator it = alternative_service_map.Get(server);
|
| ASSERT_NE(alternative_service_map.end(), it);
|
| AlternativeServiceInfoVector alternative_service_info_vector = it->second;
|
| ASSERT_EQ(3u, alternative_service_info_vector.size());
|
| @@ -1190,9 +1229,9 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(valid_alternative_service, time_one_day_later));
|
|
|
| - const HostPortPair host_port_pair("www.example.com", 443);
|
| + const url::SchemeHostPort server("https", "www.example.com", 443);
|
| http_server_props_manager_->SetAlternativeServices(
|
| - host_port_pair, alternative_service_info_vector);
|
| + server, alternative_service_info_vector);
|
|
|
| // Update cache.
|
| ExpectPrefsUpdate();
|
| @@ -1210,8 +1249,9 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict));
|
|
|
| const base::DictionaryValue* example_pref_dict;
|
| +
|
| ASSERT_TRUE(server_pref_dict->GetDictionaryWithoutPathExpansion(
|
| - "www.example.com:443", &example_pref_dict));
|
| + "https://www.example.com", &example_pref_dict));
|
|
|
| const base::ListValue* altsvc_list;
|
| ASSERT_TRUE(example_pref_dict->GetList("alternative_service", &altsvc_list));
|
| @@ -1252,13 +1292,12 @@ TEST_P(HttpServerPropertiesManagerTest, DoNotLoadExpiredAlternativeService) {
|
| server_pref_dict.SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list.release());
|
|
|
| - const HostPortPair host_port_pair("example.com", 443);
|
| + const url::SchemeHostPort server("https", "example.com", 443);
|
| AlternativeServiceMap alternative_service_map(/*max_size=*/5);
|
| ASSERT_TRUE(http_server_props_manager_->AddToAlternativeServiceMap(
|
| - host_port_pair, server_pref_dict, &alternative_service_map));
|
| + server, server_pref_dict, &alternative_service_map));
|
|
|
| - AlternativeServiceMap::iterator it =
|
| - alternative_service_map.Get(host_port_pair);
|
| + AlternativeServiceMap::iterator it = alternative_service_map.Get(server);
|
| ASSERT_NE(alternative_service_map.end(), it);
|
| AlternativeServiceInfoVector alternative_service_info_vector = it->second;
|
| ASSERT_EQ(1u, alternative_service_info_vector.size());
|
|
|