| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search/search.h" | 5 #include "components/search/search.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 EXPECT_EQ(std::string(), ForceInstantResultsParam(false)); | 159 EXPECT_EQ(std::string(), ForceInstantResultsParam(false)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 typedef EmbeddedSearchFieldTrialTest InstantExtendedEnabledParamTest; | 162 typedef EmbeddedSearchFieldTrialTest InstantExtendedEnabledParamTest; |
| 163 | 163 |
| 164 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionDisabled) { | 164 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionDisabled) { |
| 165 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", | 165 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", |
| 166 "Group1 espv:12")); | 166 "Group1 espv:12")); |
| 167 // Make sure InstantExtendedEnabledParam() returns an empty string for search | 167 // Make sure InstantExtendedEnabledParam() returns an empty string for search |
| 168 // requests. | 168 // requests. |
| 169 EXPECT_FALSE(IsQueryExtractionEnabled()); | |
| 170 EXPECT_EQ("", InstantExtendedEnabledParam(true)); | 169 EXPECT_EQ("", InstantExtendedEnabledParam(true)); |
| 171 EXPECT_EQ("espv=12&", InstantExtendedEnabledParam(false)); | 170 EXPECT_EQ("espv=12&", InstantExtendedEnabledParam(false)); |
| 172 } | 171 } |
| 173 | 172 |
| 174 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionEnabled) { | |
| 175 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 176 "EmbeddedSearch", "Group1 espv:10 query_extraction:1")); | |
| 177 EXPECT_TRUE(IsQueryExtractionEnabled()); | |
| 178 // Make sure InstantExtendedEnabledParam() returns a non-empty param string | |
| 179 // for search requests. | |
| 180 EXPECT_EQ("espv=10&", InstantExtendedEnabledParam(true)); | |
| 181 EXPECT_EQ("espv=10&", InstantExtendedEnabledParam(false)); | |
| 182 } | |
| 183 | |
| 184 TEST_F(InstantExtendedEnabledParamTest, UseDefaultEmbeddedSearchPageVersion) { | 173 TEST_F(InstantExtendedEnabledParamTest, UseDefaultEmbeddedSearchPageVersion) { |
| 185 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 174 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 186 "EmbeddedSearch", "Group1 espv:-1 query_extraction:1")); | 175 "EmbeddedSearch", "Group1 espv:-1")); |
| 187 EXPECT_TRUE(IsQueryExtractionEnabled()); | 176 EXPECT_EQ("", InstantExtendedEnabledParam(true)); |
| 188 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(true)); | |
| 189 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(false)); | 177 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(false)); |
| 190 } | 178 } |
| 191 | 179 |
| 192 typedef EmbeddedSearchFieldTrialTest IsQueryExtractionEnabledTest; | |
| 193 | |
| 194 TEST_F(IsQueryExtractionEnabledTest, NotSet) { | |
| 195 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", | |
| 196 "Group1 espv:2")); | |
| 197 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | |
| 198 EXPECT_FALSE(IsQueryExtractionEnabled()); | |
| 199 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | |
| 200 } | |
| 201 | |
| 202 TEST_F(IsQueryExtractionEnabledTest, EnabledViaFieldTrial) { | |
| 203 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 204 "EmbeddedSearch", "Group1 espv:2 query_extraction:1")); | |
| 205 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | |
| 206 EXPECT_TRUE(IsQueryExtractionEnabled()); | |
| 207 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | |
| 208 } | |
| 209 | |
| 210 TEST_F(IsQueryExtractionEnabledTest, DisabledViaFieldTrial) { | |
| 211 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 212 "EmbeddedSearch", "Group1 espv:2 query_extraction:0")); | |
| 213 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | |
| 214 EXPECT_FALSE(IsQueryExtractionEnabled()); | |
| 215 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | |
| 216 } | |
| 217 | |
| 218 TEST_F(IsQueryExtractionEnabledTest, EnabledViaCommandLine) { | |
| 219 EnableQueryExtractionForTesting(); | |
| 220 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 221 "EmbeddedSearch", "Group1 espv:2 query_extraction:0")); | |
| 222 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | |
| 223 EXPECT_TRUE(IsQueryExtractionEnabled()); | |
| 224 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | |
| 225 } | |
| 226 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) | 180 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) |
| 227 | 181 |
| 228 } // namespace search | 182 } // namespace search |
| OLD | NEW |