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 "components/omnibox/browser/history_url_provider.h" | 5 #include "components/omnibox/browser/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "components/metrics/proto/omnibox_input_type.pb.h" | 26 #include "components/metrics/proto/omnibox_input_type.pb.h" |
27 #include "components/omnibox/browser/autocomplete_match.h" | 27 #include "components/omnibox/browser/autocomplete_match.h" |
28 #include "components/omnibox/browser/autocomplete_provider.h" | 28 #include "components/omnibox/browser/autocomplete_provider.h" |
29 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 29 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
30 #include "components/omnibox/browser/autocomplete_result.h" | 30 #include "components/omnibox/browser/autocomplete_result.h" |
31 #include "components/omnibox/browser/history_quick_provider.h" | 31 #include "components/omnibox/browser/history_quick_provider.h" |
32 #include "components/search_engines/default_search_manager.h" | 32 #include "components/search_engines/default_search_manager.h" |
33 #include "components/search_engines/search_terms_data.h" | 33 #include "components/search_engines/search_terms_data.h" |
34 #include "components/search_engines/template_url.h" | 34 #include "components/search_engines/template_url.h" |
35 #include "components/search_engines/template_url_service.h" | 35 #include "components/search_engines/template_url_service.h" |
36 #include "components/url_fixer/url_fixer.h" | 36 #include "components/url_formatter/url_fixer.h" |
37 #include "content/public/test/test_browser_thread_bundle.h" | 37 #include "content/public/test/test_browser_thread_bundle.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
39 | 39 |
40 using base::ASCIIToUTF16; | 40 using base::ASCIIToUTF16; |
41 using base::Time; | 41 using base::Time; |
42 using base::TimeDelta; | 42 using base::TimeDelta; |
43 | 43 |
44 using content::TestBrowserThreadBundle; | 44 using content::TestBrowserThreadBundle; |
45 | 45 |
46 struct TestURLInfo { | 46 struct TestURLInfo { |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 { "gooey/", 1410 }, | 721 { "gooey/", 1410 }, |
722 { "gooey/a", 1400 }, | 722 { "gooey/a", 1400 }, |
723 { "gooey/a b", 1400 }, | 723 { "gooey/a b", 1400 }, |
724 }; | 724 }; |
725 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 725 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
726 SCOPED_TRACE(test_cases[i].input); | 726 SCOPED_TRACE(test_cases[i].input); |
727 if (test_cases[i].relevance == 0) { | 727 if (test_cases[i].relevance == 0) { |
728 RunTest(ASCIIToUTF16(test_cases[i].input), std::string(), false, NULL, 0); | 728 RunTest(ASCIIToUTF16(test_cases[i].input), std::string(), false, NULL, 0); |
729 } else { | 729 } else { |
730 const UrlAndLegalDefault output[] = { | 730 const UrlAndLegalDefault output[] = { |
731 {url_fixer::FixupURL(test_cases[i].input, std::string()).spec(), | 731 {url_formatter::FixupURL(test_cases[i].input, std::string()).spec(), |
732 true}}; | 732 true}}; |
733 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), | 733 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), |
734 std::string(), false, output, arraysize(output))); | 734 std::string(), false, output, arraysize(output))); |
735 // Actual relevance should be at least what test_cases expects and | 735 // Actual relevance should be at least what test_cases expects and |
736 // and no more than 10 more. | 736 // and no more than 10 more. |
737 EXPECT_LE(test_cases[i].relevance, matches_[0].relevance); | 737 EXPECT_LE(test_cases[i].relevance, matches_[0].relevance); |
738 EXPECT_LT(matches_[0].relevance, test_cases[i].relevance + 10); | 738 EXPECT_LT(matches_[0].relevance, test_cases[i].relevance + 10); |
739 } | 739 } |
740 } | 740 } |
741 } | 741 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 {{"7.com/5", 1203, 1203}, {"7.com/5a", 1202, 50}, {NULL, 0, 0}} }, | 1035 {{"7.com/5", 1203, 1203}, {"7.com/5a", 1202, 50}, {NULL, 0, 0}} }, |
1036 }; | 1036 }; |
1037 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 1037 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
1038 SCOPED_TRACE(test_cases[i].input); | 1038 SCOPED_TRACE(test_cases[i].input); |
1039 UrlAndLegalDefault output[kMaxMatches]; | 1039 UrlAndLegalDefault output[kMaxMatches]; |
1040 int max_matches; | 1040 int max_matches; |
1041 for (max_matches = 0; max_matches < kMaxMatches; ++max_matches) { | 1041 for (max_matches = 0; max_matches < kMaxMatches; ++max_matches) { |
1042 if (test_cases[i].matches[max_matches].url == NULL) | 1042 if (test_cases[i].matches[max_matches].url == NULL) |
1043 break; | 1043 break; |
1044 output[max_matches].url = | 1044 output[max_matches].url = |
1045 url_fixer::FixupURL(test_cases[i].matches[max_matches].url, | 1045 url_formatter::FixupURL(test_cases[i].matches[max_matches].url, |
1046 std::string()).spec(); | 1046 std::string()) |
| 1047 .spec(); |
1047 output[max_matches].allowed_to_be_default_match = true; | 1048 output[max_matches].allowed_to_be_default_match = true; |
1048 } | 1049 } |
1049 autocomplete_->scoring_params_ = test_cases[i].scoring_params; | 1050 autocomplete_->scoring_params_ = test_cases[i].scoring_params; |
1050 | 1051 |
1051 // Test the control (scoring disabled). | 1052 // Test the control (scoring disabled). |
1052 autocomplete_->scoring_params_.experimental_scoring_enabled = false; | 1053 autocomplete_->scoring_params_.experimental_scoring_enabled = false; |
1053 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), | 1054 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), |
1054 std::string(), false, output, max_matches)); | 1055 std::string(), false, output, max_matches)); |
1055 for (int j = 0; j < max_matches; ++j) { | 1056 for (int j = 0; j < max_matches; ++j) { |
1056 EXPECT_EQ(test_cases[i].matches[j].control_relevance, | 1057 EXPECT_EQ(test_cases[i].matches[j].control_relevance, |
1057 matches_[j].relevance); | 1058 matches_[j].relevance); |
1058 } | 1059 } |
1059 | 1060 |
1060 // Test the experiment (scoring enabled). | 1061 // Test the experiment (scoring enabled). |
1061 autocomplete_->scoring_params_.experimental_scoring_enabled = true; | 1062 autocomplete_->scoring_params_.experimental_scoring_enabled = true; |
1062 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), | 1063 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), |
1063 std::string(), false, output, max_matches)); | 1064 std::string(), false, output, max_matches)); |
1064 for (int j = 0; j < max_matches; ++j) { | 1065 for (int j = 0; j < max_matches; ++j) { |
1065 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, | 1066 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, |
1066 matches_[j].relevance); | 1067 matches_[j].relevance); |
1067 } | 1068 } |
1068 } | 1069 } |
1069 } | 1070 } |
OLD | NEW |