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

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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); 143 EXPECT_TRUE(IsInstantExtendedAPIEnabled());
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::CreateFieldTrial("InstantExtended",
154 "InstantExtended/Group1 espv:42/")); 154 "Group1 espv:42"));
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::CreateFieldTrial("InstantExtended",
163 "InstantExtended/Group1 espv:2/")); 163 "Group1 espv:2"));
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 SetDefaultInstantTemplateUrl(false); 443 SetDefaultInstantTemplateUrl(false);
444 444
445 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); 445 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile()));
446 } 446 }
447 447
448 TEST_F(SearchTest, IsInstantCheckboxEnabledExtendedEnabledWithInstant) { 448 TEST_F(SearchTest, IsInstantCheckboxEnabledExtendedEnabledWithInstant) {
449 // Enable instant extended. 449 // Enable instant extended.
450 EnableInstantExtendedAPIForTesting(); 450 EnableInstantExtendedAPIForTesting();
451 451
452 // Enable Instant. 452 // Enable Instant.
453 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 453 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
454 "InstantExtended/Group1 allow_instant:1/")); 454 "Group1 allow_instant:1"));
455 ASSERT_TRUE(IsInstantCheckboxVisible()); 455 ASSERT_TRUE(IsInstantCheckboxVisible());
456 456
457 // Enable suggest. 457 // Enable suggest.
458 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 458 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
459 459
460 // Set an Instant URL with a valid search terms replacement key. 460 // Set an Instant URL with a valid search terms replacement key.
461 SetDefaultInstantTemplateUrl(true); 461 SetDefaultInstantTemplateUrl(true);
462 462
463 profile()->GetPrefs()->SetBoolean(prefs::kSearchInstantEnabled, true); 463 profile()->GetPrefs()->SetBoolean(prefs::kSearchInstantEnabled, true);
464 464
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 536
537 // Now that suggest is back on and the instant url is good, the checkbox 537 // Now that suggest is back on and the instant url is good, the checkbox
538 // should be enabled and checked again, but still invisible. 538 // should be enabled and checked again, but still invisible.
539 EXPECT_FALSE(IsInstantCheckboxVisible()); 539 EXPECT_FALSE(IsInstantCheckboxVisible());
540 EXPECT_TRUE(IsInstantCheckboxEnabled(profile())); 540 EXPECT_TRUE(IsInstantCheckboxEnabled(profile()));
541 EXPECT_FALSE(IsInstantCheckboxChecked(profile())); 541 EXPECT_FALSE(IsInstantCheckboxChecked(profile()));
542 } 542 }
543 543
544 544
545 } // namespace chrome 545 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698