| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 16 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_input.h" | 17 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 19 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 20 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
| 21 #include "chrome/browser/autocomplete/history_url_provider.h" | 21 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 22 #include "chrome/browser/history/history_service.h" | 22 #include "chrome/browser/history/history_service.h" |
| 23 #include "chrome/browser/history/history_service_factory.h" | 23 #include "chrome/browser/history/history_service_factory.h" |
| 24 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 24 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 25 #include "chrome/browser/search/search.h" | |
| 26 #include "chrome/browser/search_engines/template_url.h" | 25 #include "chrome/browser/search_engines/template_url.h" |
| 27 #include "chrome/browser/search_engines/template_url_service.h" | 26 #include "chrome/browser/search_engines/template_url_service.h" |
| 28 #include "chrome/browser/search_engines/template_url_service_factory.h" | 27 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/metrics/variations/variations_util.h" | 29 #include "chrome/common/metrics/variations/variations_util.h" |
| 31 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/test/base/testing_browser_process.h" | 31 #include "chrome/test/base/testing_browser_process.h" |
| 33 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 34 #include "components/variations/entropy_provider.h" | 33 #include "components/variations/entropy_provider.h" |
| 35 #include "content/public/test/test_browser_thread_bundle.h" | 34 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 // case to this test, please consider adding it to the tests in | 931 // case to this test, please consider adding it to the tests in |
| 933 // KeywordFetcherSuggestRelevance below. | 932 // KeywordFetcherSuggestRelevance below. |
| 934 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { | 933 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { |
| 935 struct DefaultFetcherMatch { | 934 struct DefaultFetcherMatch { |
| 936 std::string contents; | 935 std::string contents; |
| 937 bool allowed_to_be_default_match; | 936 bool allowed_to_be_default_match; |
| 938 }; | 937 }; |
| 939 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; | 938 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; |
| 940 struct { | 939 struct { |
| 941 const std::string json; | 940 const std::string json; |
| 942 const DefaultFetcherMatch matches[4]; | 941 const DefaultFetcherMatch matches[6]; |
| 943 const std::string inline_autocompletion; | 942 const std::string inline_autocompletion; |
| 944 } cases[] = { | 943 } cases[] = { |
| 945 // Ensure that suggestrelevance scores reorder matches. | 944 // Ensure that suggestrelevance scores reorder matches. |
| 946 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 945 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
| 947 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, | 946 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, |
| 947 kEmptyMatch, kEmptyMatch }, |
| 948 std::string() }, | 948 std::string() }, |
| 949 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 949 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 950 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 950 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 951 "\"google:suggestrelevance\":[1, 2]}]", | 951 "\"google:suggestrelevance\":[1, 2]}]", |
| 952 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, | 952 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch, |
| 953 kEmptyMatch, kEmptyMatch }, |
| 953 std::string() }, | 954 std::string() }, |
| 954 | 955 |
| 955 // Without suggested relevance scores, we should only allow one | 956 // Without suggested relevance scores, we should only allow one |
| 956 // navsuggest result to be be displayed. | 957 // navsuggest result to be be displayed. |
| 957 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 958 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 958 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 959 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
| 959 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, | 960 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
| 961 kEmptyMatch, kEmptyMatch }, |
| 960 std::string() }, | 962 std::string() }, |
| 961 | 963 |
| 962 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 964 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
| 963 // Negative values will have no effect; the calculated value will be used. | 965 // Negative values will have no effect; the calculated value will be used. |
| 964 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 966 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
| 965 "\"google:suggestrelevance\":[9998]}]", | 967 "\"google:suggestrelevance\":[9998]}]", |
| 966 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 968 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 969 kEmptyMatch }, |
| 967 std::string() }, | 970 std::string() }, |
| 968 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 971 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
| 969 "\"google:suggestrelevance\":[9999]}]", | 972 "\"google:suggestrelevance\":[9999]}]", |
| 970 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 973 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 974 kEmptyMatch }, |
| 971 "1" }, | 975 "1" }, |
| 972 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 976 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
| 973 "\"google:suggestrelevance\":[9999]}]", | 977 "\"google:suggestrelevance\":[9999]}]", |
| 974 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 978 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 979 kEmptyMatch }, |
| 975 "1" }, | 980 "1" }, |
| 976 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 981 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
| 977 "\"google:suggestrelevance\":[9999]}]", | 982 "\"google:suggestrelevance\":[9999]}]", |
| 978 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 983 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 984 kEmptyMatch }, |
| 979 "1" }, | 985 "1" }, |
| 980 { "[\"a\",[\"http://a.com\"],[],[]," | 986 { "[\"a\",[\"http://a.com\"],[],[]," |
| 981 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 987 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 982 "\"google:verbatimrelevance\":9999," | 988 "\"google:verbatimrelevance\":9999," |
| 983 "\"google:suggestrelevance\":[9998]}]", | 989 "\"google:suggestrelevance\":[9998]}]", |
| 984 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, | 990 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 991 kEmptyMatch }, |
| 985 std::string() }, | 992 std::string() }, |
| 986 { "[\"a\",[\"http://a.com\"],[],[]," | 993 { "[\"a\",[\"http://a.com\"],[],[]," |
| 987 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 994 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 988 "\"google:verbatimrelevance\":9998," | 995 "\"google:verbatimrelevance\":9998," |
| 989 "\"google:suggestrelevance\":[9999]}]", | 996 "\"google:suggestrelevance\":[9999]}]", |
| 990 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 997 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 998 kEmptyMatch }, |
| 991 ".com" }, | 999 ".com" }, |
| 992 { "[\"a\",[\"http://a.com\"],[],[]," | 1000 { "[\"a\",[\"http://a.com\"],[],[]," |
| 993 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1001 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 994 "\"google:verbatimrelevance\":0," | 1002 "\"google:verbatimrelevance\":0," |
| 995 "\"google:suggestrelevance\":[9999]}]", | 1003 "\"google:suggestrelevance\":[9999]}]", |
| 996 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1004 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1005 kEmptyMatch }, |
| 997 ".com" }, | 1006 ".com" }, |
| 998 { "[\"a\",[\"http://a.com\"],[],[]," | 1007 { "[\"a\",[\"http://a.com\"],[],[]," |
| 999 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1008 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1000 "\"google:verbatimrelevance\":-1," | 1009 "\"google:verbatimrelevance\":-1," |
| 1001 "\"google:suggestrelevance\":[9999]}]", | 1010 "\"google:suggestrelevance\":[9999]}]", |
| 1002 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1011 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1012 kEmptyMatch }, |
| 1003 ".com" }, | 1013 ".com" }, |
| 1004 | 1014 |
| 1005 // Ensure that both types of relevance scores reorder matches together. | 1015 // Ensure that both types of relevance scores reorder matches together. |
| 1006 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1016 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
| 1007 "\"google:verbatimrelevance\":9998}]", | 1017 "\"google:verbatimrelevance\":9998}]", |
| 1008 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, | 1018 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, |
| 1019 kEmptyMatch }, |
| 1009 "1" }, | 1020 "1" }, |
| 1010 | 1021 |
| 1011 // Ensure that only inlinable matches may be ranked as the highest result. | 1022 // Ensure that only inlinable matches may be ranked as the highest result. |
| 1012 // Ignore all suggested relevance scores if this constraint is violated. | 1023 // Ignore all suggested relevance scores if this constraint is violated. |
| 1013 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1024 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
| 1014 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, | 1025 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1026 kEmptyMatch }, |
| 1015 std::string() }, | 1027 std::string() }, |
| 1016 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1028 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
| 1017 "\"google:verbatimrelevance\":0}]", | 1029 "\"google:verbatimrelevance\":0}]", |
| 1018 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, | 1030 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1031 kEmptyMatch }, |
| 1019 std::string() }, | 1032 std::string() }, |
| 1020 { "[\"a\",[\"http://b.com\"],[],[]," | 1033 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1021 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1034 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1022 "\"google:suggestrelevance\":[9999]}]", | 1035 "\"google:suggestrelevance\":[9999]}]", |
| 1023 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, | 1036 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
| 1037 kEmptyMatch, kEmptyMatch }, |
| 1024 std::string() }, | 1038 std::string() }, |
| 1025 { "[\"a\",[\"http://b.com\"],[],[]," | 1039 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1026 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1040 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1027 "\"google:suggestrelevance\":[9999]," | 1041 "\"google:suggestrelevance\":[9999]," |
| 1028 "\"google:verbatimrelevance\":0}]", | 1042 "\"google:verbatimrelevance\":0}]", |
| 1029 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, | 1043 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
| 1044 kEmptyMatch, kEmptyMatch }, |
| 1030 std::string() }, | 1045 std::string() }, |
| 1031 { "[\"a\",[\"https://a/\"],[],[]," | 1046 { "[\"a\",[\"https://a/\"],[],[]," |
| 1032 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1047 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1033 "\"google:suggestrelevance\":[9999]}]", | 1048 "\"google:suggestrelevance\":[9999]}]", |
| 1034 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1049 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch, |
| 1050 kEmptyMatch, kEmptyMatch }, |
| 1035 std::string() }, | 1051 std::string() }, |
| 1036 | 1052 |
| 1037 // Ensure that the top result is ranked as highly as calculated verbatim. | 1053 // Ensure that the top result is ranked as highly as calculated verbatim. |
| 1038 // Ignore the suggested verbatim relevance if this constraint is violated. | 1054 // Ignore the suggested verbatim relevance if this constraint is violated. |
| 1039 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1055 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
| 1040 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1056 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1057 kEmptyMatch }, |
| 1041 std::string() }, | 1058 std::string() }, |
| 1042 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 1059 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
| 1043 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1060 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1061 kEmptyMatch }, |
| 1044 std::string() }, | 1062 std::string() }, |
| 1045 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 1063 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
| 1046 "\"google:verbatimrelevance\":0}]", | 1064 "\"google:verbatimrelevance\":0}]", |
| 1047 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1065 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1066 kEmptyMatch }, |
| 1048 std::string() }, | 1067 std::string() }, |
| 1049 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 1068 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
| 1050 "\"google:verbatimrelevance\":0}]", | 1069 "\"google:verbatimrelevance\":0}]", |
| 1051 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, | 1070 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1071 kEmptyMatch }, |
| 1052 std::string() }, | 1072 std::string() }, |
| 1053 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 1073 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
| 1054 "\"google:verbatimrelevance\":2}]", | 1074 "\"google:verbatimrelevance\":2}]", |
| 1055 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, | 1075 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1076 kEmptyMatch }, |
| 1056 std::string() }, | 1077 std::string() }, |
| 1057 { "[\"a\",[\"http://a.com\"],[],[]," | 1078 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1058 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1079 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1059 "\"google:suggestrelevance\":[1]," | 1080 "\"google:suggestrelevance\":[1]," |
| 1060 "\"google:verbatimrelevance\":0}]", | 1081 "\"google:verbatimrelevance\":0}]", |
| 1061 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, | 1082 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1083 kEmptyMatch }, |
| 1062 std::string() }, | 1084 std::string() }, |
| 1063 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1085 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1064 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1086 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1065 "\"google:suggestrelevance\":[1, 2]," | 1087 "\"google:suggestrelevance\":[1, 2]," |
| 1066 "\"google:verbatimrelevance\":0}]", | 1088 "\"google:verbatimrelevance\":0}]", |
| 1067 { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch }, | 1089 { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch, |
| 1090 kEmptyMatch, kEmptyMatch }, |
| 1068 std::string() }, | 1091 std::string() }, |
| 1069 | 1092 |
| 1070 // Ensure that all suggestions are considered, regardless of order. | 1093 // Ensure that all suggestions are considered, regardless of order. |
| 1071 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1094 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
| 1072 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1095 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
| 1073 { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, | 1096 { { "a", true }, { "h", false }, { "g", false }, { "f", false }, |
| 1097 {"e", false }, {"d", false } }, |
| 1074 std::string() }, | 1098 std::string() }, |
| 1075 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1099 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
| 1076 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1100 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
| 1077 "\"http://h.com\"],[],[]," | 1101 "\"http://h.com\"],[],[]," |
| 1078 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1102 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
| 1079 "\"NAVIGATION\", \"NAVIGATION\"," | 1103 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1080 "\"NAVIGATION\", \"NAVIGATION\"," | 1104 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1081 "\"NAVIGATION\"]," | 1105 "\"NAVIGATION\"]," |
| 1082 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1106 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
| 1083 { { "a", true }, { "h.com", false }, { "g.com", false }, | 1107 { { "a", true }, { "h.com", false }, { "g.com", false }, |
| 1084 { "f.com", false } }, | 1108 { "f.com", false }, {"e.com", false }, {"d.com", false } }, |
| 1085 std::string() }, | 1109 std::string() }, |
| 1086 | 1110 |
| 1087 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1111 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
| 1088 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1112 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
| 1089 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, | 1113 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, |
| 1114 kEmptyMatch }, |
| 1090 std::string() }, | 1115 std::string() }, |
| 1091 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1116 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
| 1092 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1117 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1118 kEmptyMatch }, |
| 1093 std::string() }, | 1119 std::string() }, |
| 1094 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1120 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1095 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1121 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1096 "\"google:suggestrelevance\":[1]}]", | 1122 "\"google:suggestrelevance\":[1]}]", |
| 1097 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, | 1123 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
| 1124 kEmptyMatch, kEmptyMatch }, |
| 1098 std::string() }, | 1125 std::string() }, |
| 1099 { "[\"a\",[\"http://a1.com\"],[],[]," | 1126 { "[\"a\",[\"http://a1.com\"],[],[]," |
| 1100 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1127 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1101 "\"google:suggestrelevance\":[9999, 1]}]", | 1128 "\"google:suggestrelevance\":[9999, 1]}]", |
| 1102 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, | 1129 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
| 1130 kEmptyMatch, kEmptyMatch }, |
| 1103 std::string() }, | 1131 std::string() }, |
| 1104 | 1132 |
| 1105 // Ensure that all 'verbatim' results are merged with their maximum score. | 1133 // Ensure that all 'verbatim' results are merged with their maximum score. |
| 1106 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1134 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1107 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1135 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1108 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, | 1136 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1137 kEmptyMatch }, |
| 1109 "2" }, | 1138 "2" }, |
| 1110 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1139 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1111 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1140 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
| 1112 "\"google:verbatimrelevance\":0}]", | 1141 "\"google:verbatimrelevance\":0}]", |
| 1113 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, | 1142 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1143 kEmptyMatch }, |
| 1114 "2" }, | 1144 "2" }, |
| 1115 | 1145 |
| 1116 // Ensure that verbatim is always generated without other suggestions. | 1146 // Ensure that verbatim is always generated without other suggestions. |
| 1117 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). | 1147 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). |
| 1118 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1148 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
| 1119 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1149 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1150 kEmptyMatch }, |
| 1120 std::string() }, | 1151 std::string() }, |
| 1121 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1152 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
| 1122 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1153 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1154 kEmptyMatch }, |
| 1123 std::string() }, | 1155 std::string() }, |
| 1124 }; | 1156 }; |
| 1125 | 1157 |
| 1126 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1158 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
| 1127 QueryForInput(ASCIIToUTF16("a"), false, false); | 1159 QueryForInput(ASCIIToUTF16("a"), false, false); |
| 1128 net::TestURLFetcher* fetcher = | 1160 net::TestURLFetcher* fetcher = |
| 1129 test_factory_.GetFetcherByID( | 1161 test_factory_.GetFetcherByID( |
| 1130 SearchProvider::kDefaultProviderURLFetcherID); | 1162 SearchProvider::kDefaultProviderURLFetcherID); |
| 1131 ASSERT_TRUE(fetcher); | 1163 ASSERT_TRUE(fetcher); |
| 1132 fetcher->set_response_code(200); | 1164 fetcher->set_response_code(200); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1163 // causes SearchProvider to allow some constraints to be violated that it | 1195 // causes SearchProvider to allow some constraints to be violated that it |
| 1164 // wouldn't normally because the omnibox will fix the problems later. | 1196 // wouldn't normally because the omnibox will fix the problems later. |
| 1165 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { | 1197 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { |
| 1166 struct DefaultFetcherMatch { | 1198 struct DefaultFetcherMatch { |
| 1167 std::string contents; | 1199 std::string contents; |
| 1168 bool allowed_to_be_default_match; | 1200 bool allowed_to_be_default_match; |
| 1169 }; | 1201 }; |
| 1170 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; | 1202 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; |
| 1171 struct { | 1203 struct { |
| 1172 const std::string json; | 1204 const std::string json; |
| 1173 const DefaultFetcherMatch matches[4]; | 1205 const DefaultFetcherMatch matches[6]; |
| 1174 const std::string inline_autocompletion; | 1206 const std::string inline_autocompletion; |
| 1175 } cases[] = { | 1207 } cases[] = { |
| 1176 // Ensure that suggestrelevance scores reorder matches. | 1208 // Ensure that suggestrelevance scores reorder matches. |
| 1177 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 1209 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
| 1178 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, | 1210 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, kEmptyMatch, |
| 1211 kEmptyMatch }, |
| 1179 std::string() }, | 1212 std::string() }, |
| 1180 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1213 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 1181 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1214 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1182 "\"google:suggestrelevance\":[1, 2]}]", | 1215 "\"google:suggestrelevance\":[1, 2]}]", |
| 1183 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, | 1216 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch, |
| 1217 kEmptyMatch, kEmptyMatch }, |
| 1184 std::string() }, | 1218 std::string() }, |
| 1185 | 1219 |
| 1186 // Without suggested relevance scores, we should only allow one | 1220 // Without suggested relevance scores, we should only allow one |
| 1187 // navsuggest result to be be displayed. | 1221 // navsuggest result to be be displayed. |
| 1188 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1222 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 1189 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 1223 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
| 1190 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, | 1224 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
| 1225 kEmptyMatch, kEmptyMatch }, |
| 1191 std::string() }, | 1226 std::string() }, |
| 1192 | 1227 |
| 1193 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1228 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
| 1194 // Negative values will have no effect; the calculated value will be used. | 1229 // Negative values will have no effect; the calculated value will be used. |
| 1195 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1230 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
| 1196 "\"google:suggestrelevance\":[9998]}]", | 1231 "\"google:suggestrelevance\":[9998]}]", |
| 1197 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1232 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1233 kEmptyMatch }, |
| 1198 std::string() }, | 1234 std::string() }, |
| 1199 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1235 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
| 1200 "\"google:suggestrelevance\":[9999]}]", | 1236 "\"google:suggestrelevance\":[9999]}]", |
| 1201 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1237 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1238 kEmptyMatch }, |
| 1202 "1" }, | 1239 "1" }, |
| 1203 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 1240 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
| 1204 "\"google:suggestrelevance\":[9999]}]", | 1241 "\"google:suggestrelevance\":[9999]}]", |
| 1205 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1242 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1243 kEmptyMatch }, |
| 1206 "1" }, | 1244 "1" }, |
| 1207 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 1245 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
| 1208 "\"google:suggestrelevance\":[9999]}]", | 1246 "\"google:suggestrelevance\":[9999]}]", |
| 1209 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1247 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1248 kEmptyMatch }, |
| 1210 "1" }, | 1249 "1" }, |
| 1211 { "[\"a\",[\"http://a.com\"],[],[]," | 1250 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1212 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1251 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1213 "\"google:verbatimrelevance\":9999," | 1252 "\"google:verbatimrelevance\":9999," |
| 1214 "\"google:suggestrelevance\":[9998]}]", | 1253 "\"google:suggestrelevance\":[9998]}]", |
| 1215 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, | 1254 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1255 kEmptyMatch }, |
| 1216 std::string() }, | 1256 std::string() }, |
| 1217 { "[\"a\",[\"http://a.com\"],[],[]," | 1257 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1218 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1258 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1219 "\"google:verbatimrelevance\":9998," | 1259 "\"google:verbatimrelevance\":9998," |
| 1220 "\"google:suggestrelevance\":[9999]}]", | 1260 "\"google:suggestrelevance\":[9999]}]", |
| 1221 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1261 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1262 kEmptyMatch }, |
| 1222 ".com" }, | 1263 ".com" }, |
| 1223 { "[\"a\",[\"http://a.com\"],[],[]," | 1264 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1224 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1265 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1225 "\"google:verbatimrelevance\":0," | 1266 "\"google:verbatimrelevance\":0," |
| 1226 "\"google:suggestrelevance\":[9999]}]", | 1267 "\"google:suggestrelevance\":[9999]}]", |
| 1227 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1268 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1269 kEmptyMatch }, |
| 1228 ".com" }, | 1270 ".com" }, |
| 1229 { "[\"a\",[\"http://a.com\"],[],[]," | 1271 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1230 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1272 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1231 "\"google:verbatimrelevance\":-1," | 1273 "\"google:verbatimrelevance\":-1," |
| 1232 "\"google:suggestrelevance\":[9999]}]", | 1274 "\"google:suggestrelevance\":[9999]}]", |
| 1233 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1275 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1276 kEmptyMatch }, |
| 1234 ".com" }, | 1277 ".com" }, |
| 1235 | 1278 |
| 1236 // Ensure that both types of relevance scores reorder matches together. | 1279 // Ensure that both types of relevance scores reorder matches together. |
| 1237 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1280 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
| 1238 "\"google:verbatimrelevance\":9998}]", | 1281 "\"google:verbatimrelevance\":9998}]", |
| 1239 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, | 1282 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, |
| 1283 kEmptyMatch }, |
| 1240 "1" }, | 1284 "1" }, |
| 1241 | 1285 |
| 1242 // Allow non-inlineable matches to be the highest-scoring match but, | 1286 // Allow non-inlineable matches to be the highest-scoring match but, |
| 1243 // if the result set lacks a single inlineable result, abandon suggested | 1287 // if the result set lacks a single inlineable result, abandon suggested |
| 1244 // relevance scores entirely. | 1288 // relevance scores entirely. |
| 1245 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1289 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
| 1246 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1290 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1291 kEmptyMatch }, |
| 1247 std::string() }, | 1292 std::string() }, |
| 1248 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1293 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
| 1249 "\"google:verbatimrelevance\":0}]", | 1294 "\"google:verbatimrelevance\":0}]", |
| 1250 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, | 1295 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1296 kEmptyMatch }, |
| 1251 std::string() }, | 1297 std::string() }, |
| 1252 { "[\"a\",[\"http://b.com\"],[],[]," | 1298 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1253 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1299 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1254 "\"google:suggestrelevance\":[9999]}]", | 1300 "\"google:suggestrelevance\":[9999]}]", |
| 1255 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1301 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch, |
| 1302 kEmptyMatch, kEmptyMatch }, |
| 1256 std::string() }, | 1303 std::string() }, |
| 1257 { "[\"a\",[\"http://b.com\"],[],[]," | 1304 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1258 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1305 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1259 "\"google:suggestrelevance\":[9999]," | 1306 "\"google:suggestrelevance\":[9999]," |
| 1260 "\"google:verbatimrelevance\":0}]", | 1307 "\"google:verbatimrelevance\":0}]", |
| 1261 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, | 1308 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
| 1309 kEmptyMatch, kEmptyMatch }, |
| 1262 std::string() }, | 1310 std::string() }, |
| 1263 | 1311 |
| 1264 // Allow low-scoring matches. | 1312 // Allow low-scoring matches. |
| 1265 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1313 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
| 1266 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1314 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1315 kEmptyMatch }, |
| 1267 "1" }, | 1316 "1" }, |
| 1268 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 1317 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
| 1269 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, | 1318 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1319 kEmptyMatch }, |
| 1270 "1" }, | 1320 "1" }, |
| 1271 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 1321 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
| 1272 "\"google:verbatimrelevance\":0}]", | 1322 "\"google:verbatimrelevance\":0}]", |
| 1273 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1323 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1324 kEmptyMatch }, |
| 1274 "1" }, | 1325 "1" }, |
| 1275 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 1326 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
| 1276 "\"google:verbatimrelevance\":0}]", | 1327 "\"google:verbatimrelevance\":0}]", |
| 1277 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1328 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1329 kEmptyMatch }, |
| 1278 "2" }, | 1330 "2" }, |
| 1279 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 1331 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
| 1280 "\"google:verbatimrelevance\":2}]", | 1332 "\"google:verbatimrelevance\":2}]", |
| 1281 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, | 1333 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1334 kEmptyMatch }, |
| 1282 "2" }, | 1335 "2" }, |
| 1283 { "[\"a\",[\"http://a.com\"],[],[]," | 1336 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1284 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1337 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1285 "\"google:suggestrelevance\":[1]," | 1338 "\"google:suggestrelevance\":[1]," |
| 1286 "\"google:verbatimrelevance\":0}]", | 1339 "\"google:verbatimrelevance\":0}]", |
| 1287 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1340 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1341 kEmptyMatch }, |
| 1288 ".com" }, | 1342 ".com" }, |
| 1289 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1343 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1290 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1344 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1291 "\"google:suggestrelevance\":[1, 2]," | 1345 "\"google:suggestrelevance\":[1, 2]," |
| 1292 "\"google:verbatimrelevance\":0}]", | 1346 "\"google:verbatimrelevance\":0}]", |
| 1293 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, | 1347 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
| 1348 kEmptyMatch, kEmptyMatch }, |
| 1294 "2.com" }, | 1349 "2.com" }, |
| 1295 | 1350 |
| 1296 // Ensure that all suggestions are considered, regardless of order. | 1351 // Ensure that all suggestions are considered, regardless of order. |
| 1297 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1352 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
| 1298 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1353 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
| 1299 { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, | 1354 { { "a", true }, { "h", false }, { "g", false }, { "f", false }, |
| 1355 { "e", false }, { "d", false } }, |
| 1300 std::string() }, | 1356 std::string() }, |
| 1301 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1357 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
| 1302 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1358 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
| 1303 "\"http://h.com\"],[],[]," | 1359 "\"http://h.com\"],[],[]," |
| 1304 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1360 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
| 1305 "\"NAVIGATION\", \"NAVIGATION\"," | 1361 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1306 "\"NAVIGATION\", \"NAVIGATION\"," | 1362 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1307 "\"NAVIGATION\"]," | 1363 "\"NAVIGATION\"]," |
| 1308 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1364 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
| 1309 { { "a", true }, { "h.com", false }, { "g.com", false }, | 1365 { { "a", true }, { "h.com", false }, { "g.com", false }, |
| 1310 { "f.com", false } }, | 1366 { "f.com", false }, { "e.com", false }, { "d.com", false } }, |
| 1311 std::string() }, | 1367 std::string() }, |
| 1312 | 1368 |
| 1313 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1369 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
| 1314 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1370 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
| 1315 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, | 1371 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, |
| 1372 kEmptyMatch }, |
| 1316 std::string() }, | 1373 std::string() }, |
| 1317 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1374 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
| 1318 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, | 1375 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1376 kEmptyMatch }, |
| 1319 std::string() }, | 1377 std::string() }, |
| 1320 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1378 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1321 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1379 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1322 "\"google:suggestrelevance\":[1]}]", | 1380 "\"google:suggestrelevance\":[1]}]", |
| 1323 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, | 1381 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
| 1382 kEmptyMatch, kEmptyMatch }, |
| 1324 std::string() }, | 1383 std::string() }, |
| 1325 { "[\"a\",[\"http://a1.com\"],[],[]," | 1384 { "[\"a\",[\"http://a1.com\"],[],[]," |
| 1326 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1385 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1327 "\"google:suggestrelevance\":[9999, 1]}]", | 1386 "\"google:suggestrelevance\":[9999, 1]}]", |
| 1328 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, | 1387 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
| 1388 kEmptyMatch, kEmptyMatch }, |
| 1329 std::string() }, | 1389 std::string() }, |
| 1330 | 1390 |
| 1331 // Ensure that all 'verbatim' results are merged with their maximum score. | 1391 // Ensure that all 'verbatim' results are merged with their maximum score. |
| 1332 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1392 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1333 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1393 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1334 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, | 1394 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1395 kEmptyMatch }, |
| 1335 "2" }, | 1396 "2" }, |
| 1336 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1397 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1337 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1398 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
| 1338 "\"google:verbatimrelevance\":0}]", | 1399 "\"google:verbatimrelevance\":0}]", |
| 1339 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, | 1400 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
| 1401 kEmptyMatch }, |
| 1340 "2" }, | 1402 "2" }, |
| 1341 | 1403 |
| 1342 // Ensure that verbatim is always generated without other suggestions. | 1404 // Ensure that verbatim is always generated without other suggestions. |
| 1343 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). | 1405 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). |
| 1344 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1406 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
| 1345 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1407 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1408 kEmptyMatch }, |
| 1346 std::string() }, | 1409 std::string() }, |
| 1347 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1410 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
| 1348 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1411 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
| 1412 kEmptyMatch }, |
| 1349 std::string() }, | 1413 std::string() }, |
| 1350 }; | 1414 }; |
| 1351 | 1415 |
| 1352 std::map<std::string, std::string> params; | 1416 std::map<std::string, std::string> params; |
| 1353 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) + | 1417 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) + |
| 1354 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled; | 1418 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled; |
| 1355 ASSERT_TRUE(chrome_variations::AssociateVariationParams( | 1419 ASSERT_TRUE(chrome_variations::AssociateVariationParams( |
| 1356 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params)); | 1420 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params)); |
| 1357 base::FieldTrialList::CreateFieldTrial( | 1421 base::FieldTrialList::CreateFieldTrial( |
| 1358 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); | 1422 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 // appropriate to add to DefaultFetcherSuggestRelevance as well. | 1464 // appropriate to add to DefaultFetcherSuggestRelevance as well. |
| 1401 TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { | 1465 TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
| 1402 struct KeywordFetcherMatch { | 1466 struct KeywordFetcherMatch { |
| 1403 std::string contents; | 1467 std::string contents; |
| 1404 bool from_keyword; | 1468 bool from_keyword; |
| 1405 bool allowed_to_be_default_match; | 1469 bool allowed_to_be_default_match; |
| 1406 }; | 1470 }; |
| 1407 const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false }; | 1471 const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false }; |
| 1408 struct { | 1472 struct { |
| 1409 const std::string json; | 1473 const std::string json; |
| 1410 const KeywordFetcherMatch matches[5]; | 1474 const KeywordFetcherMatch matches[6]; |
| 1411 const std::string inline_autocompletion; | 1475 const std::string inline_autocompletion; |
| 1412 } cases[] = { | 1476 } cases[] = { |
| 1413 // Ensure that suggest relevance scores reorder matches and that | 1477 // Ensure that suggest relevance scores reorder matches and that |
| 1414 // the keyword verbatim (lacking a suggested verbatim score) beats | 1478 // the keyword verbatim (lacking a suggested verbatim score) beats |
| 1415 // the default provider verbatim. | 1479 // the default provider verbatim. |
| 1416 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 1480 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
| 1417 { { "a", true, true }, | 1481 { { "a", true, true }, |
| 1418 { "k a", false, true }, | 1482 { "k a", false, true }, |
| 1419 { "c", true, false }, | 1483 { "c", true, false }, |
| 1420 { "b", true, false }, | 1484 { "b", true, false }, |
| 1421 kEmptyMatch }, | 1485 kEmptyMatch, kEmptyMatch }, |
| 1422 std::string() }, | 1486 std::string() }, |
| 1423 // Again, check that relevance scores reorder matches, just this | 1487 // Again, check that relevance scores reorder matches, just this |
| 1424 // time with navigation matches. This also checks that with | 1488 // time with navigation matches. This also checks that with |
| 1425 // suggested relevance scores we allow multiple navsuggest results. | 1489 // suggested relevance scores we allow multiple navsuggest results. |
| 1426 // It's odd that navsuggest results that come from a keyword | 1490 // It's odd that navsuggest results that come from a keyword |
| 1427 // provider are marked as not a keyword result. I think this | 1491 // provider are marked as not a keyword result. I think this |
| 1428 // comes from them not going to a keyword search engine). | 1492 // comes from them not going to a keyword search engine). |
| 1429 // TODO(mpearson): Investigate the implications (if any) of | 1493 // TODO(mpearson): Investigate the implications (if any) of |
| 1430 // tagging these results appropriately. If so, do it because it | 1494 // tagging these results appropriately. If so, do it because it |
| 1431 // makes more sense. | 1495 // makes more sense. |
| 1432 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," | 1496 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," |
| 1433 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1497 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1434 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", | 1498 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", |
| 1435 { { "a", true, true }, | 1499 { { "a", true, true }, |
| 1436 { "d", true, false }, | 1500 { "d", true, false }, |
| 1437 { "c.com", false, false }, | 1501 { "c.com", false, false }, |
| 1438 { "b.com", false, false }, | 1502 { "b.com", false, false }, |
| 1439 { "k a", false, true }, }, | 1503 { "k a", false, true }, |
| 1504 kEmptyMatch }, |
| 1440 std::string() }, | 1505 std::string() }, |
| 1441 | 1506 |
| 1442 // Without suggested relevance scores, we should only allow one | 1507 // Without suggested relevance scores, we should only allow one |
| 1443 // navsuggest result to be be displayed. | 1508 // navsuggest result to be be displayed. |
| 1444 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1509 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 1445 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 1510 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
| 1446 { { "a", true, true }, | 1511 { { "a", true, true }, |
| 1447 { "b.com", false, false }, | 1512 { "b.com", false, false }, |
| 1448 { "k a", false, true }, | 1513 { "k a", false, true }, |
| 1449 kEmptyMatch, kEmptyMatch }, | 1514 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1450 std::string() }, | 1515 std::string() }, |
| 1451 | 1516 |
| 1452 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1517 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
| 1453 // Negative values will have no effect; the calculated value will be used. | 1518 // Negative values will have no effect; the calculated value will be used. |
| 1454 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1519 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
| 1455 "\"google:suggestrelevance\":[9998]}]", | 1520 "\"google:suggestrelevance\":[9998]}]", |
| 1456 { { "a", true, true }, | 1521 { { "a", true, true }, |
| 1457 { "a1", true, true }, | 1522 { "a1", true, true }, |
| 1458 { "k a", false, true }, | 1523 { "k a", false, true }, |
| 1459 kEmptyMatch, kEmptyMatch }, | 1524 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1460 std::string() }, | 1525 std::string() }, |
| 1461 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1526 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
| 1462 "\"google:suggestrelevance\":[9999]}]", | 1527 "\"google:suggestrelevance\":[9999]}]", |
| 1463 { { "a1", true, true }, | 1528 { { "a1", true, true }, |
| 1464 { "a", true, true }, | 1529 { "a", true, true }, |
| 1465 { "k a", false, true }, | 1530 { "k a", false, true }, |
| 1466 kEmptyMatch, kEmptyMatch }, | 1531 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1467 "1" }, | 1532 "1" }, |
| 1468 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 1533 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
| 1469 "\"google:suggestrelevance\":[9999]}]", | 1534 "\"google:suggestrelevance\":[9999]}]", |
| 1470 { { "a1", true, true }, | 1535 { { "a1", true, true }, |
| 1471 { "k a", false, true }, | 1536 { "k a", false, true }, |
| 1472 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1537 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1473 "1" }, | 1538 "1" }, |
| 1474 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 1539 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
| 1475 "\"google:suggestrelevance\":[9999]}]", | 1540 "\"google:suggestrelevance\":[9999]}]", |
| 1476 { { "a1", true, true }, | 1541 { { "a1", true, true }, |
| 1477 { "a", true, true }, | 1542 { "a", true, true }, |
| 1478 { "k a", false, true }, | 1543 { "k a", false, true }, |
| 1479 kEmptyMatch, kEmptyMatch }, | 1544 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1480 "1" }, | 1545 "1" }, |
| 1481 { "[\"a\",[\"http://a.com\"],[],[]," | 1546 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1482 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1547 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1483 "\"google:verbatimrelevance\":9999," | 1548 "\"google:verbatimrelevance\":9999," |
| 1484 "\"google:suggestrelevance\":[9998]}]", | 1549 "\"google:suggestrelevance\":[9998]}]", |
| 1485 { { "a", true, true }, | 1550 { { "a", true, true }, |
| 1486 { "a.com", false, true }, | 1551 { "a.com", false, true }, |
| 1487 { "k a", false, true }, | 1552 { "k a", false, true }, |
| 1488 kEmptyMatch, kEmptyMatch }, | 1553 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1489 std::string() }, | 1554 std::string() }, |
| 1490 | 1555 |
| 1491 // Ensure that both types of relevance scores reorder matches together. | 1556 // Ensure that both types of relevance scores reorder matches together. |
| 1492 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1557 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
| 1493 "\"google:verbatimrelevance\":9998}]", | 1558 "\"google:verbatimrelevance\":9998}]", |
| 1494 { { "a1", true, true }, | 1559 { { "a1", true, true }, |
| 1495 { "a", true, true }, | 1560 { "a", true, true }, |
| 1496 { "a2", true, true }, | 1561 { "a2", true, true }, |
| 1497 { "k a", false, true }, | 1562 { "k a", false, true }, |
| 1498 kEmptyMatch }, | 1563 kEmptyMatch, kEmptyMatch }, |
| 1499 "1" }, | 1564 "1" }, |
| 1500 | 1565 |
| 1501 // Ensure that only inlinable matches may be ranked as the highest result. | 1566 // Ensure that only inlinable matches may be ranked as the highest result. |
| 1502 // Ignore all suggested relevance scores if this constraint is violated. | 1567 // Ignore all suggested relevance scores if this constraint is violated. |
| 1503 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1568 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
| 1504 { { "a", true, true }, | 1569 { { "a", true, true }, |
| 1505 { "b", true, false }, | 1570 { "b", true, false }, |
| 1506 { "k a", false, true }, | 1571 { "k a", false, true }, |
| 1507 kEmptyMatch, kEmptyMatch }, | 1572 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1508 std::string() }, | 1573 std::string() }, |
| 1509 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1574 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
| 1510 "\"google:verbatimrelevance\":0}]", | 1575 "\"google:verbatimrelevance\":0}]", |
| 1511 { { "a", true, true }, | 1576 { { "a", true, true }, |
| 1512 { "b", true, false }, | 1577 { "b", true, false }, |
| 1513 { "k a", false, true }, | 1578 { "k a", false, true }, |
| 1514 kEmptyMatch, kEmptyMatch }, | 1579 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1515 std::string() }, | 1580 std::string() }, |
| 1516 { "[\"a\",[\"http://b.com\"],[],[]," | 1581 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1517 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1582 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1518 "\"google:suggestrelevance\":[9999]}]", | 1583 "\"google:suggestrelevance\":[9999]}]", |
| 1519 { { "a", true, true }, | 1584 { { "a", true, true }, |
| 1520 { "b.com", false, false }, | 1585 { "b.com", false, false }, |
| 1521 { "k a", false, true }, | 1586 { "k a", false, true }, |
| 1522 kEmptyMatch, kEmptyMatch }, | 1587 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1523 std::string() }, | 1588 std::string() }, |
| 1524 { "[\"a\",[\"http://b.com\"],[],[]," | 1589 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1525 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1590 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1526 "\"google:suggestrelevance\":[9999]," | 1591 "\"google:suggestrelevance\":[9999]," |
| 1527 "\"google:verbatimrelevance\":0}]", | 1592 "\"google:verbatimrelevance\":0}]", |
| 1528 { { "a", true, true }, | 1593 { { "a", true, true }, |
| 1529 { "b.com", false, false }, | 1594 { "b.com", false, false }, |
| 1530 { "k a", false, true }, | 1595 { "k a", false, true }, |
| 1531 kEmptyMatch, kEmptyMatch }, | 1596 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1532 std::string() }, | 1597 std::string() }, |
| 1533 | 1598 |
| 1534 // Ensure that the top result is ranked as highly as calculated verbatim. | 1599 // Ensure that the top result is ranked as highly as calculated verbatim. |
| 1535 // Ignore the suggested verbatim relevance if this constraint is violated. | 1600 // Ignore the suggested verbatim relevance if this constraint is violated. |
| 1536 // Note that keyword suggestions by default (not in suggested relevance | 1601 // Note that keyword suggestions by default (not in suggested relevance |
| 1537 // mode) score more highly than the default verbatim. | 1602 // mode) score more highly than the default verbatim. |
| 1538 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1603 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
| 1539 { { "a", true, true }, | 1604 { { "a", true, true }, |
| 1540 { "a1", true, true }, | 1605 { "a1", true, true }, |
| 1541 { "k a", false, true }, | 1606 { "k a", false, true }, |
| 1542 kEmptyMatch, kEmptyMatch }, | 1607 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1543 std::string() }, | 1608 std::string() }, |
| 1544 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 1609 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
| 1545 { { "a", true, true }, | 1610 { { "a", true, true }, |
| 1546 { "a1", true, true }, | 1611 { "a1", true, true }, |
| 1547 { "k a", false, true }, | 1612 { "k a", false, true }, |
| 1548 kEmptyMatch, kEmptyMatch}, | 1613 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1549 std::string() }, | 1614 std::string() }, |
| 1550 // Continuing the same category of tests, but make sure we keep the | 1615 // Continuing the same category of tests, but make sure we keep the |
| 1551 // suggested relevance scores even as we discard the verbatim relevance | 1616 // suggested relevance scores even as we discard the verbatim relevance |
| 1552 // scores. | 1617 // scores. |
| 1553 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 1618 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
| 1554 "\"google:verbatimrelevance\":0}]", | 1619 "\"google:verbatimrelevance\":0}]", |
| 1555 { { "a", true, true }, | 1620 { { "a", true, true }, |
| 1556 { "k a", false, true }, | 1621 { "k a", false, true }, |
| 1557 { "a1", true, true }, | 1622 { "a1", true, true }, |
| 1558 kEmptyMatch, kEmptyMatch}, | 1623 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1559 std::string() }, | 1624 std::string() }, |
| 1560 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 1625 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
| 1561 "\"google:verbatimrelevance\":0}]", | 1626 "\"google:verbatimrelevance\":0}]", |
| 1562 { { "a", true, true }, | 1627 { { "a", true, true }, |
| 1563 { "k a", false, true }, | 1628 { "k a", false, true }, |
| 1564 { "a2", true, true }, | 1629 { "a2", true, true }, |
| 1565 { "a1", true, true }, | 1630 { "a1", true, true }, |
| 1566 kEmptyMatch }, | 1631 kEmptyMatch, kEmptyMatch }, |
| 1567 std::string() }, | 1632 std::string() }, |
| 1568 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 1633 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
| 1569 "\"google:verbatimrelevance\":2}]", | 1634 "\"google:verbatimrelevance\":2}]", |
| 1570 { { "a", true, true }, | 1635 { { "a", true, true }, |
| 1571 { "k a", false, true }, | 1636 { "k a", false, true }, |
| 1572 { "a2", true, true }, | 1637 { "a2", true, true }, |
| 1573 { "a1", true, true }, | 1638 { "a1", true, true }, |
| 1574 kEmptyMatch }, | 1639 kEmptyMatch, kEmptyMatch }, |
| 1575 std::string() }, | 1640 std::string() }, |
| 1576 | 1641 |
| 1577 // Ensure that all suggestions are considered, regardless of order. | 1642 // Ensure that all suggestions are considered, regardless of order. |
| 1578 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1643 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
| 1579 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1644 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
| 1580 { { "a", true, true }, | 1645 { { "a", true, true }, |
| 1581 { "k a", false, true }, | 1646 { "k a", false, true }, |
| 1582 { "h", true, false }, | 1647 { "h", true, false }, |
| 1583 { "g", true, false }, | 1648 { "g", true, false }, |
| 1584 { "f", true, false } }, | 1649 { "f", true, false }, |
| 1650 { "e", true, false } }, |
| 1585 std::string() }, | 1651 std::string() }, |
| 1586 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1652 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
| 1587 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1653 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
| 1588 "\"http://h.com\"],[],[]," | 1654 "\"http://h.com\"],[],[]," |
| 1589 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1655 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
| 1590 "\"NAVIGATION\", \"NAVIGATION\"," | 1656 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1591 "\"NAVIGATION\", \"NAVIGATION\"," | 1657 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1592 "\"NAVIGATION\"]," | 1658 "\"NAVIGATION\"]," |
| 1593 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1659 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
| 1594 { { "a", true, true }, | 1660 { { "a", true, true }, |
| 1595 { "k a", false, true }, | 1661 { "k a", false, true }, |
| 1596 { "h.com", false, false }, | 1662 { "h.com", false, false }, |
| 1597 { "g.com", false, false }, | 1663 { "g.com", false, false }, |
| 1598 { "f.com", false, false } }, | 1664 { "f.com", false, false }, |
| 1665 { "e.com", false, false } }, |
| 1599 std::string() }, | 1666 std::string() }, |
| 1600 | 1667 |
| 1601 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1668 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
| 1602 // Note that keyword suggestions by default (not in suggested relevance | 1669 // Note that keyword suggestions by default (not in suggested relevance |
| 1603 // mode) score more highly than the default verbatim. | 1670 // mode) score more highly than the default verbatim. |
| 1604 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1671 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
| 1605 { { "a", true, true }, | 1672 { { "a", true, true }, |
| 1606 { "a1", true, true }, | 1673 { "a1", true, true }, |
| 1607 { "a2", true, true }, | 1674 { "a2", true, true }, |
| 1608 { "k a", false, true }, | 1675 { "k a", false, true }, |
| 1609 kEmptyMatch }, | 1676 kEmptyMatch, kEmptyMatch }, |
| 1610 std::string() }, | 1677 std::string() }, |
| 1611 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1678 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
| 1612 { { "a", true, true }, | 1679 { { "a", true, true }, |
| 1613 { "a1", true, true }, | 1680 { "a1", true, true }, |
| 1614 { "k a", false, true }, | 1681 { "k a", false, true }, |
| 1615 kEmptyMatch, kEmptyMatch}, | 1682 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1616 std::string() }, | 1683 std::string() }, |
| 1617 // In this case, ignored the suggested relevance scores means we keep | 1684 // In this case, ignored the suggested relevance scores means we keep |
| 1618 // only one navsuggest result. | 1685 // only one navsuggest result. |
| 1619 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1686 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1620 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1687 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1621 "\"google:suggestrelevance\":[1]}]", | 1688 "\"google:suggestrelevance\":[1]}]", |
| 1622 { { "a", true, true }, | 1689 { { "a", true, true }, |
| 1623 { "a1.com", false, true }, | 1690 { "a1.com", false, true }, |
| 1624 { "k a", false, true }, | 1691 { "k a", false, true }, |
| 1625 kEmptyMatch, kEmptyMatch}, | 1692 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1626 std::string() }, | 1693 std::string() }, |
| 1627 { "[\"a\",[\"http://a1.com\"],[],[]," | 1694 { "[\"a\",[\"http://a1.com\"],[],[]," |
| 1628 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1695 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1629 "\"google:suggestrelevance\":[9999, 1]}]", | 1696 "\"google:suggestrelevance\":[9999, 1]}]", |
| 1630 { { "a", true, true }, | 1697 { { "a", true, true }, |
| 1631 { "a1.com", false, true }, | 1698 { "a1.com", false, true }, |
| 1632 { "k a", false, true }, | 1699 { "k a", false, true }, |
| 1633 kEmptyMatch, kEmptyMatch}, | 1700 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1634 std::string() }, | 1701 std::string() }, |
| 1635 | 1702 |
| 1636 // Ensure that all 'verbatim' results are merged with their maximum score. | 1703 // Ensure that all 'verbatim' results are merged with their maximum score. |
| 1637 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1704 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1638 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1705 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1639 { { "a2", true, true }, | 1706 { { "a2", true, true }, |
| 1640 { "a", true, true }, | 1707 { "a", true, true }, |
| 1641 { "a1", true, true }, | 1708 { "a1", true, true }, |
| 1642 { "k a", false, true }, | 1709 { "k a", false, true }, |
| 1643 kEmptyMatch }, | 1710 kEmptyMatch, kEmptyMatch }, |
| 1644 "2" }, | 1711 "2" }, |
| 1645 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1712 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1646 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1713 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
| 1647 "\"google:verbatimrelevance\":0}]", | 1714 "\"google:verbatimrelevance\":0}]", |
| 1648 { { "a2", true, true }, | 1715 { { "a2", true, true }, |
| 1649 { "a", true, true }, | 1716 { "a", true, true }, |
| 1650 { "a1", true, true }, | 1717 { "a1", true, true }, |
| 1651 { "k a", false, true }, | 1718 { "k a", false, true }, |
| 1652 kEmptyMatch }, | 1719 kEmptyMatch, kEmptyMatch }, |
| 1653 "2" }, | 1720 "2" }, |
| 1654 | 1721 |
| 1655 // Ensure that verbatim is always generated without other suggestions. | 1722 // Ensure that verbatim is always generated without other suggestions. |
| 1656 // TODO(mpearson): Ensure the value of verbatimrelevance is respected | 1723 // TODO(mpearson): Ensure the value of verbatimrelevance is respected |
| 1657 // (except when suggested relevances are ignored). | 1724 // (except when suggested relevances are ignored). |
| 1658 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1725 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
| 1659 { { "a", true, true }, | 1726 { { "a", true, true }, |
| 1660 { "k a", false, true }, | 1727 { "k a", false, true }, |
| 1661 kEmptyMatch, kEmptyMatch, kEmptyMatch}, | 1728 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1662 std::string() }, | 1729 std::string() }, |
| 1663 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1730 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
| 1664 { { "a", true, true }, | 1731 { { "a", true, true }, |
| 1665 { "k a", false, true }, | 1732 { "k a", false, true }, |
| 1666 kEmptyMatch, kEmptyMatch, kEmptyMatch}, | 1733 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1667 std::string() }, | 1734 std::string() }, |
| 1668 | 1735 |
| 1669 // Check that navsuggestions will be demoted below queries. | 1736 // Check that navsuggestions will be demoted below queries. |
| 1670 // (Navsuggestions are not allowed to appear first.) In the process, | 1737 // (Navsuggestions are not allowed to appear first.) In the process, |
| 1671 // make sure the navsuggestions still remain in the same order. | 1738 // make sure the navsuggestions still remain in the same order. |
| 1672 // First, check the situation where navsuggest scores more than verbatim | 1739 // First, check the situation where navsuggest scores more than verbatim |
| 1673 // and there are no query suggestions. | 1740 // and there are no query suggestions. |
| 1674 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1741 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1675 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1742 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1676 "\"google:verbatimrelevance\":9990," | 1743 "\"google:verbatimrelevance\":9990," |
| 1677 "\"google:suggestrelevance\":[9998, 9999]}]", | 1744 "\"google:suggestrelevance\":[9998, 9999]}]", |
| 1678 { { "a", true, true }, | 1745 { { "a", true, true }, |
| 1679 { "a2.com", false, true }, | 1746 { "a2.com", false, true }, |
| 1680 { "a1.com", false, true }, | 1747 { "a1.com", false, true }, |
| 1681 { "k a", false, true }, | 1748 { "k a", false, true }, |
| 1682 kEmptyMatch }, | 1749 kEmptyMatch, kEmptyMatch }, |
| 1683 std::string() }, | 1750 std::string() }, |
| 1684 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1751 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1685 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1752 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1686 "\"google:verbatimrelevance\":9990," | 1753 "\"google:verbatimrelevance\":9990," |
| 1687 "\"google:suggestrelevance\":[9999, 9998]}]", | 1754 "\"google:suggestrelevance\":[9999, 9998]}]", |
| 1688 { { "a", true, true }, | 1755 { { "a", true, true }, |
| 1689 { "a1.com", false, true }, | 1756 { "a1.com", false, true }, |
| 1690 { "a2.com", false, true }, | 1757 { "a2.com", false, true }, |
| 1691 { "k a", false, true }, | 1758 { "k a", false, true }, |
| 1692 kEmptyMatch }, | 1759 kEmptyMatch, kEmptyMatch }, |
| 1693 std::string() }, | 1760 std::string() }, |
| 1694 { "[\"a\",[\"https://a/\"],[],[]," | 1761 { "[\"a\",[\"https://a/\"],[],[]," |
| 1695 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1762 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1696 "\"google:suggestrelevance\":[9999]}]", | 1763 "\"google:suggestrelevance\":[9999]}]", |
| 1697 { { "a", true, true }, | 1764 { { "a", true, true }, |
| 1698 { "https://a", false, true }, | 1765 { "https://a", false, true }, |
| 1699 { "k a", false, true }, | 1766 { "k a", false, true }, |
| 1700 kEmptyMatch, | 1767 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1701 kEmptyMatch }, | |
| 1702 std::string() }, | 1768 std::string() }, |
| 1703 // Check when navsuggest scores more than verbatim and there is query | 1769 // Check when navsuggest scores more than verbatim and there is query |
| 1704 // suggestion but it scores lower. | 1770 // suggestion but it scores lower. |
| 1705 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1771 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1706 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1772 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1707 "\"google:verbatimrelevance\":9990," | 1773 "\"google:verbatimrelevance\":9990," |
| 1708 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", | 1774 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
| 1709 { { "a", true, true }, | 1775 { { "a", true, true }, |
| 1710 { "a2.com", false, true }, | 1776 { "a2.com", false, true }, |
| 1711 { "a1.com", false, true }, | 1777 { "a1.com", false, true }, |
| 1712 { "a3", true, true }, | 1778 { "a3", true, true }, |
| 1713 { "k a", false, true } }, | 1779 { "k a", false, true }, |
| 1780 kEmptyMatch }, |
| 1714 std::string() }, | 1781 std::string() }, |
| 1715 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1782 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1716 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1783 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1717 "\"google:verbatimrelevance\":9990," | 1784 "\"google:verbatimrelevance\":9990," |
| 1718 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", | 1785 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
| 1719 { { "a", true, true }, | 1786 { { "a", true, true }, |
| 1720 { "a1.com", false, true }, | 1787 { "a1.com", false, true }, |
| 1721 { "a2.com", false, true }, | 1788 { "a2.com", false, true }, |
| 1722 { "a3", true, true }, | 1789 { "a3", true, true }, |
| 1723 { "k a", false, true } }, | 1790 { "k a", false, true }, |
| 1791 kEmptyMatch }, |
| 1724 std::string() }, | 1792 std::string() }, |
| 1725 // Check when navsuggest scores more than a query suggestion. There is | 1793 // Check when navsuggest scores more than a query suggestion. There is |
| 1726 // a verbatim but it scores lower. | 1794 // a verbatim but it scores lower. |
| 1727 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1795 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1728 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1796 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1729 "\"google:verbatimrelevance\":9990," | 1797 "\"google:verbatimrelevance\":9990," |
| 1730 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1798 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
| 1731 { { "a3", true, true }, | 1799 { { "a3", true, true }, |
| 1732 { "a2.com", false, true }, | 1800 { "a2.com", false, true }, |
| 1733 { "a1.com", false, true }, | 1801 { "a1.com", false, true }, |
| 1734 { "a", true, true }, | 1802 { "a", true, true }, |
| 1735 { "k a", false, true } }, | 1803 { "k a", false, true }, |
| 1804 kEmptyMatch }, |
| 1736 "3" }, | 1805 "3" }, |
| 1737 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1806 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1738 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1807 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1739 "\"google:verbatimrelevance\":9990," | 1808 "\"google:verbatimrelevance\":9990," |
| 1740 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 1809 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
| 1741 { { "a3", true, true }, | 1810 { { "a3", true, true }, |
| 1742 { "a1.com", false, true }, | 1811 { "a1.com", false, true }, |
| 1743 { "a2.com", false, true }, | 1812 { "a2.com", false, true }, |
| 1744 { "a", true, true }, | 1813 { "a", true, true }, |
| 1745 { "k a", false, true } }, | 1814 { "k a", false, true }, |
| 1815 kEmptyMatch }, |
| 1746 "3" }, | 1816 "3" }, |
| 1747 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1817 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1748 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1818 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1749 "\"google:verbatimrelevance\":0," | 1819 "\"google:verbatimrelevance\":0," |
| 1750 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1820 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
| 1751 { { "a3", true, true }, | 1821 { { "a3", true, true }, |
| 1752 { "a2.com", false, true }, | 1822 { "a2.com", false, true }, |
| 1753 { "a1.com", false, true }, | 1823 { "a1.com", false, true }, |
| 1754 { "k a", false, true }, | 1824 { "k a", false, true }, |
| 1755 kEmptyMatch }, | 1825 kEmptyMatch, kEmptyMatch }, |
| 1756 "3" }, | 1826 "3" }, |
| 1757 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1827 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1758 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1828 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1759 "\"google:verbatimrelevance\":0," | 1829 "\"google:verbatimrelevance\":0," |
| 1760 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 1830 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
| 1761 { { "a3", true, true }, | 1831 { { "a3", true, true }, |
| 1762 { "a1.com", false, true }, | 1832 { "a1.com", false, true }, |
| 1763 { "a2.com", false, true }, | 1833 { "a2.com", false, true }, |
| 1764 { "k a", false, true }, | 1834 { "k a", false, true }, |
| 1765 kEmptyMatch }, | 1835 kEmptyMatch, kEmptyMatch }, |
| 1766 "3" }, | 1836 "3" }, |
| 1767 // Check when there is neither verbatim nor a query suggestion that, | 1837 // Check when there is neither verbatim nor a query suggestion that, |
| 1768 // because we can't demote navsuggestions below a query suggestion, | 1838 // because we can't demote navsuggestions below a query suggestion, |
| 1769 // we abandon suggested relevance scores entirely. One consequence is | 1839 // we abandon suggested relevance scores entirely. One consequence is |
| 1770 // that this means we restore the keyword verbatim match. Note | 1840 // that this means we restore the keyword verbatim match. Note |
| 1771 // that in this case of abandoning suggested relevance scores, we still | 1841 // that in this case of abandoning suggested relevance scores, we still |
| 1772 // keep the navsuggestions in the same order, but we revert to only allowing | 1842 // keep the navsuggestions in the same order, but we revert to only allowing |
| 1773 // one navigation to appear because the scores are completely local. | 1843 // one navigation to appear because the scores are completely local. |
| 1774 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1844 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1775 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1845 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1776 "\"google:verbatimrelevance\":0," | 1846 "\"google:verbatimrelevance\":0," |
| 1777 "\"google:suggestrelevance\":[9998, 9999]}]", | 1847 "\"google:suggestrelevance\":[9998, 9999]}]", |
| 1778 { { "a", true, true }, | 1848 { { "a", true, true }, |
| 1779 { "a2.com", false, true }, | 1849 { "a2.com", false, true }, |
| 1780 { "k a", false, true }, | 1850 { "k a", false, true }, |
| 1781 kEmptyMatch, kEmptyMatch}, | 1851 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1782 std::string() }, | 1852 std::string() }, |
| 1783 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1853 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1784 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1854 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1785 "\"google:verbatimrelevance\":0," | 1855 "\"google:verbatimrelevance\":0," |
| 1786 "\"google:suggestrelevance\":[9999, 9998]}]", | 1856 "\"google:suggestrelevance\":[9999, 9998]}]", |
| 1787 { { "a", true, true }, | 1857 { { "a", true, true }, |
| 1788 { "a1.com", false, true }, | 1858 { "a1.com", false, true }, |
| 1789 { "k a", false, true }, | 1859 { "k a", false, true }, |
| 1790 kEmptyMatch, kEmptyMatch}, | 1860 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1791 std::string() }, | 1861 std::string() }, |
| 1792 // More checks that everything works when it's not necessary to demote. | 1862 // More checks that everything works when it's not necessary to demote. |
| 1793 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1863 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1794 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1864 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1795 "\"google:verbatimrelevance\":9990," | 1865 "\"google:verbatimrelevance\":9990," |
| 1796 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", | 1866 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
| 1797 { { "a3", true, true }, | 1867 { { "a3", true, true }, |
| 1798 { "a2.com", false, true }, | 1868 { "a2.com", false, true }, |
| 1799 { "a1.com", false, true }, | 1869 { "a1.com", false, true }, |
| 1800 { "a", true, true }, | 1870 { "a", true, true }, |
| 1801 { "k a", false, true } }, | 1871 { "k a", false, true }, |
| 1872 kEmptyMatch }, |
| 1802 "3" }, | 1873 "3" }, |
| 1803 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1874 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1804 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1875 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1805 "\"google:verbatimrelevance\":9990," | 1876 "\"google:verbatimrelevance\":9990," |
| 1806 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1877 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1807 { { "a3", true, true }, | 1878 { { "a3", true, true }, |
| 1808 { "a1.com", false, true }, | 1879 { "a1.com", false, true }, |
| 1809 { "a2.com", false, true }, | 1880 { "a2.com", false, true }, |
| 1810 { "a", true, true }, | 1881 { "a", true, true }, |
| 1811 { "k a", false, true } }, | 1882 { "k a", false, true }, |
| 1883 kEmptyMatch }, |
| 1812 "3" }, | 1884 "3" }, |
| 1813 }; | 1885 }; |
| 1814 | 1886 |
| 1815 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1887 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
| 1816 QueryForInput(ASCIIToUTF16("k a"), false, true); | 1888 QueryForInput(ASCIIToUTF16("k a"), false, true); |
| 1817 | 1889 |
| 1818 // Set up a default fetcher with no results. | 1890 // Set up a default fetcher with no results. |
| 1819 net::TestURLFetcher* default_fetcher = | 1891 net::TestURLFetcher* default_fetcher = |
| 1820 test_factory_.GetFetcherByID( | 1892 test_factory_.GetFetcherByID( |
| 1821 SearchProvider::kDefaultProviderURLFetcherID); | 1893 SearchProvider::kDefaultProviderURLFetcherID); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 matches[j].allowed_to_be_default_match) << description; | 1926 matches[j].allowed_to_be_default_match) << description; |
| 1855 } | 1927 } |
| 1856 // Ensure that no expected matches are missing. | 1928 // Ensure that no expected matches are missing. |
| 1857 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) | 1929 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) |
| 1858 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << | 1930 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << |
| 1859 "Case # " << i << " " << description; | 1931 "Case # " << i << " " << description; |
| 1860 } | 1932 } |
| 1861 } | 1933 } |
| 1862 | 1934 |
| 1863 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { | 1935 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { |
| 1864 // Enable Instant Extended in order to allow an increased number of | |
| 1865 // suggestions. | |
| 1866 chrome::EnableInstantExtendedAPIForTesting(); | |
| 1867 | |
| 1868 // We hardcode the string "term1" below, so ensure that the search term that | 1936 // We hardcode the string "term1" below, so ensure that the search term that |
| 1869 // got added to history already is that string. | 1937 // got added to history already is that string. |
| 1870 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); | 1938 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); |
| 1871 string16 term = term1_.substr(0, term1_.length() - 1); | 1939 string16 term = term1_.substr(0, term1_.length() - 1); |
| 1872 | 1940 |
| 1873 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); | 1941 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); |
| 1874 profile_.BlockUntilHistoryProcessesPendingRequests(); | 1942 profile_.BlockUntilHistoryProcessesPendingRequests(); |
| 1875 | 1943 |
| 1876 struct { | 1944 struct { |
| 1877 const string16 input; | 1945 const string16 input; |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2640 SCOPED_TRACE(description); | 2708 SCOPED_TRACE(description); |
| 2641 EXPECT_EQ(cases[i].matches[j].contents, UTF16ToUTF8(matches[j].contents)); | 2709 EXPECT_EQ(cases[i].matches[j].contents, UTF16ToUTF8(matches[j].contents)); |
| 2642 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, | 2710 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, |
| 2643 SearchProvider::ShouldPrefetch(matches[j])); | 2711 SearchProvider::ShouldPrefetch(matches[j])); |
| 2644 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); | 2712 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); |
| 2645 EXPECT_EQ(cases[i].matches[j].from_keyword, | 2713 EXPECT_EQ(cases[i].matches[j].from_keyword, |
| 2646 matches[j].keyword == ASCIIToUTF16("k")); | 2714 matches[j].keyword == ASCIIToUTF16("k")); |
| 2647 } | 2715 } |
| 2648 } | 2716 } |
| 2649 } | 2717 } |
| OLD | NEW |