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

Unified Diff: net/http/http_alternate_protocols_unittest.cc

Issue 3195015: Add option to simulate alternate protocol always being present.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
Index: net/http/http_alternate_protocols_unittest.cc
===================================================================
--- net/http/http_alternate_protocols_unittest.cc (revision 57015)
+++ net/http/http_alternate_protocols_unittest.cc (working copy)
@@ -44,5 +44,42 @@
<< "Second attempt should be ignored.";
}
+TEST(HttpAlternateProtocols, Forced) {
+ // Test forced alternate protocols.
+
+ HttpAlternateProtocols::PortProtocolPair default_protocol;
+ default_protocol.port = 1234;
+ default_protocol.protocol = HttpAlternateProtocols::NPN_SPDY_2;
+ HttpAlternateProtocols::ForceAlternateProtocol(default_protocol);
+
+ HttpAlternateProtocols alternate_protocols;
+
+ // Verify the forced protocol.
+ HostPortPair test_host_port_pair("foo", 80);
+ EXPECT_TRUE(
+ alternate_protocols.HasAlternateProtocolFor(test_host_port_pair));
+ HttpAlternateProtocols::PortProtocolPair alternate =
+ alternate_protocols.GetAlternateProtocolFor(test_host_port_pair);
+ EXPECT_EQ(default_protocol.port, alternate.port);
+ EXPECT_EQ(default_protocol.protocol, alternate.protocol);
+
+ // Verify the real protocol overrides the forced protocol.
+ alternate_protocols.SetAlternateProtocolFor(
+ test_host_port_pair, 443, HttpAlternateProtocols::NPN_SPDY_1);
+ ASSERT_TRUE(alternate_protocols.HasAlternateProtocolFor(test_host_port_pair));
+ alternate = alternate_protocols.GetAlternateProtocolFor(test_host_port_pair);
+ EXPECT_EQ(443, alternate.port);
+ EXPECT_EQ(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol);
+
+ // Turn off the static, forced alternate protocol so that tests don't
+ // have this state.
+ HttpAlternateProtocols::DisableForcedAlternateProtocol();
+
+ // Verify the forced protocol is off.
+ HostPortPair test_host_port_pair2("bar", 80);
+ EXPECT_FALSE(
+ alternate_protocols.HasAlternateProtocolFor(test_host_port_pair2));
+}
+
} // namespace
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698