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

Unified Diff: chrome/browser/net/http_server_properties_manager_unittest.cc

Issue 8423028: Persist dynamically learned SPDY settings (like CWND). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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: chrome/browser/net/http_server_properties_manager_unittest.cc
===================================================================
--- chrome/browser/net/http_server_properties_manager_unittest.cc (revision 109764)
+++ chrome/browser/net/http_server_properties_manager_unittest.cc (working copy)
@@ -34,68 +34,41 @@
virtual ~TestingHttpServerPropertiesManager() {
}
- // Make these method public for testing.
- using HttpServerPropertiesManager::ScheduleUpdateSpdyCacheOnUI;
- using HttpServerPropertiesManager::ScheduleUpdateSpdyPrefsOnIO;
- using HttpServerPropertiesManager::ScheduleUpdateAlternateProtocolCacheOnUI;
- using HttpServerPropertiesManager::ScheduleUpdateAlternateProtocolPrefsOnIO;
+ // Make these methods public for testing.
+ using HttpServerPropertiesManager::ScheduleUpdateCacheOnUI;
+ using HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO;
// Post tasks without a delay during tests.
- virtual void StartSpdyPrefsUpdateTimerOnIO(base::TimeDelta delay) OVERRIDE {
- HttpServerPropertiesManager::StartSpdyPrefsUpdateTimerOnIO(
+ virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay) OVERRIDE {
+ HttpServerPropertiesManager::StartPrefsUpdateTimerOnIO(
base::TimeDelta());
}
- // Post tasks without a delay during tests.
- virtual void StartAlternateProtocolPrefsUpdateTimerOnIO(
- base::TimeDelta delay) OVERRIDE {
- HttpServerPropertiesManager::StartAlternateProtocolPrefsUpdateTimerOnIO(
- base::TimeDelta());
+ void UpdateCacheFromPrefsOnUIConcrete() {
+ HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI();
}
- void UpdateSpdyCacheFromPrefsConcrete() {
- HttpServerPropertiesManager::UpdateSpdyCacheFromPrefs();
- }
-
- void UpdateAlternateProtocolCacheFromPrefsConcrete() {
- HttpServerPropertiesManager::UpdateAlternateProtocolCacheFromPrefs();
- }
-
// Post tasks without a delay during tests.
- virtual void StartSpdyCacheUpdateTimerOnUI(base::TimeDelta delay) OVERRIDE {
- HttpServerPropertiesManager::StartSpdyCacheUpdateTimerOnUI(
+ virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay) OVERRIDE {
+ HttpServerPropertiesManager::StartCacheUpdateTimerOnUI(
base::TimeDelta());
}
- // Post tasks without a delay during tests.
- virtual void StartAlternateProtocolCacheUpdateTimerOnUI(
- base::TimeDelta delay) OVERRIDE {
- HttpServerPropertiesManager::StartAlternateProtocolCacheUpdateTimerOnUI(
- base::TimeDelta());
+ void UpdatePrefsFromCacheOnIOConcrete() {
+ HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO();
}
- void UpdateSpdyPrefsFromCacheConcrete() {
- HttpServerPropertiesManager::UpdateSpdyPrefsFromCache();
- }
+ MOCK_METHOD0(UpdateCacheFromPrefsOnUI, void());
+ MOCK_METHOD0(UpdatePrefsFromCacheOnIO, void());
+ MOCK_METHOD3(UpdateCacheFromPrefsOnIO,
+ void(std::vector<std::string>* spdy_servers,
+ net::SpdySettingsMap* spdy_settings_map,
+ net::AlternateProtocolMap* alternate_protocol_map));
+ MOCK_METHOD3(UpdatePrefsOnUI,
+ void(base::ListValue* spdy_server_list,
+ net::SpdySettingsMap* spdy_settings_map,
+ net::AlternateProtocolMap* alternate_protocol_map));
- void UpdateAlternateProtocolPrefsFromCacheConcrete() {
- HttpServerPropertiesManager::UpdateAlternateProtocolPrefsFromCache();
- }
-
- MOCK_METHOD0(UpdateSpdyCacheFromPrefs, void());
- MOCK_METHOD0(UpdateSpdyPrefsFromCache, void());
- MOCK_METHOD2(UpdateSpdyCacheFromPrefsOnIO,
- void(std::vector<std::string>* spdy_servers, bool support_spdy));
- MOCK_METHOD1(SetSpdyServersInPrefsOnUI,
- void(scoped_refptr<RefCountedListValue> spdy_server_list));
-
- MOCK_METHOD0(UpdateAlternateProtocolCacheFromPrefs, void());
- MOCK_METHOD0(UpdateAlternateProtocolPrefsFromCache, void());
- MOCK_METHOD1(UpdateAlternateProtocolCacheFromPrefsOnIO,
- void(RefCountedAlternateProtocolMap*));
- MOCK_METHOD1(SetAlternateProtocolServersInPrefsOnUI,
- void(RefCountedAlternateProtocolMap*));
-
private:
DISALLOW_COPY_AND_ASSIGN(TestingHttpServerPropertiesManager);
};
@@ -108,12 +81,10 @@
}
virtual void SetUp() OVERRIDE {
- pref_service_.RegisterListPref(prefs::kSpdyServers);
- pref_service_.RegisterDictionaryPref(prefs::kAlternateProtocolServers);
+ pref_service_.RegisterDictionaryPref(prefs::kHttpServerProperties);
http_server_props_manager_.reset(
new StrictMock<TestingHttpServerPropertiesManager>(&pref_service_));
- ExpectSpdyCacheUpdate();
- ExpectAlternateProtocolCacheUpdate();
+ ExpectCacheUpdate();
loop_.RunAllPending();
}
@@ -126,40 +97,22 @@
http_server_props_manager_.reset();
}
- void ExpectSpdyCacheUpdate() {
- EXPECT_CALL(*http_server_props_manager_, UpdateSpdyCacheFromPrefs())
+ void ExpectCacheUpdate() {
+ EXPECT_CALL(*http_server_props_manager_, UpdateCacheFromPrefsOnUI())
.WillOnce(
Invoke(http_server_props_manager_.get(),
&TestingHttpServerPropertiesManager::
- UpdateSpdyCacheFromPrefsConcrete));
+ UpdateCacheFromPrefsOnUIConcrete));
}
- void ExpectSpdyPrefsUpdate() {
- EXPECT_CALL(*http_server_props_manager_, UpdateSpdyPrefsFromCache())
+ void ExpectPrefsUpdate() {
+ EXPECT_CALL(*http_server_props_manager_, UpdatePrefsFromCacheOnIO())
.WillOnce(
Invoke(http_server_props_manager_.get(),
&TestingHttpServerPropertiesManager::
- UpdateSpdyPrefsFromCacheConcrete));
+ UpdatePrefsFromCacheOnIOConcrete));
}
- void ExpectAlternateProtocolCacheUpdate() {
- EXPECT_CALL(*http_server_props_manager_,
- UpdateAlternateProtocolCacheFromPrefs())
- .WillOnce(
- Invoke(http_server_props_manager_.get(),
- &TestingHttpServerPropertiesManager::
- UpdateAlternateProtocolCacheFromPrefsConcrete));
- }
-
- void ExpectAlternateProtocolPrefsUpdate() {
- EXPECT_CALL(*http_server_props_manager_,
- UpdateAlternateProtocolPrefsFromCache())
- .WillOnce(
- Invoke(http_server_props_manager_.get(),
- &TestingHttpServerPropertiesManager::
- UpdateAlternateProtocolPrefsFromCacheConcrete));
- }
-
MessageLoop loop_;
TestingPrefService pref_service_;
scoped_ptr<TestingHttpServerPropertiesManager> http_server_props_manager_;
@@ -171,32 +124,127 @@
DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest);
};
-TEST_F(HttpServerPropertiesManagerTest, SingleUpdateForTwoSpdyPrefChanges) {
- ExpectSpdyCacheUpdate();
+TEST_F(HttpServerPropertiesManagerTest,
+ SingleUpdateForTwoSpdyServerPrefChanges) {
+ ExpectCacheUpdate();
- // Set up the pref and then set it twice. Only expect a single cache update.
- base::ListValue* http_server_props = new base::ListValue;
- http_server_props->Append(new base::StringValue("www.google.com:443"));
- pref_service_.SetManagedPref(prefs::kSpdyServers, http_server_props);
- http_server_props = http_server_props->DeepCopy();
- http_server_props->Append(new base::StringValue("mail.google.com:443"));
- pref_service_.SetManagedPref(prefs::kSpdyServers, http_server_props);
+ // Set up the prefs for www.google.com:80 and mail.google.com:80 and then set
+ // it twice. Only expect a single cache update.
+
+ base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
+
+ // Set supports_spdy for www.google.com:80.
+ server_pref_dict->SetBoolean("supports_spdy", true);
+
+ // Set up the SpdySettings for www.google.com:80.
+ base::ListValue* spdy_settings_list = new base::ListValue;
+ base::DictionaryValue* spdy_setting_dict = new base::DictionaryValue;
+ spdy_setting_dict->SetInteger("flags", spdy::SETTINGS_FLAG_PERSISTED);
+ spdy_setting_dict->SetInteger("id", 1234);
+ spdy_setting_dict->SetInteger("value", 31337);
+ spdy_settings_list->Append(spdy_setting_dict);
+ server_pref_dict->Set("settings", spdy_settings_list);
+
+ // Set up alternate_protocol for www.google.com:80.
+ base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
+ alternate_protocol->SetInteger("port", 443);
+ alternate_protocol->SetInteger("protocol", static_cast<int>(net::NPN_SPDY_1));
+ server_pref_dict->SetWithoutPathExpansion(
+ "alternate_protocol", alternate_protocol);
+
+ // Set the server preference for www.google.com:80.
+ base::DictionaryValue* http_server_properties_dict =
+ new base::DictionaryValue;
+ http_server_properties_dict->SetWithoutPathExpansion(
+ "www.google.com:80", server_pref_dict);
+
+ // Set the preference for mail.google.com server.
+ base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue;
+
+ // Set supports_spdy for mail.google.com:80
+ server_pref_dict1->SetBoolean("supports_spdy", true);
+
+ // Set up the SpdySettings for mail.google.com:80
+ base::ListValue* spdy_settings_list1 = new base::ListValue;
+ base::DictionaryValue* spdy_setting_dict1 = new base::DictionaryValue;
+ spdy_setting_dict1->SetInteger("flags", spdy::SETTINGS_FLAG_PERSISTED);
+ spdy_setting_dict1->SetInteger("id", 5678);
+ spdy_setting_dict1->SetInteger("value", 62667);
+ spdy_settings_list1->Append(spdy_setting_dict1);
+ server_pref_dict1->Set("settings", spdy_settings_list1);
+
+ // Set up alternate_protocol for mail.google.com:80
+ base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue;
+ alternate_protocol1->SetInteger("port", 444);
+ alternate_protocol1->SetInteger(
+ "protocol", static_cast<int>(net::NPN_SPDY_2));
+ server_pref_dict1->SetWithoutPathExpansion(
+ "alternate_protocol", alternate_protocol1);
+
+ // Set the server preference for mail.google.com:80.
+ http_server_properties_dict->SetWithoutPathExpansion(
+ "mail.google.com:80", server_pref_dict1);
+
+ // Set the same value for kHttpServerProperties multiple times.
+ pref_service_.SetManagedPref(prefs::kHttpServerProperties,
+ http_server_properties_dict);
+ base::DictionaryValue* http_server_properties_dict2 =
+ http_server_properties_dict->DeepCopy();
+ pref_service_.SetManagedPref(prefs::kHttpServerProperties,
+ http_server_properties_dict2);
+
loop_.RunAllPending();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+ // Verify SupportsSpdy.
EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(
- net::HostPortPair::FromString("www.google.com:443")));
+ net::HostPortPair::FromString("www.google.com:80")));
EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(
- net::HostPortPair::FromString("mail.google.com:443")));
+ net::HostPortPair::FromString("mail.google.com:80")));
EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(
net::HostPortPair::FromString("foo.google.com:1337")));
+
+ // Verify SpdySettings.
+ spdy::SpdySettings spdy_settings_ret =
+ http_server_props_manager_->GetSpdySettings(
+ net::HostPortPair::FromString("www.google.com:80"));
+ ASSERT_EQ(1U, spdy_settings_ret.size());
+ spdy::SpdySetting spdy_setting1_ret = spdy_settings_ret.front();
+ spdy::SettingsFlagsAndId id1_ret(spdy_setting1_ret.first);
+ EXPECT_EQ(1234U, id1_ret.id());
+ EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, id1_ret.flags());
+ EXPECT_EQ(31337u, spdy_setting1_ret.second);
+ spdy_settings_ret = http_server_props_manager_->GetSpdySettings(
+ net::HostPortPair::FromString("mail.google.com:80"));
+ ASSERT_EQ(1U, spdy_settings_ret.size());
+ spdy_setting1_ret = spdy_settings_ret.front();
+ id1_ret = spdy_setting1_ret.first;
+ EXPECT_EQ(5678U, id1_ret.id());
+ EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, id1_ret.flags());
+ EXPECT_EQ(62667u, spdy_setting1_ret.second);
+
+ // Verify AlternateProtocol.
+ ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
+ net::HostPortPair::FromString("www.google.com:80")));
+ ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
+ net::HostPortPair::FromString("mail.google.com:80")));
+ net::PortAlternateProtocolPair port_alternate_protocol =
+ http_server_props_manager_->GetAlternateProtocol(
+ net::HostPortPair::FromString("www.google.com:80"));
+ EXPECT_EQ(443, port_alternate_protocol.port);
+ EXPECT_EQ(net::NPN_SPDY_1, port_alternate_protocol.protocol);
+ port_alternate_protocol =
+ http_server_props_manager_->GetAlternateProtocol(
+ net::HostPortPair::FromString("mail.google.com:80"));
+ EXPECT_EQ(444, port_alternate_protocol.port);
+ EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol);
}
TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) {
- ExpectSpdyPrefsUpdate();
+ ExpectPrefsUpdate();
// Post an update task to the IO thread. SetSupportsSpdy calls
- // ScheduleUpdateSpdyPrefsOnIO.
+ // ScheduleUpdatePrefsOnIO.
// Add mail.google.com:443 as a supporting spdy server.
net::HostPortPair spdy_server_mail("mail.google.com", 443);
@@ -210,174 +258,108 @@
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
}
-TEST_F(HttpServerPropertiesManagerTest, Clear) {
- ExpectSpdyPrefsUpdate();
- ExpectAlternateProtocolPrefsUpdate();
+TEST_F(HttpServerPropertiesManagerTest, SetSpdySettings) {
+ ExpectPrefsUpdate();
+ // Add SpdySettings for mail.google.com:443.
net::HostPortPair spdy_server_mail("mail.google.com", 443);
- http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
- http_server_props_manager_->SetAlternateProtocol(
- spdy_server_mail, 443, net::NPN_SPDY_2);
+ spdy::SpdySettings spdy_settings;
+ spdy::SettingsFlagsAndId id1(0);
+ id1.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST);
+ id1.set_id(1234);
+ spdy_settings.push_back(std::make_pair(id1, 31337));
+ http_server_props_manager_->SetSpdySettings(spdy_server_mail, spdy_settings);
// Run the task.
loop_.RunAllPending();
- EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
- EXPECT_TRUE(
- http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
+ spdy::SpdySettings spdy_settings_ret =
+ http_server_props_manager_->GetSpdySettings(spdy_server_mail);
+ ASSERT_EQ(1U, spdy_settings_ret.size());
+ spdy::SpdySetting spdy_setting1_ret = spdy_settings_ret.front();
+ spdy::SettingsFlagsAndId id1_ret(spdy_setting1_ret.first);
+ EXPECT_EQ(1234U, id1_ret.id());
+ EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, id1_ret.flags());
+ EXPECT_EQ(31337U, spdy_setting1_ret.second);
+
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+}
- ExpectSpdyPrefsUpdate();
- ExpectAlternateProtocolPrefsUpdate();
- // Clear http server data.
- http_server_props_manager_->Clear();
+TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) {
+ ExpectPrefsUpdate();
- // Run the task.
- loop_.RunAllPending();
-
- EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
+ net::HostPortPair spdy_server_mail("mail.google.com", 80);
EXPECT_FALSE(
http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
- Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
-}
+ http_server_props_manager_->SetAlternateProtocol(
+ spdy_server_mail, 443, net::NPN_SPDY_2);
-TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateSpdyCache0) {
- // Post an update task to the UI thread.
- http_server_props_manager_->ScheduleUpdateSpdyCacheOnUI();
- // Shutdown comes before the task is executed.
- http_server_props_manager_->ShutdownOnUIThread();
- http_server_props_manager_.reset();
- // Run the task after shutdown and deletion.
+ // Run the task.
loop_.RunAllPending();
-}
-
-TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateSpdyCache1) {
- // Post an update task.
- http_server_props_manager_->ScheduleUpdateSpdyCacheOnUI();
- // Shutdown comes before the task is executed.
- http_server_props_manager_->ShutdownOnUIThread();
- // Run the task after shutdown, but before deletion.
- loop_.RunAllPending();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
- http_server_props_manager_.reset();
- loop_.RunAllPending();
-}
-TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateSpdyCache2) {
- http_server_props_manager_->UpdateSpdyCacheFromPrefsConcrete();
- // Shutdown comes before the task is executed.
- http_server_props_manager_->ShutdownOnUIThread();
- // Run the task after shutdown, but before deletion.
- loop_.RunAllPending();
- Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
- http_server_props_manager_.reset();
- loop_.RunAllPending();
+ ASSERT_TRUE(
+ http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
+ net::PortAlternateProtocolPair port_alternate_protocol =
+ http_server_props_manager_->GetAlternateProtocol(spdy_server_mail);
+ EXPECT_EQ(443, port_alternate_protocol.port);
+ EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol);
}
-//
-// Tests for shutdown when updating prefs.
-//
-TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateSpdyPrefs0) {
- // Post an update task to the IO thread.
- http_server_props_manager_->ScheduleUpdateSpdyPrefsOnIO();
- // Shutdown comes before the task is executed.
- http_server_props_manager_->ShutdownOnUIThread();
- http_server_props_manager_.reset();
- // Run the task after shutdown and deletion.
- loop_.RunAllPending();
-}
+TEST_F(HttpServerPropertiesManagerTest, Clear) {
+ ExpectPrefsUpdate();
-TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateSpdyPrefs1) {
- ExpectSpdyPrefsUpdate();
- // Post an update task.
- http_server_props_manager_->ScheduleUpdateSpdyPrefsOnIO();
- // Shutdown comes before the task is executed.
- http_server_props_manager_->ShutdownOnUIThread();
- // Run the task after shutdown, but before deletion.
- loop_.RunAllPending();
- Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
- http_server_props_manager_.reset();
- loop_.RunAllPending();
-}
+ net::HostPortPair spdy_server_mail("mail.google.com", 443);
+ http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
+ http_server_props_manager_->SetAlternateProtocol(
+ spdy_server_mail, 443, net::NPN_SPDY_2);
-TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateSpdyPrefs2) {
- // This posts a task to the UI thread.
- http_server_props_manager_->UpdateSpdyPrefsFromCacheConcrete();
- // Shutdown comes before the task is executed.
- http_server_props_manager_->ShutdownOnUIThread();
- // Run the task after shutdown, but before deletion.
+ spdy::SpdySettings spdy_settings;
+ spdy::SettingsFlagsAndId id1(0);
+ id1.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST);
+ id1.set_id(1234);
+ spdy_settings.push_back(std::make_pair(id1, 31337));
+ http_server_props_manager_->SetSpdySettings(spdy_server_mail, spdy_settings);
+
+ // Run the task.
loop_.RunAllPending();
- Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
- http_server_props_manager_.reset();
- loop_.RunAllPending();
-}
-TEST_F(HttpServerPropertiesManagerTest,
- SingleUpdateForTwoAlternateProtocolPrefChanges) {
- ExpectAlternateProtocolCacheUpdate();
+ EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
+ EXPECT_TRUE(
+ http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
- // Set up the pref and then set it twice. Only expect a single cache update.
- base::DictionaryValue* alternate_protocol_servers = new base::DictionaryValue;
- base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
- alternate_protocol->SetInteger("port", 443);
- alternate_protocol->SetInteger("protocol", static_cast<int>(net::NPN_SPDY_1));
- alternate_protocol_servers->SetWithoutPathExpansion(
- "www.google.com:80", alternate_protocol);
- alternate_protocol = new base::DictionaryValue;
- alternate_protocol->SetInteger("port", 444);
- alternate_protocol->SetInteger("protocol", static_cast<int>(net::NPN_SPDY_2));
- alternate_protocol_servers->SetWithoutPathExpansion(
- "mail.google.com:80", alternate_protocol);
- pref_service_.SetManagedPref(prefs::kAlternateProtocolServers,
- alternate_protocol_servers);
- alternate_protocol_servers = alternate_protocol_servers->DeepCopy();
- pref_service_.SetManagedPref(prefs::kAlternateProtocolServers,
- alternate_protocol_servers);
- loop_.RunAllPending();
+ spdy::SpdySettings spdy_settings_ret =
+ http_server_props_manager_->GetSpdySettings(spdy_server_mail);
+ ASSERT_EQ(1U, spdy_settings_ret.size());
+ spdy::SpdySetting spdy_setting1_ret = spdy_settings_ret.front();
+ spdy::SettingsFlagsAndId id1_ret(spdy_setting1_ret.first);
+ EXPECT_EQ(1234U, id1_ret.id());
+ EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, id1_ret.flags());
+ EXPECT_EQ(31337U, spdy_setting1_ret.second);
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
- ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
- net::HostPortPair::FromString("www.google.com:80")));
- ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
- net::HostPortPair::FromString("mail.google.com:80")));
- net::PortAlternateProtocolPair port_alternate_protocol =
- http_server_props_manager_->GetAlternateProtocol(
- net::HostPortPair::FromString("www.google.com:80"));
- EXPECT_EQ(443, port_alternate_protocol.port);
- EXPECT_EQ(net::NPN_SPDY_1, port_alternate_protocol.protocol);
- port_alternate_protocol =
- http_server_props_manager_->GetAlternateProtocol(
- net::HostPortPair::FromString("mail.google.com:80"));
- EXPECT_EQ(444, port_alternate_protocol.port);
- EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol);
-}
+ ExpectPrefsUpdate();
+ // Clear http server data.
+ http_server_props_manager_->Clear();
-TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) {
- ExpectAlternateProtocolPrefsUpdate();
+ // Run the task.
+ loop_.RunAllPending();
- net::HostPortPair spdy_server_mail("mail.google.com", 80);
+ EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
EXPECT_FALSE(
http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
- http_server_props_manager_->SetAlternateProtocol(
- spdy_server_mail, 443, net::NPN_SPDY_2);
- // Run the task.
- loop_.RunAllPending();
- Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+ spdy::SpdySettings spdy_settings1_ret =
+ http_server_props_manager_->GetSpdySettings(spdy_server_mail);
+ EXPECT_EQ(0U, spdy_settings1_ret.size());
- ASSERT_TRUE(
- http_server_props_manager_->HasAlternateProtocol(spdy_server_mail));
- net::PortAlternateProtocolPair port_alternate_protocol =
- http_server_props_manager_->GetAlternateProtocol(spdy_server_mail);
- EXPECT_EQ(443, port_alternate_protocol.port);
- EXPECT_EQ(net::NPN_SPDY_2, port_alternate_protocol.protocol);
+ Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
}
-TEST_F(HttpServerPropertiesManagerTest,
- ShutdownWithPendingUpdateAlternateProtocolCache0) {
+TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) {
// Post an update task to the UI thread.
- http_server_props_manager_->ScheduleUpdateAlternateProtocolCacheOnUI();
+ http_server_props_manager_->ScheduleUpdateCacheOnUI();
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
http_server_props_manager_.reset();
@@ -385,10 +367,9 @@
loop_.RunAllPending();
}
-TEST_F(HttpServerPropertiesManagerTest,
- ShutdownWithPendingUpdateAlternateProtocolCache1) {
+TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) {
// Post an update task.
- http_server_props_manager_->ScheduleUpdateAlternateProtocolCacheOnUI();
+ http_server_props_manager_->ScheduleUpdateCacheOnUI();
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
@@ -398,9 +379,8 @@
loop_.RunAllPending();
}
-TEST_F(HttpServerPropertiesManagerTest,
- ShutdownWithPendingUpdateAlternateProtocolCache2) {
- http_server_props_manager_->UpdateAlternateProtocolCacheFromPrefsConcrete();
+TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) {
+ http_server_props_manager_->UpdateCacheFromPrefsOnUIConcrete();
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
@@ -413,10 +393,9 @@
//
// Tests for shutdown when updating prefs.
//
-TEST_F(HttpServerPropertiesManagerTest,
- ShutdownWithPendingUpdateAlternateProtocolPrefs0) {
+TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) {
// Post an update task to the IO thread.
- http_server_props_manager_->ScheduleUpdateAlternateProtocolPrefsOnIO();
+ http_server_props_manager_->ScheduleUpdatePrefsOnIO();
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
http_server_props_manager_.reset();
@@ -424,11 +403,10 @@
loop_.RunAllPending();
}
-TEST_F(HttpServerPropertiesManagerTest,
- ShutdownWithPendingUpdateAlternateProtocolPrefs1) {
- ExpectAlternateProtocolPrefsUpdate();
+TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
+ ExpectPrefsUpdate();
// Post an update task.
- http_server_props_manager_->ScheduleUpdateAlternateProtocolPrefsOnIO();
+ http_server_props_manager_->ScheduleUpdatePrefsOnIO();
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
@@ -438,10 +416,9 @@
loop_.RunAllPending();
}
-TEST_F(HttpServerPropertiesManagerTest,
- ShutdownWithPendingUpdateAlternateProtocolPrefs2) {
+TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) {
// This posts a task to the UI thread.
- http_server_props_manager_->UpdateAlternateProtocolPrefsFromCacheConcrete();
+ http_server_props_manager_->UpdatePrefsFromCacheOnIOConcrete();
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.

Powered by Google App Engine
This is Rietveld 408576698