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

Unified Diff: net/http/http_server_properties_manager_unittest.cc

Issue 893403005: Add HttpServerPropertiesManagerTest.UpdateCacheWithPrefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | 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_manager_unittest.cc
diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc
index cbc2275e6da29da6f22d24f1ae9d43c05aa6976a..df39dc6718d04bf19b5307d8369901ba8bd5dc06 100644
--- a/net/http/http_server_properties_manager_unittest.cc
+++ b/net/http/http_server_properties_manager_unittest.cc
@@ -668,6 +668,97 @@ TEST_F(HttpServerPropertiesManagerTest, BadSupportsQuic) {
EXPECT_EQ("bar", supports_quic1.address);
}
+TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
+ const HostPortPair server_www("www.google.com", 80);
+ const HostPortPair server_mail("mail.google.com", 80);
+
+ // Set alternate protocol.
+ http_server_props_manager_->SetAlternateProtocol(server_www, 443, NPN_SPDY_3,
+ 1.0);
+ http_server_props_manager_->SetAlternateProtocol(server_mail, 444,
+ NPN_SPDY_3_1, 0.2);
+
+ // Set SupportsQuic.
+ http_server_props_manager_->SetSupportsQuic(server_www, true, "foo");
+
+ // Set ServerNetworkStats.
+ ServerNetworkStats stats;
+ stats.srtt = base::TimeDelta::FromInternalValue(42);
+ http_server_props_manager_->SetServerNetworkStats(server_mail, stats);
+
+ ExpectPrefsUpdate();
+ ExpectCacheUpdate();
+ http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
+ base::RunLoop().RunUntilIdle();
+
+ const base::Value* http_server_properties =
+ pref_service_.GetUserPref(kTestHttpServerProperties);
Ryan Hamilton 2015/02/04 22:33:29 Oh nice! This is great. I do wonder if we can make
Bence 2015/02/05 14:53:24 Done.
+ ASSERT_NE(nullptr, http_server_properties);
+ const base::DictionaryValue* http_server_properties_dict =
+ new base::DictionaryValue;
+ ASSERT_TRUE(
+ http_server_properties->GetAsDictionary(&http_server_properties_dict));
+ const base::DictionaryValue* servers_dict = new base::DictionaryValue;
+ ASSERT_TRUE(
+ http_server_properties_dict->GetDictionary("servers", &servers_dict));
+ ASSERT_EQ(2u, servers_dict->size());
+
+ // Verify alternate protocol.
+ const base::DictionaryValue* www_prefs_dict = new base::DictionaryValue;
+ ASSERT_TRUE(servers_dict->GetDictionaryWithoutPathExpansion(
+ "www.google.com:80", &www_prefs_dict));
+ const base::DictionaryValue* www_altproto_dict = new base::DictionaryValue;
+ ASSERT_TRUE(
+ www_prefs_dict->GetDictionary("alternate_protocol", &www_altproto_dict));
+ int port;
+ ASSERT_TRUE(www_altproto_dict->GetInteger("port", &port));
+ EXPECT_EQ(443, port);
+ std::string protocol_str;
+ ASSERT_TRUE(www_altproto_dict->GetString("protocol_str", &protocol_str));
+ EXPECT_EQ("npn-spdy/3", protocol_str);
+ double probability;
+ ASSERT_TRUE(www_altproto_dict->GetDouble("probability", &probability));
+ EXPECT_EQ(1.0, probability);
+
+ const base::DictionaryValue* mail_prefs_dict = new base::DictionaryValue;
+ ASSERT_TRUE(servers_dict->GetDictionaryWithoutPathExpansion(
+ "mail.google.com:80", &mail_prefs_dict));
+ const base::DictionaryValue* mail_altproto_dict = new base::DictionaryValue;
+ ASSERT_TRUE(mail_prefs_dict->GetDictionary("alternate_protocol",
+ &mail_altproto_dict));
+ ASSERT_TRUE(mail_altproto_dict->GetInteger("port", &port));
+ EXPECT_EQ(444, port);
+ ASSERT_TRUE(mail_altproto_dict->GetString("protocol_str", &protocol_str));
+ EXPECT_EQ("npn-spdy/3.1", protocol_str);
+ ASSERT_TRUE(mail_altproto_dict->GetDouble("probability", &probability));
+ EXPECT_EQ(0.2, probability);
+
+ // Verify SupportsQuic.
+ const base::DictionaryValue* supports_quic_dict = new base::DictionaryValue;
+ ASSERT_TRUE(
+ www_prefs_dict->GetDictionary("supports_quic", &supports_quic_dict));
+ bool used_quic;
+ ASSERT_TRUE(supports_quic_dict->GetBoolean("used_quic", &used_quic));
+ EXPECT_TRUE(used_quic);
+ std::string address;
+ ASSERT_TRUE(supports_quic_dict->GetString("address", &address));
+ EXPECT_EQ("foo", address);
+
+ ASSERT_FALSE(mail_prefs_dict->GetDictionaryWithoutPathExpansion(
+ "supports_quic", &supports_quic_dict));
Ryan Hamilton 2015/02/04 22:33:29 I have a CL in flight which changes the supports q
Bence 2015/02/05 14:53:24 Rebased, changed test to adapt to your CL. Done.
+
+ // Verify ServerNetworkStats.
+ const base::DictionaryValue* stats_dict = new base::DictionaryValue;
+ ASSERT_FALSE(www_prefs_dict->GetDictionaryWithoutPathExpansion(
+ "network_stats", &stats_dict));
+
+ ASSERT_TRUE(mail_prefs_dict->GetDictionaryWithoutPathExpansion(
+ "network_stats", &stats_dict));
+ int srtt;
+ ASSERT_TRUE(stats_dict->GetInteger("srtt", &srtt));
+ EXPECT_EQ(42, srtt);
+}
+
TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) {
// Post an update task to the UI thread.
http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698