Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: net/http/http_server_properties_impl_unittest.cc

Issue 1531943003: Changes to AlternativeServices initialization to maintain MRU order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_spdy_settings_mru_cache
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e540648cfa2582e49364e0c5a69d37415a300370..ca9040650f138aedc9525e043bdfc65a2ee52d02 100644
--- a/net/http/http_server_properties_impl_unittest.cc
+++ b/net/http/http_server_properties_impl_unittest.cc
@@ -376,6 +376,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
const AlternativeService alternative_service1(NPN_HTTP_2, "bar1", 443);
const base::Time now = base::Time::Now();
base::Time expiration1 = now + base::TimeDelta::FromDays(1);
+ // 1st entry in the memory.
impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 1.0,
expiration1);
@@ -389,6 +390,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
alternative_service_info_vector.push_back(
AlternativeServiceInfo(alternative_service2, 1.0, expiration2));
HostPortPair test_host_port_pair2("foo2", 80);
+ // 0th entry in the memory.
impl_.SetAlternativeServices(test_host_port_pair2,
alternative_service_info_vector);
@@ -400,6 +402,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
base::Time expiration3 = now + base::TimeDelta::FromDays(3);
const AlternativeServiceInfo alternative_service_info1(alternative_service3,
0.7, expiration3);
+ // Simulate updating data for 0th entry with data from Preferences.
alternative_service_map.Put(
test_host_port_pair2,
AlternativeServiceInfoVector(/*size=*/1, alternative_service_info1));
@@ -409,22 +412,21 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
base::Time expiration4 = now + base::TimeDelta::FromDays(4);
const AlternativeServiceInfo alternative_service_info2(alternative_service4,
0.2, expiration4);
+ // Add an old entry from Preferences, this will be added to end of recency
+ // list.
alternative_service_map.Put(
test_host_port_pair3,
AlternativeServiceInfoVector(/*size=*/1, alternative_service_info2));
+ // MRU list will be test_host_port_pair2, test_host_port_pair1,
+ // test_host_port_pair3.
impl_.InitializeAlternativeServiceServers(&alternative_service_map);
// Verify alternative_service_map.
const AlternativeServiceMap& map = impl_.alternative_service_map();
ASSERT_EQ(3u, map.size());
AlternativeServiceMap::const_iterator map_it = map.begin();
- EXPECT_TRUE(map_it->first.Equals(test_host_port_pair3));
- ASSERT_EQ(1u, map_it->second.size());
- EXPECT_EQ(alternative_service4, map_it->second[0].alternative_service);
- EXPECT_EQ(0.2, map_it->second[0].probability);
- EXPECT_EQ(expiration4, map_it->second[0].expiration);
- ++map_it;
+
EXPECT_TRUE(map_it->first.Equals(test_host_port_pair2));
ASSERT_EQ(1u, map_it->second.size());
EXPECT_EQ(alternative_service3, map_it->second[0].alternative_service);
@@ -436,6 +438,12 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
EXPECT_EQ(alternative_service1, map_it->second[0].alternative_service);
EXPECT_EQ(1.0, map_it->second[0].probability);
EXPECT_EQ(expiration1, map_it->second[0].expiration);
+ ++map_it;
+ EXPECT_TRUE(map_it->first.Equals(test_host_port_pair3));
+ ASSERT_EQ(1u, map_it->second.size());
+ EXPECT_EQ(alternative_service4, map_it->second[0].alternative_service);
+ EXPECT_EQ(0.2, map_it->second[0].probability);
+ EXPECT_EQ(expiration4, map_it->second[0].expiration);
}
// Regression test for https://crbug.com/504032:
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698