diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 03:49:05 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 03:49:05 +0000 |
commit | 4646f29cf92e2b3cd70158067d11431ae9351bcf (patch) | |
tree | d21b85657ca5d59e5383d84ea9d602a943942908 /base/field_trial_unittest.cc | |
parent | a199e400093448023d4f6c555f32d230b3fb2fcd (diff) | |
download | chromium_src-4646f29cf92e2b3cd70158067d11431ae9351bcf.zip chromium_src-4646f29cf92e2b3cd70158067d11431ae9351bcf.tar.gz chromium_src-4646f29cf92e2b3cd70158067d11431ae9351bcf.tar.bz2 |
Facilitate a FieldTrial in the renderer
I added a command line for the renderer that accepts a FieldTrial
name and value, and forces that value to be activated in the
renderer. As a result, any FieldTrial setting that is specified
by the browser process can be set (forced) in the renderer
process. Such settings can then be used to establish names
of histograms, which means all processes can work in sync
on a single field trial (and generate data). This should
allow A/B tests to be run that modulate the page load times.
Dave: Please review/confirm that you are happy with the changes to
render_view.cc. Note that all I did was change the names and limits
for the histograms (they now go up to 3 minutes). The MakeName()
allows me to get an A/B test of the impact of DNS pre-resolution.
Mike: Please review the code for passing along switch settings.
r=davemoore,mbelshe
Review URL: http://codereview.chromium.org/115525
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16460 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/field_trial_unittest.cc')
-rw-r--r-- | base/field_trial_unittest.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/base/field_trial_unittest.cc b/base/field_trial_unittest.cc index 6c818e5..f678b0b 100644 --- a/base/field_trial_unittest.cc +++ b/base/field_trial_unittest.cc @@ -114,3 +114,44 @@ TEST_F(FieldTrialTest, OneWinner) { EXPECT_EQ(trial->group(), winner_index); EXPECT_EQ(winner_name, trial->group_name()); } + +TEST_F(FieldTrialTest, Save) { + FieldTrial* trial = new FieldTrial("Some name", 10); + // There is no winner yet, so no textual group name is associated with trial. + EXPECT_EQ(trial->group_name(), ""); + EXPECT_EQ(trial->MakePersistentString(), "Some name/"); + + // Create a winning group. + trial->AppendGroup("Winner", 10); + EXPECT_EQ(trial->MakePersistentString(), "Some name/Winner"); +} + +TEST_F(FieldTrialTest, Restore) { + FieldTrial* trial = FieldTrial::RestorePersistentString("Some name/winner"); + EXPECT_EQ(trial->group_name(), "winner"); + EXPECT_EQ(trial->name(), "Some name"); +} + +TEST_F(FieldTrialTest, BogusRestore) { + const FieldTrial *trial = FieldTrial::RestorePersistentString("MissingSlash"); + EXPECT_EQ(trial, static_cast<FieldTrial *>(NULL)); + + trial = FieldTrial::RestorePersistentString("MissingGroupName/"); + EXPECT_EQ(trial, static_cast<FieldTrial *>(NULL)); + + trial = FieldTrial::RestorePersistentString("/MissingName"); + EXPECT_EQ(trial, static_cast<FieldTrial *>(NULL)); +} + +TEST_F(FieldTrialTest, DuplicateRestore) { + FieldTrial* trial = new FieldTrial("Some name", 10); + trial->AppendGroup("Winner", 10); + EXPECT_EQ(trial->MakePersistentString(), "Some name/Winner"); + + // It is OK if we redundantly specify a winner. + EXPECT_EQ(trial, FieldTrial::RestorePersistentString("Some name/Winner")); + + // But it is an error to try to change to a different winner. + EXPECT_EQ(FieldTrial::RestorePersistentString("Some name/Loser"), + static_cast<FieldTrial *>(NULL)); +} |