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

Unified Diff: net/http/http_server_properties_impl_unittest.cc

Issue 180743026: Relanding 255326 "HttpServerProperties - Implement MRU for AlternateProtocolMap. Persist" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Erase to fix compilation error Created 6 years, 9 months 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') | net/http/http_stream_factory_impl.h » ('j') | 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 0ab132d8107b160bcb4d7c994045577d7c9b4c32..abd48b87bd7daafc8b4c0d77af1f11ab85875439 100644
--- a/net/http/http_server_properties_impl_unittest.cc
+++ b/net/http/http_server_properties_impl_unittest.cc
@@ -206,13 +206,27 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
HostPortPair test_host_port_pair2("foo2", 80);
impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3);
- AlternateProtocolMap alternate_protocol_map;
+ AlternateProtocolMap alternate_protocol_map(
+ AlternateProtocolMap::NO_AUTO_EVICT);
PortAlternateProtocolPair port_alternate_protocol_pair;
port_alternate_protocol_pair.port = 123;
port_alternate_protocol_pair.protocol = NPN_SPDY_3;
- alternate_protocol_map[test_host_port_pair2] = port_alternate_protocol_pair;
+ alternate_protocol_map.Put(test_host_port_pair2,
+ port_alternate_protocol_pair);
+ HostPortPair test_host_port_pair3("foo3", 80);
+ port_alternate_protocol_pair.port = 1234;
+ alternate_protocol_map.Put(test_host_port_pair3,
+ port_alternate_protocol_pair);
impl_.InitializeAlternateProtocolServers(&alternate_protocol_map);
+ // Verify test_host_port_pair3 is the MRU server.
+ const net::AlternateProtocolMap& map = impl_.alternate_protocol_map();
+ net::AlternateProtocolMap::const_iterator it = map.begin();
+ it = map.begin();
+ EXPECT_TRUE(it->first.Equals(test_host_port_pair3));
+ 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));
port_alternate_protocol_pair =
@@ -224,6 +238,49 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol_pair.protocol);
}
+TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) {
+ HostPortPair test_host_port_pair1("foo1", 80);
+ impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3);
+ HostPortPair test_host_port_pair2("foo2", 80);
+ impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3);
+
+ const net::AlternateProtocolMap& map = impl_.alternate_protocol_map();
+ net::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 reoder 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);
+ HostPortPair test_host_port_pair2("foo2", 80);
+ impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3);
+
+ const net::AlternateProtocolMap& map = impl_.alternate_protocol_map();
+ net::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);
+
+ // GetAlternateProtocol should reoder the AlternateProtocol map.
+ PortAlternateProtocolPair alternate =
+ impl_.GetAlternateProtocol(test_host_port_pair1);
+ EXPECT_EQ(443, alternate.port);
+ EXPECT_EQ(NPN_SPDY_3, alternate.protocol);
+ 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, SetBroken) {
HostPortPair test_host_port_pair("foo", 80);
impl_.SetBrokenAlternateProtocol(test_host_port_pair);
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698