diff options
author | sreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 21:55:32 +0000 |
---|---|---|
committer | sreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 21:55:32 +0000 |
commit | 99213165c36a3e5aa38544927c2d77244e148e78 (patch) | |
tree | 7f1314d55655934770a28aafb502f55f413f180d | |
parent | 1871a0953a61c77e7d0f6e127c2c6aeb082c0394 (diff) | |
download | chromium_src-99213165c36a3e5aa38544927c2d77244e148e78.zip chromium_src-99213165c36a3e5aa38544927c2d77244e148e78.tar.gz chromium_src-99213165c36a3e5aa38544927c2d77244e148e78.tar.bz2 |
Allow controlling the Instant field trial through a command line flag.
This also allows us to disable the field trial for all tests, without
hacking around the kInstantEnabledOnce preference.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8198027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104794 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/instant/instant_field_trial.cc | 12 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service_uitest.cc | 5 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 6 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 2 | ||||
-rw-r--r-- | chrome/test/base/test_launcher_utils.cc | 3 | ||||
-rw-r--r-- | chrome/test/functional/instant.py | 2 |
6 files changed, 23 insertions, 7 deletions
diff --git a/chrome/browser/instant/instant_field_trial.cc b/chrome/browser/instant/instant_field_trial.cc index dc68ac9..13a0b42 100644 --- a/chrome/browser/instant/instant_field_trial.cc +++ b/chrome/browser/instant/instant_field_trial.cc @@ -4,10 +4,12 @@ #include "chrome/browser/instant/instant_field_trial.h" +#include "base/command_line.h" #include "base/metrics/field_trial.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" namespace { @@ -39,6 +41,16 @@ void InstantFieldTrial::Activate() { // static InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kInstantFieldTrial)) { + std::string switch_value = + command_line->GetSwitchValueASCII(switches::kInstantFieldTrial); + if (switch_value == switches::kInstantFieldTrialInstant) + return EXPERIMENT1; + else + return INACTIVE; + } + if (!profile || profile->IsOffTheRecord()) return INACTIVE; diff --git a/chrome/browser/metrics/metrics_service_uitest.cc b/chrome/browser/metrics/metrics_service_uitest.cc index f323fdc..20fca2b 100644 --- a/chrome/browser/metrics/metrics_service_uitest.cc +++ b/chrome/browser/metrics/metrics_service_uitest.cc @@ -39,11 +39,6 @@ class MetricsServiceTest : public UITest { scoped_refptr<BrowserProxy> window = automation()->GetBrowserWindow(0); ASSERT_TRUE(window.get()); - // The Instant field trial causes a preload of the default search engine, - // which messes up the expected page load count. Setting this preference - // disables the field trial. - ASSERT_TRUE(window->SetBooleanPreference(prefs::kInstantEnabledOnce, true)); - FilePath page1_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page1_path)); page1_path = page1_path.AppendASCII("title2.html"); diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index aa617a0..14f5394 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -669,6 +669,12 @@ const char kImportFromFile[] = "import-from-file"; // Causes the browser to launch directly in incognito mode. const char kIncognito[] = "incognito"; +// Control the Instant field trial. Valid values are defined below. If an +// unknown value is supplied on the command line, the field trial is disabled. +const char kInstantFieldTrial[] = "instant-field-trial"; +// The field trial is forced into the INSTANT_EXPERIMENT group. +const char kInstantFieldTrialInstant[] = "instant"; + // URL to use for instant. If specified this overrides the url from the // TemplateURL. const char kInstantURL[] = "instant-url"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 5b54d39..872136d 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -187,6 +187,8 @@ extern const char kHstsHosts[]; extern const char kImport[]; extern const char kImportFromFile[]; extern const char kIncognito[]; +extern const char kInstantFieldTrial[]; +extern const char kInstantFieldTrialInstant[]; extern const char kInstantURL[]; extern const char kKeepAliveForTest[]; extern const char kLoadExtension[]; diff --git a/chrome/test/base/test_launcher_utils.cc b/chrome/test/base/test_launcher_utils.cc index 4dfe1f7..d8239eb 100644 --- a/chrome/test/base/test_launcher_utils.cc +++ b/chrome/test/base/test_launcher_utils.cc @@ -53,6 +53,9 @@ void PrepareBrowserCommandLineForTests(CommandLine* command_line) { // See crbug.com/89808. // command_line->AppendSwitch(switches::kUseMockKeychain); #endif + + // Disable the Instant field trial, which may cause unexpected page loads. + command_line->AppendSwitchASCII(switches::kInstantFieldTrial, "disabled"); } bool OverrideUserDataDir(const FilePath& user_data_dir) { diff --git a/chrome/test/functional/instant.py b/chrome/test/functional/instant.py index 796b687..917b10f 100644 --- a/chrome/test/functional/instant.py +++ b/chrome/test/functional/instant.py @@ -21,7 +21,6 @@ class InstantSettingsTest(pyauto.PyUITest): msg='Instant is enabled by default.') # Enable instant. self.SetPrefs(pyauto.kInstantEnabled, True) - self.SetPrefs(pyauto.kInstantEnabledOnce, True) self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), msg='Instant is not enabled.') self.SetOmniboxText('google.com') @@ -42,7 +41,6 @@ class InstantTest(pyauto.PyUITest): def setUp(self): pyauto.PyUITest.setUp(self) self.SetPrefs(pyauto.kInstantEnabled, True) - self.SetPrefs(pyauto.kInstantEnabledOnce, True) def _DoneLoading(self): info = self.GetInstantInfo() |