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

Unified Diff: net/http/http_server_properties_manager_unittest.cc

Issue 2585823003: Enforce check on how many pref updates and cache updates are called in http_server_properties_manag… (Closed)
Patch Set: fix Created 4 years 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 b2f11528bdb6a81c88f45554792ea29b474bff37..3d7bdfb21c509f031ed415d5398b920628fc92b7 100644
--- a/net/http/http_server_properties_manager_unittest.cc
+++ b/net/http/http_server_properties_manager_unittest.cc
@@ -32,6 +32,7 @@ namespace {
using base::StringPrintf;
using base::TestMockTimeTaskRunner;
using ::testing::_;
+using ::testing::AtLeast;
using ::testing::Invoke;
using ::testing::Mock;
using ::testing::StrictMock;
@@ -213,25 +214,19 @@ class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> {
ScheduleUpdatePrefsOnNetworkThreadConcrete));
}
- void ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly() {
+ void ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(int times) {
EXPECT_CALL(*http_server_props_manager_,
ScheduleUpdatePrefsOnNetworkThread(_))
+ .Times(AtLeast(times))
.WillRepeatedly(Invoke(http_server_props_manager_.get(),
&TestingHttpServerPropertiesManager::
ScheduleUpdatePrefsOnNetworkThreadConcrete));
}
- void ExpectPrefsUpdate() {
- EXPECT_CALL(*http_server_props_manager_,
- UpdatePrefsFromCacheOnNetworkThread(_))
- .WillOnce(Invoke(http_server_props_manager_.get(),
- &TestingHttpServerPropertiesManager::
- UpdatePrefsFromCacheOnNetworkThreadConcrete));
- }
-
- void ExpectPrefsUpdateRepeatedly() {
+ void ExpectPrefsUpdate(int times) {
EXPECT_CALL(*http_server_props_manager_,
UpdatePrefsFromCacheOnNetworkThread(_))
+ .Times(times)
.WillRepeatedly(
Invoke(http_server_props_manager_.get(),
&TestingHttpServerPropertiesManager::
@@ -487,7 +482,7 @@ TEST_P(HttpServerPropertiesManagerTest,
TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
ExpectCacheUpdate();
// The prefs are automatically updated in the case corruption is detected.
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
@@ -577,7 +572,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
ExpectCacheUpdate();
// The prefs are automatically updated in the case corruption is detected.
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
@@ -638,7 +633,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
}
TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
// Post an update task to the network thread. SetSupportsSpdy calls
@@ -670,11 +665,11 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
// update could also be scheduled once the previous scheduled update is
// completed.
TEST_P(HttpServerPropertiesManagerTest,
- SinglePrefUpdateForTwoSpdyServerCacheChangese) {
+ SinglePrefUpdateForTwoSpdyServerCacheChanges) {
http_server_props_manager_->set_pref_update_delay(
base::TimeDelta::FromMilliseconds(60));
- ExpectPrefsUpdateRepeatedly();
- ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
+ ExpectPrefsUpdate(2);
+ ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(3);
// Post an update task to the network thread. SetSupportsSpdy calls
// ScheduleUpdatePrefsOnNetworkThread with a delay of 60ms.
@@ -728,7 +723,7 @@ TEST_P(HttpServerPropertiesManagerTest,
}
TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
@@ -759,7 +754,7 @@ TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) {
}
TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
@@ -814,7 +809,7 @@ TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {
}
TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80);
EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
@@ -867,7 +862,7 @@ TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
}
TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
IPAddress address;
@@ -894,7 +889,7 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsQuic) {
}
TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
url::SchemeHostPort mail_server("http", "mail.google.com", 80);
@@ -924,7 +919,7 @@ TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) {
}
TEST_P(HttpServerPropertiesManagerTest, QuicServerInfo) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectScheduleUpdatePrefsOnNetworkThread();
QuicServerId mail_quic_server_id("mail.google.com", 80);
@@ -957,8 +952,8 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
// thus can not mock the pref task runner.
SetUpWithNonTaskRunner();
- ExpectPrefsUpdate();
- ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
+ ExpectPrefsUpdate(1);
+ ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(5);
url::SchemeHostPort spdy_server("https", "mail.google.com", 443);
http_server_props_manager_->SetSupportsSpdy(spdy_server, true);
@@ -995,7 +990,7 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
// Clear http server data, time out if we do not get a completion callback.
http_server_props_manager_->Clear(base::MessageLoop::QuitWhenIdleClosure());
@@ -1120,7 +1115,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
}
TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
- ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
+ ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(5);
const url::SchemeHostPort server_www("http", "www.google.com", 80);
const url::SchemeHostPort server_mail("http", "mail.google.com", 80);
@@ -1163,7 +1158,7 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
http_server_props_manager_->SetSupportsQuic(true, actual_address);
// Update cache.
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectCacheUpdate();
http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
@@ -1270,7 +1265,7 @@ TEST_P(HttpServerPropertiesManagerTest, DoNotLoadAltSvcForInsecureOrigins) {
// Do not persist expired or broken alternative service entries to disk.
TEST_P(HttpServerPropertiesManagerTest,
DoNotPersistExpiredOrBrokenAlternativeService) {
- ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
+ ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly(2);
AlternativeServiceInfoVector alternative_service_info_vector;
@@ -1300,7 +1295,7 @@ TEST_P(HttpServerPropertiesManagerTest,
server, alternative_service_info_vector);
// Update cache.
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
ExpectCacheUpdate();
http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
@@ -1446,7 +1441,7 @@ TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) {
}
TEST_P(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
- ExpectPrefsUpdate();
+ ExpectPrefsUpdate(1);
// Post an update task.
http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread();
// Shutdown comes before the task is executed.
« 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