OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autocomplete/autocomplete_result.h" | 5 #include "chrome/browser/autocomplete/autocomplete_result.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 // Add a rule demoting history-url and killing history-title. | 342 // Add a rule demoting history-url and killing history-title. |
343 // Must be the same as kBundledExperimentFieldTrialName | 343 // Must be the same as kBundledExperimentFieldTrialName |
344 // defined in omnibox_field_trial.cc. | 344 // defined in omnibox_field_trial.cc. |
345 const std::string kTrialName = "OmniboxBundledExperimentV1"; | 345 const std::string kTrialName = "OmniboxBundledExperimentV1"; |
346 // Must be the same as kDemoteByTypeRule defined in | 346 // Must be the same as kDemoteByTypeRule defined in |
347 // omnibox_field_trial.cc. | 347 // omnibox_field_trial.cc. |
348 const std::string kRuleName = "DemoteByType"; | 348 const std::string kRuleName = "DemoteByType"; |
349 { | 349 { |
350 std::map<std::string, std::string> params; | 350 std::map<std::string, std::string> params; |
351 params[kRuleName + ":3"] = "1:50,7:100,2:0"; // 3 == HOMEPAGE | 351 params[kRuleName + ":3:*"] = "1:50,7:100,2:0"; // 3 == HOMEPAGE |
352 ASSERT_TRUE(chrome_variations::AssociateVariationParams( | 352 ASSERT_TRUE(chrome_variations::AssociateVariationParams( |
353 kTrialName, "A", params)); | 353 kTrialName, "A", params)); |
354 } | 354 } |
355 base::FieldTrialList::CreateFieldTrial(kTrialName, "A"); | 355 base::FieldTrialList::CreateFieldTrial(kTrialName, "A"); |
356 | 356 |
357 AutocompleteResult result; | 357 AutocompleteResult result; |
358 result.AppendMatches(matches); | 358 result.AppendMatches(matches); |
359 AutocompleteInput input(string16(), string16::npos, string16(), GURL(), | 359 AutocompleteInput input(string16(), string16::npos, string16(), GURL(), |
360 AutocompleteInput::HOMEPAGE, false, false, false, | 360 AutocompleteInput::HOMEPAGE, false, false, false, |
361 AutocompleteInput::ALL_MATCHES); | 361 AutocompleteInput::ALL_MATCHES); |
362 result.SortAndCull(input, test_util_.profile()); | 362 result.SortAndCull(input, test_util_.profile()); |
363 | 363 |
364 // Check the new ordering. The history-title results should be omitted. | 364 // Check the new ordering. The history-title results should be omitted. |
365 // We cannot check relevance scores because the matches are sorted by | 365 // We cannot check relevance scores because the matches are sorted by |
366 // demoted relevance but the actual relevance scores are not modified. | 366 // demoted relevance but the actual relevance scores are not modified. |
367 ASSERT_EQ(3u, result.size()); | 367 ASSERT_EQ(3u, result.size()); |
368 EXPECT_EQ("http://search-what-you-typed/", | 368 EXPECT_EQ("http://search-what-you-typed/", |
369 result.match_at(0)->destination_url.spec()); | 369 result.match_at(0)->destination_url.spec()); |
370 EXPECT_EQ("http://history-url/", | 370 EXPECT_EQ("http://history-url/", |
371 result.match_at(1)->destination_url.spec()); | 371 result.match_at(1)->destination_url.spec()); |
372 EXPECT_EQ("http://search-history/", | 372 EXPECT_EQ("http://search-history/", |
373 result.match_at(2)->destination_url.spec()); | 373 result.match_at(2)->destination_url.spec()); |
374 } | 374 } |
OLD | NEW |