diff options
author | rtenneti <rtenneti@chromium.org> | 2014-09-25 11:39:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-25 18:40:59 +0000 |
commit | 1c863aa414026f2ece4ce5b930bcbce1cd07d6f0 (patch) | |
tree | e1b8661ab42975a7da8aeba583d0c4a7fe725f6f /net/http/http_server_properties_manager_unittest.cc | |
parent | 5b07d9f661d67fbb6e76ad8a0c967a613c31f615 (diff) | |
download | chromium_src-1c863aa414026f2ece4ce5b930bcbce1cd07d6f0.zip chromium_src-1c863aa414026f2ece4ce5b930bcbce1cd07d6f0.tar.gz chromium_src-1c863aa414026f2ece4ce5b930bcbce1cd07d6f0.tar.bz2 |
QUIC - Code to persist if we had talked QUIC to a server and if so what
is the address.
This code is not hooked up into QUIC code yet. Will submit that in
the next CL.
R=rch@chromium.org
Review URL: https://codereview.chromium.org/605563003
Cr-Commit-Position: refs/heads/master@{#296749}
Diffstat (limited to 'net/http/http_server_properties_manager_unittest.cc')
-rw-r--r-- | net/http/http_server_properties_manager_unittest.cc | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index ad2a08b..012a46d 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc @@ -67,16 +67,18 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager { MOCK_METHOD0(UpdateCacheFromPrefsOnPrefThread, void()); MOCK_METHOD1(UpdatePrefsFromCacheOnNetworkThread, void(const base::Closure&)); - MOCK_METHOD5(UpdateCacheFromPrefsOnNetworkThread, + MOCK_METHOD6(UpdateCacheFromPrefsOnNetworkThread, void(std::vector<std::string>* spdy_servers, net::SpdySettingsMap* spdy_settings_map, net::AlternateProtocolMap* alternate_protocol_map, net::AlternateProtocolExperiment experiment, + net::SupportsQuicMap* supports_quic_map, bool detected_corrupted_prefs)); - MOCK_METHOD3(UpdatePrefsOnPref, + MOCK_METHOD4(UpdatePrefsOnPref, void(base::ListValue* spdy_server_list, net::SpdySettingsMap* spdy_settings_map, - net::AlternateProtocolMap* alternate_protocol_map)); + net::AlternateProtocolMap* alternate_protocol_map, + net::SupportsQuicMap* supports_quic_map)); private: DISALLOW_COPY_AND_ASSIGN(TestingHttpServerPropertiesManager); @@ -155,6 +157,12 @@ TEST_F(HttpServerPropertiesManagerTest, server_pref_dict->SetWithoutPathExpansion("alternate_protocol", alternate_protocol); + // Set up SupportsQuic for www.google.com:80. + base::DictionaryValue* supports_quic = new base::DictionaryValue; + supports_quic->SetBoolean("used_quic", true); + supports_quic->SetString("address", "foo"); + server_pref_dict->SetWithoutPathExpansion("supports_quic", supports_quic); + // 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); @@ -173,6 +181,12 @@ TEST_F(HttpServerPropertiesManagerTest, server_pref_dict1->SetWithoutPathExpansion("alternate_protocol", alternate_protocol1); + // Set up SupportsQuic for mail.google.com:80 + base::DictionaryValue* supports_quic1 = new base::DictionaryValue; + supports_quic1->SetBoolean("used_quic", false); + supports_quic1->SetString("address", "bar"); + server_pref_dict1->SetWithoutPathExpansion("supports_quic", supports_quic1); + // Set the server preference for mail.google.com:80. servers_dict->SetWithoutPathExpansion("mail.google.com:80", server_pref_dict1); @@ -215,6 +229,17 @@ TEST_F(HttpServerPropertiesManagerTest, net::HostPortPair::FromString("mail.google.com:80")); EXPECT_EQ(444, port_alternate_protocol.port); EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocol.protocol); + + // Verify SupportsQuic. + net::SupportsQuic supports_quic2 = + http_server_props_manager_->GetSupportsQuic( + net::HostPortPair::FromString("www.google.com:80")); + EXPECT_TRUE(supports_quic2.used_quic); + EXPECT_EQ("foo", supports_quic2.address); + supports_quic2 = http_server_props_manager_->GetSupportsQuic( + net::HostPortPair::FromString("mail.google.com:80")); + EXPECT_FALSE(supports_quic2.used_quic); + EXPECT_EQ("bar", supports_quic2.address); } TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) { @@ -357,6 +382,26 @@ TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); } +TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { + ExpectPrefsUpdate(); + + net::HostPortPair quic_server_mail("mail.google.com", 80); + net::SupportsQuic supports_quic = http_server_props_manager_->GetSupportsQuic( + quic_server_mail); + EXPECT_FALSE(supports_quic.used_quic); + EXPECT_EQ("", supports_quic.address); + http_server_props_manager_->SetSupportsQuic(quic_server_mail, true, "foo"); + + // Run the task. + base::RunLoop().RunUntilIdle(); + Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); + + net::SupportsQuic supports_quic1 = + http_server_props_manager_->GetSupportsQuic(quic_server_mail); + EXPECT_TRUE(supports_quic1.used_quic); + EXPECT_EQ("foo", supports_quic1.address); +} + TEST_F(HttpServerPropertiesManagerTest, Clear) { ExpectPrefsUpdate(); @@ -364,6 +409,7 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) { http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); http_server_props_manager_->SetAlternateProtocol( spdy_server_mail, 443, net::NPN_SPDY_3, 1); + http_server_props_manager_->SetSupportsQuic(spdy_server_mail, true, "foo"); const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; @@ -377,6 +423,10 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) { EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); EXPECT_TRUE( http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); + net::SupportsQuic supports_quic = http_server_props_manager_->GetSupportsQuic( + spdy_server_mail); + EXPECT_TRUE(supports_quic.used_quic); + EXPECT_EQ("foo", supports_quic.address); // Check SPDY settings values. const net::SettingsMap& settings_map1_ret = @@ -399,6 +449,10 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) { EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail)); EXPECT_FALSE( http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); + net::SupportsQuic supports_quic1 = + http_server_props_manager_->GetSupportsQuic(spdy_server_mail); + EXPECT_FALSE(supports_quic1.used_quic); + EXPECT_EQ("", supports_quic1.address); const net::SettingsMap& settings_map2_ret = http_server_props_manager_->GetSpdySettings(spdy_server_mail); |