| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 144 } |
| 145 | 145 |
| 146 TEST_F(SearchTest, ShouldPrefetchSearchResults_Default) { | 146 TEST_F(SearchTest, ShouldPrefetchSearchResults_Default) { |
| 147 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 147 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_Default) { | 150 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_Default) { |
| 151 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); | 151 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_DisabledViaFieldTrial) { | |
| 155 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 156 "EmbeddedSearch", "Group1 espv:89 allow_prefetch_non_default_match:0")); | |
| 157 EXPECT_FALSE(ShouldAllowPrefetchNonDefaultMatch()); | |
| 158 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | |
| 159 } | |
| 160 | |
| 161 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_EnabledViaFieldTrial) { | |
| 162 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 163 "EmbeddedSearch", "Group1 espv:80 allow_prefetch_non_default_match:1")); | |
| 164 EXPECT_TRUE(ShouldAllowPrefetchNonDefaultMatch()); | |
| 165 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | |
| 166 } | |
| 167 | |
| 168 TEST_F(SearchTest, ForceInstantResultsParam) { | 154 TEST_F(SearchTest, ForceInstantResultsParam) { |
| 169 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", | 155 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", |
| 170 "Group1 espv:2")); | 156 "Group1 espv:2")); |
| 171 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | 157 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); |
| 172 EXPECT_EQ("ion=1&", ForceInstantResultsParam(true)); | 158 EXPECT_EQ("ion=1&", ForceInstantResultsParam(true)); |
| 173 EXPECT_EQ(std::string(), ForceInstantResultsParam(false)); | 159 EXPECT_EQ(std::string(), ForceInstantResultsParam(false)); |
| 174 } | 160 } |
| 175 | 161 |
| 176 typedef EmbeddedSearchFieldTrialTest InstantExtendedEnabledParamTest; | 162 typedef EmbeddedSearchFieldTrialTest InstantExtendedEnabledParamTest; |
| 177 | 163 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 EnableQueryExtractionForTesting(); | 219 EnableQueryExtractionForTesting(); |
| 234 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 220 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 235 "EmbeddedSearch", "Group1 espv:2 query_extraction:0")); | 221 "EmbeddedSearch", "Group1 espv:2 query_extraction:0")); |
| 236 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | 222 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); |
| 237 EXPECT_TRUE(IsQueryExtractionEnabled()); | 223 EXPECT_TRUE(IsQueryExtractionEnabled()); |
| 238 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | 224 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); |
| 239 } | 225 } |
| 240 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) | 226 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) |
| 241 | 227 |
| 242 } // namespace search | 228 } // namespace search |
| OLD | NEW |