Changed the default Blacklist case (for no finch)

from disabled to enabled.



BUG=

Review URL: https://codereview.chromium.org/272213006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271246 0039d316-1c4b-4281-b951-d872f2087c98
parent 4183bf09
......@@ -6,11 +6,14 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_reg_util_win.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome_elf/chrome_elf_constants.h"
#include "components/variations/entropy_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "version.h" // NOLINT
......@@ -54,20 +57,47 @@ class ChromeBlacklistTrialTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(ChromeBlacklistTrialTest);
};
// Ensure that the default trial deletes any existing blacklist beacons.
// Ensure that the default trial sets up the blacklist beacons.
TEST_F(ChromeBlacklistTrialTest, DefaultRun) {
// Set some dummy values as beacons.
blacklist_registry_key_->WriteValue(blacklist::kBeaconState,
blacklist::BLACKLIST_DISABLED);
blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion, L"Data");
// This setup code should result in the default group, which should have
// the blacklist set up.
InitializeChromeElf();
// Ensure the beacon values are now correct, indicating the
// blacklist beacon was setup.
ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState());
chrome::VersionInfo version_info;
base::string16 version(base::UTF8ToUTF16(version_info.Version()));
ASSERT_EQ(version, GetBlacklistVersion());
}
// Ensure that the blacklist is disabled for any users in the
// "BlacklistDisabled" finch group.
TEST_F(ChromeBlacklistTrialTest, BlacklistDisabledRun) {
// Set the beacons to enabled values.
blacklist_registry_key_->WriteValue(blacklist::kBeaconState,
blacklist::BLACKLIST_ENABLED);
blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion, L"Data");
// This setup code should result in the default group, which should remove
// all the beacon values.
// Create the field trial with the blacklist disabled group.
base::FieldTrialList field_trial_list(
new metrics::SHA1EntropyProvider("test"));
scoped_refptr<base::FieldTrial> trial(
base::FieldTrialList::CreateFieldTrial(
kBrowserBlacklistTrialName, kBrowserBlacklistTrialDisabledGroupName));
// This setup code should now delete any existing blacklist beacons.
InitializeChromeElf();
// Ensure that invalid values are returned to indicate that the
// beacon values are gone.
// Ensure invalid values are returned to indicate that the beacon
// values are indeed gone.
ASSERT_EQ(blacklist::BLACKLIST_STATE_MAX, GetBlacklistState());
ASSERT_EQ(base::string16(), GetBlacklistVersion());
}
......
......@@ -15,10 +15,10 @@
#include "content/public/browser/browser_thread.h"
#include "version.h" // NOLINT
namespace {
const char kBrowserBlacklistTrialName[] = "BrowserBlacklist";
const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist";
namespace {
// How long to wait, in seconds, before reporting for the second (and last
// time), what dlls were blocked from the browser process.
......@@ -82,12 +82,12 @@ void ReportSuccessfulBlocks() {
void InitializeChromeElf() {
if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) ==
kBrowserBlacklistTrialEnabledGroupName) {
BrowserBlacklistBeaconSetup();
} else {
kBrowserBlacklistTrialDisabledGroupName) {
// Disable the blacklist for all future runs by removing the beacon.
base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER);
blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath);
} else {
BrowserBlacklistBeaconSetup();
}
// Report all successful blacklist interceptions.
......
......@@ -5,6 +5,10 @@
#ifndef CHROME_BROWSER_CHROME_ELF_INIT_WIN_H_
#define CHROME_BROWSER_CHROME_ELF_INIT_WIN_H_
// Field trial name and full name for the blacklist disabled group.
extern const char kBrowserBlacklistTrialName[];
extern const char kBrowserBlacklistTrialDisabledGroupName[];
// Prepare any initialization code for Chrome Elf's setup (This will generally
// only affect future runs since Chrome Elf is already setup by this point).
void InitializeChromeElf();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment