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

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 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); 144 EXPECT_TRUE(IsInstantExtendedAPIEnabled());
145 #if defined(OS_IOS) || defined(OS_ANDROID) 145 #if defined(OS_IOS) || defined(OS_ANDROID)
146 EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); 146 EXPECT_EQ(1ul, EmbeddedSearchPageVersion());
147 #else 147 #else
148 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); 148 EXPECT_EQ(2ul, EmbeddedSearchPageVersion());
149 #endif 149 #endif
150 ValidateMetrics(INSTANT_EXTENDED_OPT_IN); 150 ValidateMetrics(INSTANT_EXTENDED_OPT_IN);
151 } 151 }
152 152
153 TEST_F(InstantExtendedAPIEnabledTest, EnabledViaFinchFlag) { 153 TEST_F(InstantExtendedAPIEnabledTest, EnabledViaFinchFlag) {
154 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 154 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
155 "InstantExtended/Group1 espv:42/")); 155 "Group1 espv:42"));
156 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); 156 EXPECT_TRUE(IsInstantExtendedAPIEnabled());
157 EXPECT_EQ(42ul, EmbeddedSearchPageVersion()); 157 EXPECT_EQ(42ul, EmbeddedSearchPageVersion());
158 ValidateMetrics(INSTANT_EXTENDED_NOT_SET); 158 ValidateMetrics(INSTANT_EXTENDED_NOT_SET);
159 } 159 }
160 160
161 TEST_F(InstantExtendedAPIEnabledTest, DisabledViaCommandLineFlag) { 161 TEST_F(InstantExtendedAPIEnabledTest, DisabledViaCommandLineFlag) {
162 GetCommandLine()->AppendSwitch(switches::kDisableInstantExtendedAPI); 162 GetCommandLine()->AppendSwitch(switches::kDisableInstantExtendedAPI);
163 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 163 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
164 "InstantExtended/Group1 espv:2/")); 164 "Group1 espv:2"));
165 EXPECT_FALSE(IsInstantExtendedAPIEnabled()); 165 EXPECT_FALSE(IsInstantExtendedAPIEnabled());
166 EXPECT_EQ(0ul, EmbeddedSearchPageVersion()); 166 EXPECT_EQ(0ul, EmbeddedSearchPageVersion());
167 ValidateMetrics(INSTANT_EXTENDED_OPT_OUT); 167 ValidateMetrics(INSTANT_EXTENDED_OPT_OUT);
168 } 168 }
169 169
170 class SearchTest : public BrowserWithTestWindowTest { 170 class SearchTest : public BrowserWithTestWindowTest {
171 protected: 171 protected:
172 virtual void SetUp() OVERRIDE { 172 virtual void SetUp() OVERRIDE {
173 BrowserWithTestWindowTest::SetUp(); 173 BrowserWithTestWindowTest::SetUp();
174 field_trial_list_.reset(new base::FieldTrialList( 174 field_trial_list_.reset(new base::FieldTrialList(
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 SetDefaultInstantTemplateUrl(false); 444 SetDefaultInstantTemplateUrl(false);
445 445
446 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); 446 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile()));
447 } 447 }
448 448
449 TEST_F(SearchTest, IsInstantCheckboxEnabledExtendedEnabledWithInstant) { 449 TEST_F(SearchTest, IsInstantCheckboxEnabledExtendedEnabledWithInstant) {
450 // Enable instant extended. 450 // Enable instant extended.
451 EnableInstantExtendedAPIForTesting(); 451 EnableInstantExtendedAPIForTesting();
452 452
453 // Enable Instant. 453 // Enable Instant.
454 ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString( 454 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
455 "InstantExtended/Group1 allow_instant:1/")); 455 "Group1 allow_instant:1"));
456 ASSERT_TRUE(IsInstantCheckboxVisible()); 456 ASSERT_TRUE(IsInstantCheckboxVisible());
457 457
458 // Enable suggest. 458 // Enable suggest.
459 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 459 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
460 460
461 // Set an Instant URL with a valid search terms replacement key. 461 // Set an Instant URL with a valid search terms replacement key.
462 SetDefaultInstantTemplateUrl(true); 462 SetDefaultInstantTemplateUrl(true);
463 463
464 profile()->GetPrefs()->SetBoolean(prefs::kSearchInstantEnabled, true); 464 profile()->GetPrefs()->SetBoolean(prefs::kSearchInstantEnabled, true);
465 465
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 EXPECT_EQ("http://www.bar.com/webhp?strk", instant_url.spec()); 579 EXPECT_EQ("http://www.bar.com/webhp?strk", instant_url.spec());
580 580
581 // Similarly, setting a Google base URL on the command line should allow you 581 // Similarly, setting a Google base URL on the command line should allow you
582 // to get the Google version of the local NTP, even though search provider's 582 // to get the Google version of the local NTP, even though search provider's
583 // URL doesn't contain "google". 583 // URL doesn't contain "google".
584 local_instant_url = GetLocalInstantURL(profile()); 584 local_instant_url = GetLocalInstantURL(profile());
585 EXPECT_EQ(GURL(chrome::kChromeSearchLocalGoogleNtpUrl), local_instant_url); 585 EXPECT_EQ(GURL(chrome::kChromeSearchLocalGoogleNtpUrl), local_instant_url);
586 } 586 }
587 587
588 } // namespace chrome 588 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/metrics_private/metrics_apitest.cc ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698