| 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 54618729bd3db6928a0fd111f033486fd29e0e40..4256ae42b48205c0bc8ed687aa5b7b1b9c23ee66 100644
|
| --- a/net/http/http_server_properties_manager_unittest.cc
|
| +++ b/net/http/http_server_properties_manager_unittest.cc
|
| @@ -106,7 +106,11 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager {
|
|
|
| } // namespace
|
|
|
| -class HttpServerPropertiesManagerTest : public testing::Test {
|
| +// 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};
|
| +
|
| +class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> {
|
| protected:
|
| HttpServerPropertiesManagerTest() {}
|
|
|
| @@ -183,7 +187,11 @@ class HttpServerPropertiesManagerTest : public testing::Test {
|
| DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest);
|
| };
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest,
|
| +INSTANTIATE_TEST_CASE_P(Tests,
|
| + HttpServerPropertiesManagerTest,
|
| + ::testing::ValuesIn(kHttpServerPropertiesVersions));
|
| +
|
| +TEST_P(HttpServerPropertiesManagerTest,
|
| SingleUpdateForTwoSpdyServerPrefChanges) {
|
| ExpectCacheUpdate();
|
|
|
| @@ -218,6 +226,13 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| // Set the server preference for www.google.com:80.
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| + base::ListValue* servers_list = nullptr;
|
| + if (GetParam() == 4) {
|
| + servers_list = new base::ListValue;
|
| + // |servers_list| takes ownership of |servers_dict|.
|
| + servers_list->AppendIfNotPresent(servers_dict);
|
| + servers_dict = new base::DictionaryValue;
|
| + }
|
|
|
| // Set the preference for mail.google.com server.
|
| base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue;
|
| @@ -234,18 +249,27 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| server_pref_dict1->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list1);
|
|
|
| - // Set up ServerNetworkStats for mail.google.com:80.
|
| + // Set up ServerNetworkStats for 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);
|
| -
|
| base::DictionaryValue* http_server_properties_dict =
|
| new base::DictionaryValue;
|
| - HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
|
| - http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
|
| + if (GetParam() == 4) {
|
| + // |servers_list| takes ownership of |servers_dict|.
|
| + servers_list->AppendIfNotPresent(servers_dict);
|
| + HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_list);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(http_server_properties_dict,
|
| + GetParam());
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_dict);
|
| + }
|
| base::DictionaryValue* supports_quic = new base::DictionaryValue;
|
| supports_quic->SetBoolean("used_quic", true);
|
| supports_quic->SetString("address", "127.0.0.1");
|
| @@ -292,24 +316,46 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| HostPortPair::FromString("foo.google.com:1337")));
|
|
|
| // Verify alternative service.
|
| - const AlternativeServiceMap& map =
|
| - http_server_props_manager_->alternative_service_map();
|
| - ASSERT_EQ(2u, map.size());
|
| - AlternativeServiceMap::const_iterator map_it = map.begin();
|
| - EXPECT_EQ("www.google.com", map_it->first.host());
|
| - ASSERT_EQ(2u, map_it->second.size());
|
| - EXPECT_EQ(NPN_HTTP_2, map_it->second[0].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| - EXPECT_EQ(443, map_it->second[0].alternative_service.port);
|
| - EXPECT_EQ(QUIC, map_it->second[1].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[1].alternative_service.host.empty());
|
| - EXPECT_EQ(1234, map_it->second[1].alternative_service.port);
|
| - ++map_it;
|
| - EXPECT_EQ("mail.google.com", map_it->first.host());
|
| - ASSERT_EQ(1u, map_it->second.size());
|
| - EXPECT_EQ(NPN_SPDY_3_1, map_it->second[0].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| - EXPECT_EQ(444, map_it->second[0].alternative_service.port);
|
| + if (GetParam() == 4) {
|
| + const AlternativeServiceMap& map =
|
| + http_server_props_manager_->alternative_service_map();
|
| + ASSERT_EQ(2u, map.size());
|
| +
|
| + AlternativeServiceMap::const_iterator map_it = map.begin();
|
| + EXPECT_EQ("mail.google.com", map_it->first.host());
|
| + ASSERT_EQ(1u, map_it->second.size());
|
| + EXPECT_EQ(NPN_SPDY_3_1, map_it->second[0].alternative_service.protocol);
|
| + EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| + EXPECT_EQ(444, map_it->second[0].alternative_service.port);
|
| + ++map_it;
|
| + EXPECT_EQ("www.google.com", map_it->first.host());
|
| + ASSERT_EQ(2u, map_it->second.size());
|
| + EXPECT_EQ(NPN_HTTP_2, map_it->second[0].alternative_service.protocol);
|
| + EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| + EXPECT_EQ(443, map_it->second[0].alternative_service.port);
|
| + EXPECT_EQ(QUIC, map_it->second[1].alternative_service.protocol);
|
| + EXPECT_TRUE(map_it->second[1].alternative_service.host.empty());
|
| + EXPECT_EQ(1234, map_it->second[1].alternative_service.port);
|
| + } else {
|
| + const AlternativeServiceMap& map =
|
| + http_server_props_manager_->alternative_service_map();
|
| + ASSERT_EQ(2u, map.size());
|
| + AlternativeServiceMap::const_iterator map_it = map.begin();
|
| + EXPECT_EQ("www.google.com", map_it->first.host());
|
| + ASSERT_EQ(2u, map_it->second.size());
|
| + EXPECT_EQ(NPN_HTTP_2, map_it->second[0].alternative_service.protocol);
|
| + EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| + EXPECT_EQ(443, map_it->second[0].alternative_service.port);
|
| + EXPECT_EQ(QUIC, map_it->second[1].alternative_service.protocol);
|
| + EXPECT_TRUE(map_it->second[1].alternative_service.host.empty());
|
| + EXPECT_EQ(1234, map_it->second[1].alternative_service.port);
|
| + ++map_it;
|
| + EXPECT_EQ("mail.google.com", map_it->first.host());
|
| + ASSERT_EQ(1u, map_it->second.size());
|
| + EXPECT_EQ(NPN_SPDY_3_1, map_it->second[0].alternative_service.protocol);
|
| + EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| + EXPECT_EQ(444, map_it->second[0].alternative_service.port);
|
| + }
|
|
|
| // Verify SupportsQuic.
|
| IPAddressNumber last_address;
|
| @@ -331,7 +377,7 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| mail_quic_server_id));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| +TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| ExpectCacheUpdate();
|
| // The prefs are automaticalls updated in the case corruption is detected.
|
| ExpectPrefsUpdate();
|
| @@ -360,6 +406,21 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| servers_dict->SetWithoutPathExpansion("www.google.com:65536",
|
| server_pref_dict);
|
| + base::DictionaryValue* http_server_properties_dict =
|
| + new base::DictionaryValue;
|
| + 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);
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_list);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(http_server_properties_dict,
|
| + GetParam());
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_dict);
|
| + }
|
|
|
| // Set quic_server_info for www.google.com:65536.
|
| base::DictionaryValue* quic_servers_dict = new base::DictionaryValue;
|
| @@ -369,10 +430,6 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| quic_servers_dict->SetWithoutPathExpansion("http://mail.google.com:65536",
|
| quic_server_pref_dict1);
|
|
|
| - base::DictionaryValue* http_server_properties_dict =
|
| - new base::DictionaryValue;
|
| - HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
|
| - http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
|
| http_server_properties_dict->SetWithoutPathExpansion("quic_servers",
|
| quic_servers_dict);
|
|
|
| @@ -391,11 +448,11 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| const ServerNetworkStats* stats1 =
|
| http_server_props_manager_->GetServerNetworkStats(
|
| HostPortPair::FromString("www.google.com:65536"));
|
| - EXPECT_EQ(NULL, stats1);
|
| + EXPECT_EQ(nullptr, stats1);
|
| EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size());
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| +TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| ExpectCacheUpdate();
|
| // The prefs are automaticalls updated in the case corruption is detected.
|
| ExpectPrefsUpdate();
|
| @@ -418,11 +475,21 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| // Set the server preference for www.google.com:80.
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| -
|
| base::DictionaryValue* http_server_properties_dict =
|
| new base::DictionaryValue;
|
| - HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
|
| - http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
|
| + 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);
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_list);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(http_server_properties_dict,
|
| + GetParam());
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_dict);
|
| + }
|
|
|
| // Set up the pref.
|
| pref_service_.SetManagedPref(kTestHttpServerProperties,
|
| @@ -436,7 +503,7 @@ TEST_F(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| HasAlternativeService(HostPortPair::FromString("www.google.com:80")));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| +TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -459,7 +526,7 @@ TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) {
|
| +TEST_P(HttpServerPropertiesManagerTest, SetSpdySetting) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -486,7 +553,7 @@ TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ClearSpdySetting) {
|
| ExpectPrefsUpdateRepeatedly();
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| @@ -525,7 +592,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
|
| ExpectPrefsUpdateRepeatedly();
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| @@ -563,7 +630,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, GetAlternativeServices) {
|
| +TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -587,7 +654,7 @@ TEST_F(HttpServerPropertiesManagerTest, GetAlternativeServices) {
|
| EXPECT_EQ(alternative_service, alternative_service_vector[0]);
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| +TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -618,7 +685,7 @@ TEST_F(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[1]);
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {
|
| +TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {
|
| HostPortPair spdy_server_mail("mail.google.com", 80);
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com",
|
| @@ -634,7 +701,7 @@ TEST_F(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ClearAlternativeServices) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ClearAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -655,7 +722,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearAlternativeServices) {
|
| EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
|
| ExpectPrefsUpdate();
|
|
|
| HostPortPair spdy_server_mail("mail.google.com", 80);
|
| @@ -701,7 +768,7 @@ TEST_F(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
|
| alternative_service));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) {
|
| +TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -722,14 +789,14 @@ TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) {
|
| EXPECT_EQ(actual_address, address);
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ServerNetworkStats) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| HostPortPair mail_server("mail.google.com", 80);
|
| const ServerNetworkStats* stats =
|
| http_server_props_manager_->GetServerNetworkStats(mail_server);
|
| - EXPECT_EQ(NULL, stats);
|
| + EXPECT_EQ(nullptr, stats);
|
| ServerNetworkStats stats1;
|
| stats1.srtt = base::TimeDelta::FromMicroseconds(10);
|
| http_server_props_manager_->SetServerNetworkStats(mail_server, stats1);
|
| @@ -745,7 +812,7 @@ TEST_F(HttpServerPropertiesManagerTest, ServerNetworkStats) {
|
| EXPECT_EQ(10, stats2->srtt.ToInternalValue());
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, QuicServerInfo) {
|
| +TEST_P(HttpServerPropertiesManagerTest, QuicServerInfo) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| @@ -767,7 +834,7 @@ TEST_F(HttpServerPropertiesManagerTest, QuicServerInfo) {
|
| mail_quic_server_id));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, Clear) {
|
| +TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| @@ -833,7 +900,7 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) {
|
| EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address));
|
| const ServerNetworkStats* stats2 =
|
| http_server_props_manager_->GetServerNetworkStats(spdy_server_mail);
|
| - EXPECT_EQ(NULL, stats2);
|
| + EXPECT_EQ(nullptr, stats2);
|
| EXPECT_EQ(nullptr,
|
| http_server_props_manager_->GetQuicServerInfo(mail_quic_server_id));
|
|
|
| @@ -846,10 +913,13 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) {
|
|
|
| // https://crbug.com/444956: Add 200 alternative_service servers followed by
|
| // supports_quic and verify we have read supports_quic from prefs.
|
| -TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| +TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| ExpectCacheUpdate();
|
|
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| + base::ListValue* servers_list = nullptr;
|
| + if (GetParam() == 4)
|
| + servers_list = new base::ListValue;
|
|
|
| for (int i = 0; i < 200; ++i) {
|
| // Set up alternative_service for www.google.com:i.
|
| @@ -861,8 +931,16 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| server_pref_dict->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list);
|
| - servers_dict->SetWithoutPathExpansion(StringPrintf("www.google.com:%d", i),
|
| - server_pref_dict);
|
| + if (GetParam() == 4) {
|
| + servers_dict->SetWithoutPathExpansion(
|
| + StringPrintf("www.google.com:%d", i), server_pref_dict);
|
| + // |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.
|
| @@ -871,11 +949,20 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| // Set the server preference for mail.google.com:80.
|
| servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| server_pref_dict1);
|
| -
|
| base::DictionaryValue* http_server_properties_dict =
|
| new base::DictionaryValue;
|
| - HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
|
| - http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
|
| + if (GetParam() == 4) {
|
| + // |servers_list| takes ownership of |servers_dict|.
|
| + servers_list->AppendIfNotPresent(servers_dict);
|
| + HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_list);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(http_server_properties_dict,
|
| + GetParam());
|
| + http_server_properties_dict->SetWithoutPathExpansion("servers",
|
| + servers_dict);
|
| + }
|
|
|
| // Set up SupportsQuic for 127.0.0.1
|
| base::DictionaryValue* supports_quic = new base::DictionaryValue;
|
| @@ -908,7 +995,7 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| EXPECT_EQ("127.0.0.1", IPAddressToString(address));
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| +TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| const HostPortPair server_www("www.google.com", 80);
|
| @@ -962,16 +1049,19 @@ TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| const char expected_json[] =
|
| "{\"quic_servers\":{\"https://"
|
| "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}},"
|
| - "\"servers\":{\"mail.google.com:80\":{\"alternative_service\":[{"
|
| - "\"expiration\":\"9223372036854775807\",\"host\":\"foo.google.com\","
|
| - "\"port\":444,\"probability\":0.2,\"protocol_str\":\"npn-spdy/3.1\"}],"
|
| - "\"network_stats\":{\"srtt\":42}},\"www.google.com:80\":{"
|
| + "\"servers\":["
|
| + "{\"www.google.com:80\":{"
|
| "\"alternative_service\":[{\"expiration\":\"13756212000000000\","
|
| "\"port\":443,\"probability\":1.0,\"protocol_str\":\"npn-h2\"},"
|
| "{\"expiration\":\"13758804000000000\",\"host\":\"www.google.com\","
|
| "\"port\":1234,\"probability\":0.7,\"protocol_str\":\"npn-h2\"}]}},"
|
| + "{\"mail.google.com:80\":{\"alternative_service\":[{"
|
| + "\"expiration\":\"9223372036854775807\",\"host\":\"foo.google.com\","
|
| + "\"port\":444,\"probability\":0.2,\"protocol_str\":\"npn-spdy/3.1\"}],"
|
| + "\"network_stats\":{\"srtt\":42}}}"
|
| + "],"
|
| "\"supports_quic\":{\"address\":\"127.0.0.1\",\"used_quic\":true},"
|
| - "\"version\":3}";
|
| + "\"version\":4}";
|
|
|
| const base::Value* http_server_properties =
|
| pref_service_.GetUserPref(kTestHttpServerProperties);
|
| @@ -982,7 +1072,7 @@ TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| EXPECT_EQ(expected_json, preferences_json);
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
|
| +TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
|
| scoped_ptr<base::Value> server_value = base::JSONReader::Read(
|
| "{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"npn-h2\"},"
|
| "{\"port\":123,\"protocol_str\":\"quic\",\"probability\":0.7,"
|
| @@ -1037,7 +1127,7 @@ TEST_F(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
|
| }
|
|
|
| // Do not persist expired or broken alternative service entries to disk.
|
| -TEST_F(HttpServerPropertiesManagerTest,
|
| +TEST_P(HttpServerPropertiesManagerTest,
|
| DoNotPersistExpiredOrBrokenAlternativeService) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| @@ -1081,8 +1171,11 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| const base::DictionaryValue* pref_dict;
|
| ASSERT_TRUE(pref_value->GetAsDictionary(&pref_dict));
|
|
|
| + const base::ListValue* servers_list = nullptr;
|
| + ASSERT_TRUE(pref_dict->GetListWithoutPathExpansion("servers", &servers_list));
|
| + base::ListValue::const_iterator it = servers_list->begin();
|
| const base::DictionaryValue* server_pref_dict;
|
| - ASSERT_TRUE(pref_dict->GetDictionary("servers", &server_pref_dict));
|
| + ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict));
|
|
|
| const base::DictionaryValue* example_pref_dict;
|
| ASSERT_TRUE(server_pref_dict->GetDictionaryWithoutPathExpansion(
|
| @@ -1102,7 +1195,7 @@ TEST_F(HttpServerPropertiesManagerTest,
|
| }
|
|
|
| // Test that expired alternative service entries on disk are ignored.
|
| -TEST_F(HttpServerPropertiesManagerTest, DoNotLoadExpiredAlternativeService) {
|
| +TEST_P(HttpServerPropertiesManagerTest, DoNotLoadExpiredAlternativeService) {
|
| scoped_ptr<base::ListValue> alternative_service_list(new base::ListValue);
|
| base::DictionaryValue* expired_dict = new base::DictionaryValue;
|
| expired_dict->SetString("protocol_str", "npn-h2");
|
| @@ -1148,7 +1241,7 @@ TEST_F(HttpServerPropertiesManagerTest, DoNotLoadExpiredAlternativeService) {
|
| EXPECT_EQ(one_day_from_now_, alternative_service_info_vector[0].expiration);
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) {
|
| // Post an update task to the UI thread.
|
| http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
|
| // Shutdown comes before the task is executed.
|
| @@ -1158,7 +1251,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) {
|
| // Post an update task.
|
| http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
|
| // Shutdown comes before the task is executed.
|
| @@ -1170,7 +1263,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) {
|
| http_server_props_manager_->UpdateCacheFromPrefsOnUIConcrete();
|
| // Shutdown comes before the task is executed.
|
| http_server_props_manager_->ShutdownOnPrefThread();
|
| @@ -1184,7 +1277,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) {
|
| //
|
| // Tests for shutdown when updating prefs.
|
| //
|
| -TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) {
|
| // Post an update task to the IO thread.
|
| http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread();
|
| // Shutdown comes before the task is executed.
|
| @@ -1194,7 +1287,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
|
| ExpectPrefsUpdate();
|
| // Post an update task.
|
| http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread();
|
| @@ -1207,7 +1300,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| -TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) {
|
| +TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) {
|
| // This posts a task to the UI thread.
|
| http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete(
|
| base::Closure());
|
|
|