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

Side by Side Diff: chrome/browser/omnibox/omnibox_field_trial_unittest.cc

Issue 55413002: Don't demote top match for certain match types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's comments Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/omnibox/omnibox_field_trial.h" 5 #include "chrome/browser/omnibox/omnibox_field_trial.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 OmniboxFieldTrial::GetDemotionsByType( 181 OmniboxFieldTrial::GetDemotionsByType(
182 AutocompleteInput::HOME_PAGE, &demotions_by_type); 182 AutocompleteInput::HOME_PAGE, &demotions_by_type);
183 ASSERT_EQ(1u, demotions_by_type.size()); 183 ASSERT_EQ(1u, demotions_by_type.size());
184 VerifyDemotion(demotions_by_type, AutocompleteMatchType::NAVSUGGEST, 1.0); 184 VerifyDemotion(demotions_by_type, AutocompleteMatchType::NAVSUGGEST, 1.0);
185 OmniboxFieldTrial::GetDemotionsByType( 185 OmniboxFieldTrial::GetDemotionsByType(
186 AutocompleteInput::BLANK, &demotions_by_type); 186 AutocompleteInput::BLANK, &demotions_by_type);
187 ASSERT_EQ(1u, demotions_by_type.size()); 187 ASSERT_EQ(1u, demotions_by_type.size());
188 VerifyDemotion(demotions_by_type, AutocompleteMatchType::HISTORY_URL, 0.25); 188 VerifyDemotion(demotions_by_type, AutocompleteMatchType::HISTORY_URL, 0.25);
189 } 189 }
190 190
191 TEST_F(OmniboxFieldTrialTest, GetUndemotableTopTypes) {
192 {
193 std::map<std::string, std::string> params;
194 const std::string rule(OmniboxFieldTrial::kUndemotableTopTypeRule);
195 params[rule + ":1:*"] = "1,3";
196 params[rule + ":3:*"] = "5";
197 params[rule + ":*:*"] = "2";
198 ASSERT_TRUE(chrome_variations::AssociateVariationParams(
199 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params));
200 }
201 base::FieldTrialList::CreateFieldTrial(
202 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A");
203 OmniboxFieldTrial::UndemotableTopMatchTypes undemotable_types;
204 undemotable_types = OmniboxFieldTrial::GetUndemotableTopTypes(
205 AutocompleteInput::NEW_TAB_PAGE);
206 ASSERT_EQ(2u, undemotable_types.size());
207 ASSERT_EQ(1u, undemotable_types.count(AutocompleteMatchType::HISTORY_URL));
208 ASSERT_EQ(1u, undemotable_types.count(AutocompleteMatchType::HISTORY_BODY));
209 undemotable_types = OmniboxFieldTrial::GetUndemotableTopTypes(
210 AutocompleteInput::HOME_PAGE);
211 ASSERT_EQ(1u, undemotable_types.size());
212 ASSERT_EQ(1u, undemotable_types.count(AutocompleteMatchType::NAVSUGGEST));
213 undemotable_types = OmniboxFieldTrial::GetUndemotableTopTypes(
214 AutocompleteInput::BLANK);
215 ASSERT_EQ(1u, undemotable_types.size());
216 ASSERT_EQ(1u, undemotable_types.count(AutocompleteMatchType::HISTORY_TITLE));
217 }
218
191 TEST_F(OmniboxFieldTrialTest, GetValueForRuleInContext) { 219 TEST_F(OmniboxFieldTrialTest, GetValueForRuleInContext) {
192 // This test starts with Instant Extended off (the default state), then 220 // This test starts with Instant Extended off (the default state), then
193 // enables Instant Extended and tests again on the same rules. 221 // enables Instant Extended and tests again on the same rules.
194 222
195 { 223 {
196 std::map<std::string, std::string> params; 224 std::map<std::string, std::string> params;
197 // Rule 1 has some exact matches and fallbacks at every level. 225 // Rule 1 has some exact matches and fallbacks at every level.
198 params["rule1:1:0"] = "rule1-1-0-value"; // NEW_TAB_PAGE 226 params["rule1:1:0"] = "rule1-1-0-value"; // NEW_TAB_PAGE
199 params["rule1:3:0"] = "rule1-3-0-value"; // HOME_PAGE 227 params["rule1:3:0"] = "rule1-3-0-value"; // HOME_PAGE
200 params["rule1:4:1"] = "rule1-4-1-value"; // OTHER 228 params["rule1:4:1"] = "rule1-4-1-value"; // OTHER
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 ExpectRuleValue("", 320 ExpectRuleValue("",
293 "rule4", AutocompleteInput::BLANK); // no global fallback 321 "rule4", AutocompleteInput::BLANK); // no global fallback
294 ExpectRuleValue("", 322 ExpectRuleValue("",
295 "rule4", AutocompleteInput::HOME_PAGE); // no global fallback 323 "rule4", AutocompleteInput::HOME_PAGE); // no global fallback
296 324
297 // Tests for rule 5 (a missing rule). 325 // Tests for rule 5 (a missing rule).
298 ExpectRuleValue("", 326 ExpectRuleValue("",
299 "rule5", AutocompleteInput::OTHER); // no rule at all 327 "rule5", AutocompleteInput::OTHER); // no rule at all
300 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) 328 #endif // !defined(OS_IOS) && !defined(OS_ANDROID)
301 } 329 }
OLDNEW
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698