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

Unified Diff: chrome/browser/chrome_elf_init_unittest_win.cc

Issue 311893005: Can now adjust the number of retries before the blacklist is disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding setup failure counter, UMA recording and unit tests Created 6 years, 6 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 | chrome/browser/chrome_elf_init_win.h » ('j') | chrome/browser/chrome_elf_init_win.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_elf_init_unittest_win.cc
diff --git a/chrome/browser/chrome_elf_init_unittest_win.cc b/chrome/browser/chrome_elf_init_unittest_win.cc
index 441f73665707f1f8dbc3bddc08729fb3ef70f91c..d01c0e107b89e98644460d3689f1d3330e177cd1 100644
--- a/chrome/browser/chrome_elf_init_unittest_win.cc
+++ b/chrome/browser/chrome_elf_init_unittest_win.cc
@@ -113,7 +113,14 @@ TEST_F(ChromeBlacklistTrialTest, VerifyFirstRun) {
ASSERT_EQ(version, GetBlacklistVersion());
}
+// This test assumes that kBeaconAttemps (the number of startup retries we
+// allow) is at least 2.
TEST_F(ChromeBlacklistTrialTest, SetupFailed) {
+ // Ensure the setup failure counter is low enough that even a new failure
+ // would leave the blacklist enabled.
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconFailedCount,
+ kBeaconAttempts - 2);
+
// Set the registry to indicate that the blacklist setup is running,
// which means it failed to run correctly last time for this version.
blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion,
@@ -121,13 +128,50 @@ TEST_F(ChromeBlacklistTrialTest, SetupFailed) {
blacklist_registry_key_->WriteValue(blacklist::kBeaconState,
blacklist::BLACKLIST_SETUP_RUNNING);
- BrowserBlacklistBeaconSetup();
+ BrowserBlacklistBeaconSetup();
+
+ // The blacklist has now failed kBeaconAttempts - 1 times, the beacon should
+ // reflect this and the blacklist state be set to enabled.
+ DWORD failed_attempt_count = kBeaconAttempts;
+ GetBlacklistFailedCount(&failed_attempt_count);
+ ASSERT_EQ(kBeaconAttempts - 1, failed_attempt_count);
+ ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState());
+
+ // Force a second 'failure', this should disable the blacklist.
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion,
+ TEXT(CHROME_VERSION_STRING));
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconState,
+ blacklist::BLACKLIST_SETUP_RUNNING);
- // Since the blacklist setup failed, it should now be disabled.
+ BrowserBlacklistBeaconSetup();
ASSERT_EQ(blacklist::BLACKLIST_DISABLED, GetBlacklistState());
}
+TEST_F(ChromeBlacklistTrialTest, SetupSucceeded) {
+ // Write a non-zero value to the registry so that we can check it gets reset.
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconFailedCount,
+ kBeaconAttempts);
+
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion,
+ TEXT(CHROME_VERSION_STRING));
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconState,
+ blacklist::BLACKLIST_ENABLED);
+
+ BrowserBlacklistBeaconSetup();
+
+ // Because the set up was successful the counter should be reset.
+ DWORD attempt_count = kBeaconAttempts;
+ GetBlacklistFailedCount(&attempt_count);
+ ASSERT_EQ(static_cast<DWORD>(0), attempt_count);
+ ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState());
+}
+
TEST_F(ChromeBlacklistTrialTest, ThunkSetupFailed) {
+ // Set the setup failure counter so that one more failure should disable the
+ // blacklist.
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconFailedCount,
+ kBeaconAttempts - 1);
+
// Set the registry to indicate that the blacklist thunk setup is running,
// which means it failed to run correctly last time for this version.
blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion,
@@ -142,6 +186,11 @@ TEST_F(ChromeBlacklistTrialTest, ThunkSetupFailed) {
}
TEST_F(ChromeBlacklistTrialTest, InterceptionFailed) {
+ // Set the setup failure counter so that one more failure should disable the
+ // blacklist.
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconFailedCount,
+ kBeaconAttempts - 1);
+
// Set the registry to indicate that an interception is running,
// which means it failed to run correctly last time for this version.
blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion,
@@ -157,11 +206,14 @@ TEST_F(ChromeBlacklistTrialTest, InterceptionFailed) {
TEST_F(ChromeBlacklistTrialTest, VersionChanged) {
// Mark the blacklist as disabled for an older version, so it should
- // get enabled for this new version.
+ // get enabled for this new version. Also record a non-zero number of
+ // setup failures, this should be reset to zero.
blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion,
L"old_version");
blacklist_registry_key_->WriteValue(blacklist::kBeaconState,
blacklist::BLACKLIST_DISABLED);
+ blacklist_registry_key_->WriteValue(blacklist::kBeaconFailedCount,
+ kBeaconAttempts);
BrowserBlacklistBeaconSetup();
@@ -171,4 +223,9 @@ TEST_F(ChromeBlacklistTrialTest, VersionChanged) {
chrome::VersionInfo version_info;
base::string16 expected_version(base::UTF8ToUTF16(version_info.Version()));
ASSERT_EQ(expected_version, GetBlacklistVersion());
+
+ // The counter should be reset.
+ DWORD attempt_count = kBeaconAttempts;
+ GetBlacklistFailedCount(&attempt_count);
+ ASSERT_EQ(static_cast<DWORD>(0), attempt_count);
}
« no previous file with comments | « no previous file | chrome/browser/chrome_elf_init_win.h » ('j') | chrome/browser/chrome_elf_init_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698