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

Side by Side Diff: chrome/browser/search/search_unittest.cc

Issue 17945002: Make --force-fieldtrials not activate them in the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/metrics/field_trial.h" 6 #include "base/metrics/field_trial.h"
7 #include "base/metrics/histogram_base.h" 7 #include "base/metrics/histogram_base.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #if defined(OS_IOS) || defined(OS_ANDROID) 144 #if defined(OS_IOS) || defined(OS_ANDROID)
145 EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); 145 EXPECT_EQ(1ul, EmbeddedSearchPageVersion());
146 #else 146 #else
147 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); 147 EXPECT_EQ(2ul, EmbeddedSearchPageVersion());
148 #endif 148 #endif
149 ValidateMetrics(INSTANT_EXTENDED_OPT_IN); 149 ValidateMetrics(INSTANT_EXTENDED_OPT_IN);
150 } 150 }
151 151
152 TEST_F(InstantExtendedAPIEnabledTest, EnabledViaFinchFlag) { 152 TEST_F(InstantExtendedAPIEnabledTest, EnabledViaFinchFlag) {
153 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 153 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString(
154 "InstantExtended/Group1 espv:42/")); 154 "InstantExtended/Group1 espv:42/", false));
155 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); 155 EXPECT_TRUE(IsInstantExtendedAPIEnabled());
156 EXPECT_EQ(42ul, EmbeddedSearchPageVersion()); 156 EXPECT_EQ(42ul, EmbeddedSearchPageVersion());
157 ValidateMetrics(INSTANT_EXTENDED_NOT_SET); 157 ValidateMetrics(INSTANT_EXTENDED_NOT_SET);
158 } 158 }
159 159
160 TEST_F(InstantExtendedAPIEnabledTest, DisabledViaCommandLineFlag) { 160 TEST_F(InstantExtendedAPIEnabledTest, DisabledViaCommandLineFlag) {
161 GetCommandLine()->AppendSwitch(switches::kDisableInstantExtendedAPI); 161 GetCommandLine()->AppendSwitch(switches::kDisableInstantExtendedAPI);
162 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 162 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString(
163 "InstantExtended/Group1 espv:2/")); 163 "InstantExtended/Group1 espv:2/", false));
164 EXPECT_FALSE(IsInstantExtendedAPIEnabled()); 164 EXPECT_FALSE(IsInstantExtendedAPIEnabled());
165 EXPECT_EQ(0ul, EmbeddedSearchPageVersion()); 165 EXPECT_EQ(0ul, EmbeddedSearchPageVersion());
166 ValidateMetrics(INSTANT_EXTENDED_OPT_OUT); 166 ValidateMetrics(INSTANT_EXTENDED_OPT_OUT);
167 } 167 }
168 168
169 class SearchTest : public BrowserWithTestWindowTest { 169 class SearchTest : public BrowserWithTestWindowTest {
170 protected: 170 protected:
171 virtual void SetUp() OVERRIDE { 171 virtual void SetUp() OVERRIDE {
172 BrowserWithTestWindowTest::SetUp(); 172 BrowserWithTestWindowTest::SetUp();
173 field_trial_list_.reset(new base::FieldTrialList( 173 field_trial_list_.reset(new base::FieldTrialList(
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); 478 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile()));
479 } 479 }
480 480
481 TEST_F(SearchTest, IsInstantCheckboxEnabledExtendedEnabledWithInstant) { 481 TEST_F(SearchTest, IsInstantCheckboxEnabledExtendedEnabledWithInstant) {
482 // Enable instant extended. 482 // Enable instant extended.
483 EnableInstantExtendedAPIForTesting(); 483 EnableInstantExtendedAPIForTesting();
484 484
485 // Enable Instant. 485 // Enable Instant.
486 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 486 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString(
487 "InstantExtended/Group1 allow_instant:1/")); 487 "InstantExtended/Group1 allow_instant:1/", false));
488 ASSERT_TRUE(IsInstantCheckboxVisible()); 488 ASSERT_TRUE(IsInstantCheckboxVisible());
489 489
490 // Enable suggest. 490 // Enable suggest.
491 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 491 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
492 492
493 // Set an Instant URL with a valid search terms replacement key. 493 // Set an Instant URL with a valid search terms replacement key.
494 SetDefaultInstantTemplateUrl(true); 494 SetDefaultInstantTemplateUrl(true);
495 495
496 profile()->GetPrefs()->SetBoolean(prefs::kSearchInstantEnabled, true); 496 profile()->GetPrefs()->SetBoolean(prefs::kSearchInstantEnabled, true);
497 497
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 569
570 // Now that suggest is back on and the instant url is good, the checkbox 570 // Now that suggest is back on and the instant url is good, the checkbox
571 // should be enabled and checked again, but still invisible. 571 // should be enabled and checked again, but still invisible.
572 EXPECT_FALSE(IsInstantCheckboxVisible()); 572 EXPECT_FALSE(IsInstantCheckboxVisible());
573 EXPECT_TRUE(IsInstantCheckboxEnabled(profile())); 573 EXPECT_TRUE(IsInstantCheckboxEnabled(profile()));
574 EXPECT_FALSE(IsInstantCheckboxChecked(profile())); 574 EXPECT_FALSE(IsInstantCheckboxChecked(profile()));
575 } 575 }
576 576
577 577
578 } // namespace chrome 578 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698