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

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 19 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
20 #include "chrome/browser/autocomplete/autocomplete_controller.h" 20 #include "chrome/browser/autocomplete/autocomplete_controller.h"
21 #include "chrome/browser/autocomplete/autocomplete_input.h" 21 #include "chrome/browser/autocomplete/autocomplete_input.h"
22 #include "chrome/browser/autocomplete/autocomplete_match.h" 22 #include "chrome/browser/autocomplete/autocomplete_match.h"
23 #include "chrome/browser/autocomplete/autocomplete_provider.h" 23 #include "chrome/browser/autocomplete/autocomplete_provider.h"
24 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 24 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
25 #include "chrome/browser/autocomplete/history_url_provider.h" 25 #include "chrome/browser/autocomplete/history_url_provider.h"
26 #include "chrome/browser/history/history_service.h" 26 #include "chrome/browser/history/history_service.h"
27 #include "chrome/browser/history/history_service_factory.h" 27 #include "chrome/browser/history/history_service_factory.h"
28 #include "chrome/browser/omnibox/omnibox_field_trial.h" 28 #include "chrome/browser/omnibox/omnibox_field_trial.h"
29 #include "chrome/browser/search/search.h"
30 #include "chrome/browser/search_engines/search_engine_type.h" 29 #include "chrome/browser/search_engines/search_engine_type.h"
31 #include "chrome/browser/search_engines/template_url.h" 30 #include "chrome/browser/search_engines/template_url.h"
32 #include "chrome/browser/search_engines/template_url_service.h" 31 #include "chrome/browser/search_engines/template_url_service.h"
33 #include "chrome/browser/search_engines/template_url_service_factory.h" 32 #include "chrome/browser/search_engines/template_url_service_factory.h"
34 #include "chrome/browser/signin/signin_manager.h" 33 #include "chrome/browser/signin/signin_manager.h"
35 #include "chrome/browser/signin/signin_manager_factory.h" 34 #include "chrome/browser/signin/signin_manager_factory.h"
36 #include "chrome/browser/sync/profile_sync_service.h" 35 #include "chrome/browser/sync/profile_sync_service.h"
37 #include "chrome/browser/sync/profile_sync_service_factory.h" 36 #include "chrome/browser/sync/profile_sync_service_factory.h"
38 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
39 #include "chrome/common/metrics/variations/variations_util.h" 38 #include "chrome/common/metrics/variations/variations_util.h"
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 // case to this test, please consider adding it to the tests in 1033 // case to this test, please consider adding it to the tests in
1035 // KeywordFetcherSuggestRelevance below. 1034 // KeywordFetcherSuggestRelevance below.
1036 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { 1035 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) {
1037 struct DefaultFetcherMatch { 1036 struct DefaultFetcherMatch {
1038 std::string contents; 1037 std::string contents;
1039 bool allowed_to_be_default_match; 1038 bool allowed_to_be_default_match;
1040 }; 1039 };
1041 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; 1040 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false };
1042 struct { 1041 struct {
1043 const std::string json; 1042 const std::string json;
1044 const DefaultFetcherMatch matches[4]; 1043 const DefaultFetcherMatch matches[6];
1045 const std::string inline_autocompletion; 1044 const std::string inline_autocompletion;
1046 } cases[] = { 1045 } cases[] = {
1047 // Ensure that suggestrelevance scores reorder matches. 1046 // Ensure that suggestrelevance scores reorder matches.
1048 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 1047 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
1049 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, 1048 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch,
1049 kEmptyMatch, kEmptyMatch },
1050 std::string() }, 1050 std::string() },
1051 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1051 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1052 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1052 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1053 "\"google:suggestrelevance\":[1, 2]}]", 1053 "\"google:suggestrelevance\":[1, 2]}]",
1054 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, 1054 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch,
1055 kEmptyMatch, kEmptyMatch },
1055 std::string() }, 1056 std::string() },
1056 1057
1057 // Without suggested relevance scores, we should only allow one 1058 // Without suggested relevance scores, we should only allow one
1058 // navsuggest result to be be displayed. 1059 // navsuggest result to be be displayed.
1059 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1060 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1060 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", 1061 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]",
1061 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1062 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1063 kEmptyMatch, kEmptyMatch },
1062 std::string() }, 1064 std::string() },
1063 1065
1064 // Ensure that verbatimrelevance scores reorder or suppress verbatim. 1066 // Ensure that verbatimrelevance scores reorder or suppress verbatim.
1065 // Negative values will have no effect; the calculated value will be used. 1067 // Negative values will have no effect; the calculated value will be used.
1066 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," 1068 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999,"
1067 "\"google:suggestrelevance\":[9998]}]", 1069 "\"google:suggestrelevance\":[9998]}]",
1068 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1070 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1071 kEmptyMatch },
1069 std::string() }, 1072 std::string() },
1070 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," 1073 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998,"
1071 "\"google:suggestrelevance\":[9999]}]", 1074 "\"google:suggestrelevance\":[9999]}]",
1072 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1075 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1076 kEmptyMatch },
1073 "1" }, 1077 "1" },
1074 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," 1078 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0,"
1075 "\"google:suggestrelevance\":[9999]}]", 1079 "\"google:suggestrelevance\":[9999]}]",
1076 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1080 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1081 kEmptyMatch },
1077 "1" }, 1082 "1" },
1078 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," 1083 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1,"
1079 "\"google:suggestrelevance\":[9999]}]", 1084 "\"google:suggestrelevance\":[9999]}]",
1080 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1085 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1086 kEmptyMatch },
1081 "1" }, 1087 "1" },
1082 { "[\"a\",[\"http://a.com\"],[],[]," 1088 { "[\"a\",[\"http://a.com\"],[],[],"
1083 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1089 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1084 "\"google:verbatimrelevance\":9999," 1090 "\"google:verbatimrelevance\":9999,"
1085 "\"google:suggestrelevance\":[9998]}]", 1091 "\"google:suggestrelevance\":[9998]}]",
1086 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, 1092 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1093 kEmptyMatch },
1087 std::string() }, 1094 std::string() },
1088 { "[\"a\",[\"http://a.com\"],[],[]," 1095 { "[\"a\",[\"http://a.com\"],[],[],"
1089 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1096 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1090 "\"google:verbatimrelevance\":9998," 1097 "\"google:verbatimrelevance\":9998,"
1091 "\"google:suggestrelevance\":[9999]}]", 1098 "\"google:suggestrelevance\":[9999]}]",
1092 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1099 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1100 kEmptyMatch },
1093 ".com" }, 1101 ".com" },
1094 { "[\"a\",[\"http://a.com\"],[],[]," 1102 { "[\"a\",[\"http://a.com\"],[],[],"
1095 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1103 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1096 "\"google:verbatimrelevance\":0," 1104 "\"google:verbatimrelevance\":0,"
1097 "\"google:suggestrelevance\":[9999]}]", 1105 "\"google:suggestrelevance\":[9999]}]",
1098 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1106 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1107 kEmptyMatch },
1099 ".com" }, 1108 ".com" },
1100 { "[\"a\",[\"http://a.com\"],[],[]," 1109 { "[\"a\",[\"http://a.com\"],[],[],"
1101 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1110 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1102 "\"google:verbatimrelevance\":-1," 1111 "\"google:verbatimrelevance\":-1,"
1103 "\"google:suggestrelevance\":[9999]}]", 1112 "\"google:suggestrelevance\":[9999]}]",
1104 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1113 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1114 kEmptyMatch },
1105 ".com" }, 1115 ".com" },
1106 1116
1107 // Ensure that both types of relevance scores reorder matches together. 1117 // Ensure that both types of relevance scores reorder matches together.
1108 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," 1118 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997],"
1109 "\"google:verbatimrelevance\":9998}]", 1119 "\"google:verbatimrelevance\":9998}]",
1110 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, 1120 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1121 kEmptyMatch },
1111 "1" }, 1122 "1" },
1112 1123
1113 // Ensure that only inlinable matches may be ranked as the highest result. 1124 // Ensure that only inlinable matches may be ranked as the highest result.
1114 // Ignore all suggested relevance scores if this constraint is violated. 1125 // Ignore all suggested relevance scores if this constraint is violated.
1115 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", 1126 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]",
1116 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, 1127 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1128 kEmptyMatch },
1117 std::string() }, 1129 std::string() },
1118 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," 1130 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999],"
1119 "\"google:verbatimrelevance\":0}]", 1131 "\"google:verbatimrelevance\":0}]",
1120 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, 1132 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1133 kEmptyMatch },
1121 std::string() }, 1134 std::string() },
1122 { "[\"a\",[\"http://b.com\"],[],[]," 1135 { "[\"a\",[\"http://b.com\"],[],[],"
1123 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1136 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1124 "\"google:suggestrelevance\":[9999]}]", 1137 "\"google:suggestrelevance\":[9999]}]",
1125 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1138 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1139 kEmptyMatch, kEmptyMatch },
1126 std::string() }, 1140 std::string() },
1127 { "[\"a\",[\"http://b.com\"],[],[]," 1141 { "[\"a\",[\"http://b.com\"],[],[],"
1128 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1142 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1129 "\"google:suggestrelevance\":[9999]," 1143 "\"google:suggestrelevance\":[9999],"
1130 "\"google:verbatimrelevance\":0}]", 1144 "\"google:verbatimrelevance\":0}]",
1131 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1145 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1146 kEmptyMatch, kEmptyMatch },
1132 std::string() }, 1147 std::string() },
1133 { "[\"a\",[\"https://a/\"],[],[]," 1148 { "[\"a\",[\"https://a/\"],[],[],"
1134 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1149 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1135 "\"google:suggestrelevance\":[9999]}]", 1150 "\"google:suggestrelevance\":[9999]}]",
1136 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1151 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch,
1152 kEmptyMatch, kEmptyMatch },
1137 std::string() }, 1153 std::string() },
1138 1154
1139 // Ensure that the top result is ranked as highly as calculated verbatim. 1155 // Ensure that the top result is ranked as highly as calculated verbatim.
1140 // Ignore the suggested verbatim relevance if this constraint is violated. 1156 // Ignore the suggested verbatim relevance if this constraint is violated.
1141 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1157 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1142 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1158 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1159 kEmptyMatch },
1143 std::string() }, 1160 std::string() },
1144 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1161 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1145 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1162 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1163 kEmptyMatch },
1146 std::string() }, 1164 std::string() },
1147 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1165 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
1148 "\"google:verbatimrelevance\":0}]", 1166 "\"google:verbatimrelevance\":0}]",
1149 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1167 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1168 kEmptyMatch },
1150 std::string() }, 1169 std::string() },
1151 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," 1170 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
1152 "\"google:verbatimrelevance\":0}]", 1171 "\"google:verbatimrelevance\":0}]",
1153 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, 1172 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1173 kEmptyMatch },
1154 std::string() }, 1174 std::string() },
1155 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," 1175 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
1156 "\"google:verbatimrelevance\":2}]", 1176 "\"google:verbatimrelevance\":2}]",
1157 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, 1177 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1178 kEmptyMatch },
1158 std::string() }, 1179 std::string() },
1159 { "[\"a\",[\"http://a.com\"],[],[]," 1180 { "[\"a\",[\"http://a.com\"],[],[],"
1160 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1181 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1161 "\"google:suggestrelevance\":[1]," 1182 "\"google:suggestrelevance\":[1],"
1162 "\"google:verbatimrelevance\":0}]", 1183 "\"google:verbatimrelevance\":0}]",
1163 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, 1184 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1185 kEmptyMatch },
1164 std::string() }, 1186 std::string() },
1165 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1187 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1166 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1188 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1167 "\"google:suggestrelevance\":[1, 2]," 1189 "\"google:suggestrelevance\":[1, 2],"
1168 "\"google:verbatimrelevance\":0}]", 1190 "\"google:verbatimrelevance\":0}]",
1169 { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch }, 1191 { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch,
1192 kEmptyMatch, kEmptyMatch },
1170 std::string() }, 1193 std::string() },
1171 1194
1172 // Ensure that all suggestions are considered, regardless of order. 1195 // Ensure that all suggestions are considered, regardless of order.
1173 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," 1196 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[],"
1174 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1197 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1175 { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, 1198 { { "a", true }, { "h", false }, { "g", false }, { "f", false },
1199 {"e", false }, {"d", false } },
1176 std::string() }, 1200 std::string() },
1177 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," 1201 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\","
1178 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," 1202 "\"http://e.com\", \"http://f.com\", \"http://g.com\","
1179 "\"http://h.com\"],[],[]," 1203 "\"http://h.com\"],[],[],"
1180 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," 1204 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\","
1181 "\"NAVIGATION\", \"NAVIGATION\"," 1205 "\"NAVIGATION\", \"NAVIGATION\","
1182 "\"NAVIGATION\", \"NAVIGATION\"," 1206 "\"NAVIGATION\", \"NAVIGATION\","
1183 "\"NAVIGATION\"]," 1207 "\"NAVIGATION\"],"
1184 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1208 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1185 { { "a", true }, { "h.com", false }, { "g.com", false }, 1209 { { "a", true }, { "h.com", false }, { "g.com", false },
1186 { "f.com", false } }, 1210 { "f.com", false }, {"e.com", false }, {"d.com", false } },
1187 std::string() }, 1211 std::string() },
1188 1212
1189 // Ensure that incorrectly sized suggestion relevance lists are ignored. 1213 // Ensure that incorrectly sized suggestion relevance lists are ignored.
1190 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", 1214 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]",
1191 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, 1215 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1216 kEmptyMatch },
1192 std::string() }, 1217 std::string() },
1193 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", 1218 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]",
1194 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1219 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1220 kEmptyMatch },
1195 std::string() }, 1221 std::string() },
1196 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1222 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1197 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1223 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1198 "\"google:suggestrelevance\":[1]}]", 1224 "\"google:suggestrelevance\":[1]}]",
1199 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1225 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1226 kEmptyMatch, kEmptyMatch },
1200 std::string() }, 1227 std::string() },
1201 { "[\"a\",[\"http://a1.com\"],[],[]," 1228 { "[\"a\",[\"http://a1.com\"],[],[],"
1202 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1229 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1203 "\"google:suggestrelevance\":[9999, 1]}]", 1230 "\"google:suggestrelevance\":[9999, 1]}]",
1204 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1231 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1232 kEmptyMatch, kEmptyMatch },
1205 std::string() }, 1233 std::string() },
1206 1234
1207 // Ensure that all 'verbatim' results are merged with their maximum score. 1235 // Ensure that all 'verbatim' results are merged with their maximum score.
1208 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1236 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1209 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1237 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1210 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1238 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1239 kEmptyMatch },
1211 "2" }, 1240 "2" },
1212 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1241 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1213 "{\"google:suggestrelevance\":[9998, 9997, 9999]," 1242 "{\"google:suggestrelevance\":[9998, 9997, 9999],"
1214 "\"google:verbatimrelevance\":0}]", 1243 "\"google:verbatimrelevance\":0}]",
1215 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1244 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1245 kEmptyMatch },
1216 "2" }, 1246 "2" },
1217 1247
1218 // Ensure that verbatim is always generated without other suggestions. 1248 // Ensure that verbatim is always generated without other suggestions.
1219 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). 1249 // TODO(msw): Ensure verbatimrelevance is respected (except suppression).
1220 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1250 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1221 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1251 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1252 kEmptyMatch },
1222 std::string() }, 1253 std::string() },
1223 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1254 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1224 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1255 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1256 kEmptyMatch },
1225 std::string() }, 1257 std::string() },
1226 }; 1258 };
1227 1259
1228 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { 1260 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
1229 QueryForInput(ASCIIToUTF16("a"), false, false); 1261 QueryForInput(ASCIIToUTF16("a"), false, false);
1230 net::TestURLFetcher* fetcher = 1262 net::TestURLFetcher* fetcher =
1231 test_factory_.GetFetcherByID( 1263 test_factory_.GetFetcherByID(
1232 SearchProvider::kDefaultProviderURLFetcherID); 1264 SearchProvider::kDefaultProviderURLFetcherID);
1233 ASSERT_TRUE(fetcher); 1265 ASSERT_TRUE(fetcher);
1234 fetcher->set_response_code(200); 1266 fetcher->set_response_code(200);
(...skipping 30 matching lines...) Expand all
1265 // causes SearchProvider to allow some constraints to be violated that it 1297 // causes SearchProvider to allow some constraints to be violated that it
1266 // wouldn't normally because the omnibox will fix the problems later. 1298 // wouldn't normally because the omnibox will fix the problems later.
1267 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { 1299 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) {
1268 struct DefaultFetcherMatch { 1300 struct DefaultFetcherMatch {
1269 std::string contents; 1301 std::string contents;
1270 bool allowed_to_be_default_match; 1302 bool allowed_to_be_default_match;
1271 }; 1303 };
1272 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; 1304 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false };
1273 struct { 1305 struct {
1274 const std::string json; 1306 const std::string json;
1275 const DefaultFetcherMatch matches[4]; 1307 const DefaultFetcherMatch matches[6];
1276 const std::string inline_autocompletion; 1308 const std::string inline_autocompletion;
1277 } cases[] = { 1309 } cases[] = {
1278 // Ensure that suggestrelevance scores reorder matches. 1310 // Ensure that suggestrelevance scores reorder matches.
1279 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 1311 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
1280 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, 1312 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, kEmptyMatch,
1313 kEmptyMatch },
1281 std::string() }, 1314 std::string() },
1282 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1315 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1283 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1316 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1284 "\"google:suggestrelevance\":[1, 2]}]", 1317 "\"google:suggestrelevance\":[1, 2]}]",
1285 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, 1318 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch,
1319 kEmptyMatch, kEmptyMatch },
1286 std::string() }, 1320 std::string() },
1287 1321
1288 // Without suggested relevance scores, we should only allow one 1322 // Without suggested relevance scores, we should only allow one
1289 // navsuggest result to be be displayed. 1323 // navsuggest result to be be displayed.
1290 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1324 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1291 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", 1325 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]",
1292 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1326 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1327 kEmptyMatch, kEmptyMatch },
1293 std::string() }, 1328 std::string() },
1294 1329
1295 // Ensure that verbatimrelevance scores reorder or suppress verbatim. 1330 // Ensure that verbatimrelevance scores reorder or suppress verbatim.
1296 // Negative values will have no effect; the calculated value will be used. 1331 // Negative values will have no effect; the calculated value will be used.
1297 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," 1332 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999,"
1298 "\"google:suggestrelevance\":[9998]}]", 1333 "\"google:suggestrelevance\":[9998]}]",
1299 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1334 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1335 kEmptyMatch },
1300 std::string() }, 1336 std::string() },
1301 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," 1337 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998,"
1302 "\"google:suggestrelevance\":[9999]}]", 1338 "\"google:suggestrelevance\":[9999]}]",
1303 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1339 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1340 kEmptyMatch },
1304 "1" }, 1341 "1" },
1305 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," 1342 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0,"
1306 "\"google:suggestrelevance\":[9999]}]", 1343 "\"google:suggestrelevance\":[9999]}]",
1307 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1344 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1345 kEmptyMatch },
1308 "1" }, 1346 "1" },
1309 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," 1347 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1,"
1310 "\"google:suggestrelevance\":[9999]}]", 1348 "\"google:suggestrelevance\":[9999]}]",
1311 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1349 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1350 kEmptyMatch },
1312 "1" }, 1351 "1" },
1313 { "[\"a\",[\"http://a.com\"],[],[]," 1352 { "[\"a\",[\"http://a.com\"],[],[],"
1314 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1353 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1315 "\"google:verbatimrelevance\":9999," 1354 "\"google:verbatimrelevance\":9999,"
1316 "\"google:suggestrelevance\":[9998]}]", 1355 "\"google:suggestrelevance\":[9998]}]",
1317 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, 1356 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1357 kEmptyMatch },
1318 std::string() }, 1358 std::string() },
1319 { "[\"a\",[\"http://a.com\"],[],[]," 1359 { "[\"a\",[\"http://a.com\"],[],[],"
1320 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1360 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1321 "\"google:verbatimrelevance\":9998," 1361 "\"google:verbatimrelevance\":9998,"
1322 "\"google:suggestrelevance\":[9999]}]", 1362 "\"google:suggestrelevance\":[9999]}]",
1323 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1363 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1364 kEmptyMatch },
1324 ".com" }, 1365 ".com" },
1325 { "[\"a\",[\"http://a.com\"],[],[]," 1366 { "[\"a\",[\"http://a.com\"],[],[],"
1326 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1367 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1327 "\"google:verbatimrelevance\":0," 1368 "\"google:verbatimrelevance\":0,"
1328 "\"google:suggestrelevance\":[9999]}]", 1369 "\"google:suggestrelevance\":[9999]}]",
1329 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1370 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1371 kEmptyMatch },
1330 ".com" }, 1372 ".com" },
1331 { "[\"a\",[\"http://a.com\"],[],[]," 1373 { "[\"a\",[\"http://a.com\"],[],[],"
1332 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1374 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1333 "\"google:verbatimrelevance\":-1," 1375 "\"google:verbatimrelevance\":-1,"
1334 "\"google:suggestrelevance\":[9999]}]", 1376 "\"google:suggestrelevance\":[9999]}]",
1335 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1377 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1378 kEmptyMatch },
1336 ".com" }, 1379 ".com" },
1337 1380
1338 // Ensure that both types of relevance scores reorder matches together. 1381 // Ensure that both types of relevance scores reorder matches together.
1339 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," 1382 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997],"
1340 "\"google:verbatimrelevance\":9998}]", 1383 "\"google:verbatimrelevance\":9998}]",
1341 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, 1384 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1385 kEmptyMatch },
1342 "1" }, 1386 "1" },
1343 1387
1344 // Allow non-inlineable matches to be the highest-scoring match but, 1388 // Allow non-inlineable matches to be the highest-scoring match but,
1345 // if the result set lacks a single inlineable result, abandon suggested 1389 // if the result set lacks a single inlineable result, abandon suggested
1346 // relevance scores entirely. 1390 // relevance scores entirely.
1347 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", 1391 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]",
1348 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1392 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1393 kEmptyMatch },
1349 std::string() }, 1394 std::string() },
1350 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," 1395 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999],"
1351 "\"google:verbatimrelevance\":0}]", 1396 "\"google:verbatimrelevance\":0}]",
1352 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, 1397 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1398 kEmptyMatch },
1353 std::string() }, 1399 std::string() },
1354 { "[\"a\",[\"http://b.com\"],[],[]," 1400 { "[\"a\",[\"http://b.com\"],[],[],"
1355 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1401 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1356 "\"google:suggestrelevance\":[9999]}]", 1402 "\"google:suggestrelevance\":[9999]}]",
1357 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1403 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch,
1404 kEmptyMatch, kEmptyMatch },
1358 std::string() }, 1405 std::string() },
1359 { "[\"a\",[\"http://b.com\"],[],[]," 1406 { "[\"a\",[\"http://b.com\"],[],[],"
1360 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1407 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1361 "\"google:suggestrelevance\":[9999]," 1408 "\"google:suggestrelevance\":[9999],"
1362 "\"google:verbatimrelevance\":0}]", 1409 "\"google:verbatimrelevance\":0}]",
1363 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1410 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1411 kEmptyMatch, kEmptyMatch },
1364 std::string() }, 1412 std::string() },
1365 1413
1366 // Allow low-scoring matches. 1414 // Allow low-scoring matches.
1367 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1415 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1368 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1416 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1417 kEmptyMatch },
1369 "1" }, 1418 "1" },
1370 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1419 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1371 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1420 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1421 kEmptyMatch },
1372 "1" }, 1422 "1" },
1373 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1423 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
1374 "\"google:verbatimrelevance\":0}]", 1424 "\"google:verbatimrelevance\":0}]",
1375 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1425 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1426 kEmptyMatch },
1376 "1" }, 1427 "1" },
1377 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," 1428 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
1378 "\"google:verbatimrelevance\":0}]", 1429 "\"google:verbatimrelevance\":0}]",
1379 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1430 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1431 kEmptyMatch },
1380 "2" }, 1432 "2" },
1381 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," 1433 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
1382 "\"google:verbatimrelevance\":2}]", 1434 "\"google:verbatimrelevance\":2}]",
1383 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1435 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1436 kEmptyMatch },
1384 "2" }, 1437 "2" },
1385 { "[\"a\",[\"http://a.com\"],[],[]," 1438 { "[\"a\",[\"http://a.com\"],[],[],"
1386 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1439 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1387 "\"google:suggestrelevance\":[1]," 1440 "\"google:suggestrelevance\":[1],"
1388 "\"google:verbatimrelevance\":0}]", 1441 "\"google:verbatimrelevance\":0}]",
1389 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1442 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1443 kEmptyMatch },
1390 ".com" }, 1444 ".com" },
1391 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1445 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1392 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1446 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1393 "\"google:suggestrelevance\":[1, 2]," 1447 "\"google:suggestrelevance\":[1, 2],"
1394 "\"google:verbatimrelevance\":0}]", 1448 "\"google:verbatimrelevance\":0}]",
1395 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1449 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1450 kEmptyMatch, kEmptyMatch },
1396 "2.com" }, 1451 "2.com" },
1397 1452
1398 // Ensure that all suggestions are considered, regardless of order. 1453 // Ensure that all suggestions are considered, regardless of order.
1399 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," 1454 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[],"
1400 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1455 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1401 { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, 1456 { { "a", true }, { "h", false }, { "g", false }, { "f", false },
1457 { "e", false }, { "d", false } },
1402 std::string() }, 1458 std::string() },
1403 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," 1459 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\","
1404 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," 1460 "\"http://e.com\", \"http://f.com\", \"http://g.com\","
1405 "\"http://h.com\"],[],[]," 1461 "\"http://h.com\"],[],[],"
1406 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," 1462 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\","
1407 "\"NAVIGATION\", \"NAVIGATION\"," 1463 "\"NAVIGATION\", \"NAVIGATION\","
1408 "\"NAVIGATION\", \"NAVIGATION\"," 1464 "\"NAVIGATION\", \"NAVIGATION\","
1409 "\"NAVIGATION\"]," 1465 "\"NAVIGATION\"],"
1410 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1466 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1411 { { "a", true }, { "h.com", false }, { "g.com", false }, 1467 { { "a", true }, { "h.com", false }, { "g.com", false },
1412 { "f.com", false } }, 1468 { "f.com", false }, { "e.com", false }, { "d.com", false } },
1413 std::string() }, 1469 std::string() },
1414 1470
1415 // Ensure that incorrectly sized suggestion relevance lists are ignored. 1471 // Ensure that incorrectly sized suggestion relevance lists are ignored.
1416 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", 1472 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]",
1417 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, 1473 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1474 kEmptyMatch },
1418 std::string() }, 1475 std::string() },
1419 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", 1476 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]",
1420 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1477 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1478 kEmptyMatch },
1421 std::string() }, 1479 std::string() },
1422 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1480 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1423 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1481 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1424 "\"google:suggestrelevance\":[1]}]", 1482 "\"google:suggestrelevance\":[1]}]",
1425 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1483 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1484 kEmptyMatch, kEmptyMatch },
1426 std::string() }, 1485 std::string() },
1427 { "[\"a\",[\"http://a1.com\"],[],[]," 1486 { "[\"a\",[\"http://a1.com\"],[],[],"
1428 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1487 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1429 "\"google:suggestrelevance\":[9999, 1]}]", 1488 "\"google:suggestrelevance\":[9999, 1]}]",
1430 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1489 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1490 kEmptyMatch, kEmptyMatch },
1431 std::string() }, 1491 std::string() },
1432 1492
1433 // Ensure that all 'verbatim' results are merged with their maximum score. 1493 // Ensure that all 'verbatim' results are merged with their maximum score.
1434 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1494 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1435 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1495 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1436 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1496 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1497 kEmptyMatch },
1437 "2" }, 1498 "2" },
1438 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1499 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1439 "{\"google:suggestrelevance\":[9998, 9997, 9999]," 1500 "{\"google:suggestrelevance\":[9998, 9997, 9999],"
1440 "\"google:verbatimrelevance\":0}]", 1501 "\"google:verbatimrelevance\":0}]",
1441 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1502 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1503 kEmptyMatch },
1442 "2" }, 1504 "2" },
1443 1505
1444 // Ensure that verbatim is always generated without other suggestions. 1506 // Ensure that verbatim is always generated without other suggestions.
1445 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). 1507 // TODO(msw): Ensure verbatimrelevance is respected (except suppression).
1446 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1508 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1447 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1509 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1510 kEmptyMatch },
1448 std::string() }, 1511 std::string() },
1449 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1512 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1450 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1513 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1514 kEmptyMatch },
1451 std::string() }, 1515 std::string() },
1452 }; 1516 };
1453 1517
1454 std::map<std::string, std::string> params; 1518 std::map<std::string, std::string> params;
1455 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) + 1519 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) +
1456 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled; 1520 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled;
1457 ASSERT_TRUE(chrome_variations::AssociateVariationParams( 1521 ASSERT_TRUE(chrome_variations::AssociateVariationParams(
1458 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params)); 1522 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params));
1459 base::FieldTrialList::CreateFieldTrial( 1523 base::FieldTrialList::CreateFieldTrial(
1460 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); 1524 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 // appropriate to add to DefaultFetcherSuggestRelevance as well. 1566 // appropriate to add to DefaultFetcherSuggestRelevance as well.
1503 TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { 1567 TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) {
1504 struct KeywordFetcherMatch { 1568 struct KeywordFetcherMatch {
1505 std::string contents; 1569 std::string contents;
1506 bool from_keyword; 1570 bool from_keyword;
1507 bool allowed_to_be_default_match; 1571 bool allowed_to_be_default_match;
1508 }; 1572 };
1509 const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false }; 1573 const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false };
1510 struct { 1574 struct {
1511 const std::string json; 1575 const std::string json;
1512 const KeywordFetcherMatch matches[5]; 1576 const KeywordFetcherMatch matches[6];
1513 const std::string inline_autocompletion; 1577 const std::string inline_autocompletion;
1514 } cases[] = { 1578 } cases[] = {
1515 // Ensure that suggest relevance scores reorder matches and that 1579 // Ensure that suggest relevance scores reorder matches and that
1516 // the keyword verbatim (lacking a suggested verbatim score) beats 1580 // the keyword verbatim (lacking a suggested verbatim score) beats
1517 // the default provider verbatim. 1581 // the default provider verbatim.
1518 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 1582 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
1519 { { "a", true, true }, 1583 { { "a", true, true },
1520 { "k a", false, true }, 1584 { "k a", false, true },
1521 { "c", true, false }, 1585 { "c", true, false },
1522 { "b", true, false }, 1586 { "b", true, false },
1523 kEmptyMatch }, 1587 kEmptyMatch, kEmptyMatch },
1524 std::string() }, 1588 std::string() },
1525 // Again, check that relevance scores reorder matches, just this 1589 // Again, check that relevance scores reorder matches, just this
1526 // time with navigation matches. This also checks that with 1590 // time with navigation matches. This also checks that with
1527 // suggested relevance scores we allow multiple navsuggest results. 1591 // suggested relevance scores we allow multiple navsuggest results.
1528 // It's odd that navsuggest results that come from a keyword 1592 // It's odd that navsuggest results that come from a keyword
1529 // provider are marked as not a keyword result. I think this 1593 // provider are marked as not a keyword result. I think this
1530 // comes from them not going to a keyword search engine). 1594 // comes from them not going to a keyword search engine).
1531 // TODO(mpearson): Investigate the implications (if any) of 1595 // TODO(mpearson): Investigate the implications (if any) of
1532 // tagging these results appropriately. If so, do it because it 1596 // tagging these results appropriately. If so, do it because it
1533 // makes more sense. 1597 // makes more sense.
1534 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," 1598 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[],"
1535 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1599 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1536 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", 1600 "\"google:suggestrelevance\":[1301, 1302, 1303]}]",
1537 { { "a", true, true }, 1601 { { "a", true, true },
1538 { "d", true, false }, 1602 { "d", true, false },
1539 { "c.com", false, false }, 1603 { "c.com", false, false },
1540 { "b.com", false, false }, 1604 { "b.com", false, false },
1541 { "k a", false, true }, }, 1605 { "k a", false, true },
1606 kEmptyMatch },
1542 std::string() }, 1607 std::string() },
1543 1608
1544 // Without suggested relevance scores, we should only allow one 1609 // Without suggested relevance scores, we should only allow one
1545 // navsuggest result to be be displayed. 1610 // navsuggest result to be be displayed.
1546 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1611 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1547 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", 1612 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]",
1548 { { "a", true, true }, 1613 { { "a", true, true },
1549 { "b.com", false, false }, 1614 { "b.com", false, false },
1550 { "k a", false, true }, 1615 { "k a", false, true },
1551 kEmptyMatch, kEmptyMatch }, 1616 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1552 std::string() }, 1617 std::string() },
1553 1618
1554 // Ensure that verbatimrelevance scores reorder or suppress verbatim. 1619 // Ensure that verbatimrelevance scores reorder or suppress verbatim.
1555 // Negative values will have no effect; the calculated value will be used. 1620 // Negative values will have no effect; the calculated value will be used.
1556 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," 1621 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999,"
1557 "\"google:suggestrelevance\":[9998]}]", 1622 "\"google:suggestrelevance\":[9998]}]",
1558 { { "a", true, true }, 1623 { { "a", true, true },
1559 { "a1", true, true }, 1624 { "a1", true, true },
1560 { "k a", false, true }, 1625 { "k a", false, true },
1561 kEmptyMatch, kEmptyMatch }, 1626 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1562 std::string() }, 1627 std::string() },
1563 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," 1628 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998,"
1564 "\"google:suggestrelevance\":[9999]}]", 1629 "\"google:suggestrelevance\":[9999]}]",
1565 { { "a1", true, true }, 1630 { { "a1", true, true },
1566 { "a", true, true }, 1631 { "a", true, true },
1567 { "k a", false, true }, 1632 { "k a", false, true },
1568 kEmptyMatch, kEmptyMatch }, 1633 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1569 "1" }, 1634 "1" },
1570 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," 1635 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0,"
1571 "\"google:suggestrelevance\":[9999]}]", 1636 "\"google:suggestrelevance\":[9999]}]",
1572 { { "a1", true, true }, 1637 { { "a1", true, true },
1573 { "k a", false, true }, 1638 { "k a", false, true },
1574 kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1639 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch },
1575 "1" }, 1640 "1" },
1576 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," 1641 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1,"
1577 "\"google:suggestrelevance\":[9999]}]", 1642 "\"google:suggestrelevance\":[9999]}]",
1578 { { "a1", true, true }, 1643 { { "a1", true, true },
1579 { "a", true, true }, 1644 { "a", true, true },
1580 { "k a", false, true }, 1645 { "k a", false, true },
1581 kEmptyMatch, kEmptyMatch }, 1646 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1582 "1" }, 1647 "1" },
1583 { "[\"a\",[\"http://a.com\"],[],[]," 1648 { "[\"a\",[\"http://a.com\"],[],[],"
1584 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1649 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1585 "\"google:verbatimrelevance\":9999," 1650 "\"google:verbatimrelevance\":9999,"
1586 "\"google:suggestrelevance\":[9998]}]", 1651 "\"google:suggestrelevance\":[9998]}]",
1587 { { "a", true, true }, 1652 { { "a", true, true },
1588 { "a.com", false, true }, 1653 { "a.com", false, true },
1589 { "k a", false, true }, 1654 { "k a", false, true },
1590 kEmptyMatch, kEmptyMatch }, 1655 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1591 std::string() }, 1656 std::string() },
1592 1657
1593 // Ensure that both types of relevance scores reorder matches together. 1658 // Ensure that both types of relevance scores reorder matches together.
1594 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," 1659 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997],"
1595 "\"google:verbatimrelevance\":9998}]", 1660 "\"google:verbatimrelevance\":9998}]",
1596 { { "a1", true, true }, 1661 { { "a1", true, true },
1597 { "a", true, true }, 1662 { "a", true, true },
1598 { "a2", true, true }, 1663 { "a2", true, true },
1599 { "k a", false, true }, 1664 { "k a", false, true },
1600 kEmptyMatch }, 1665 kEmptyMatch, kEmptyMatch },
1601 "1" }, 1666 "1" },
1602 1667
1603 // Ensure that only inlinable matches may be ranked as the highest result. 1668 // Ensure that only inlinable matches may be ranked as the highest result.
1604 // Ignore all suggested relevance scores if this constraint is violated. 1669 // Ignore all suggested relevance scores if this constraint is violated.
1605 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", 1670 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]",
1606 { { "a", true, true }, 1671 { { "a", true, true },
1607 { "b", true, false }, 1672 { "b", true, false },
1608 { "k a", false, true }, 1673 { "k a", false, true },
1609 kEmptyMatch, kEmptyMatch }, 1674 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1610 std::string() }, 1675 std::string() },
1611 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," 1676 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999],"
1612 "\"google:verbatimrelevance\":0}]", 1677 "\"google:verbatimrelevance\":0}]",
1613 { { "a", true, true }, 1678 { { "a", true, true },
1614 { "b", true, false }, 1679 { "b", true, false },
1615 { "k a", false, true }, 1680 { "k a", false, true },
1616 kEmptyMatch, kEmptyMatch }, 1681 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1617 std::string() }, 1682 std::string() },
1618 { "[\"a\",[\"http://b.com\"],[],[]," 1683 { "[\"a\",[\"http://b.com\"],[],[],"
1619 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1684 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1620 "\"google:suggestrelevance\":[9999]}]", 1685 "\"google:suggestrelevance\":[9999]}]",
1621 { { "a", true, true }, 1686 { { "a", true, true },
1622 { "b.com", false, false }, 1687 { "b.com", false, false },
1623 { "k a", false, true }, 1688 { "k a", false, true },
1624 kEmptyMatch, kEmptyMatch }, 1689 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1625 std::string() }, 1690 std::string() },
1626 { "[\"a\",[\"http://b.com\"],[],[]," 1691 { "[\"a\",[\"http://b.com\"],[],[],"
1627 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1692 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1628 "\"google:suggestrelevance\":[9999]," 1693 "\"google:suggestrelevance\":[9999],"
1629 "\"google:verbatimrelevance\":0}]", 1694 "\"google:verbatimrelevance\":0}]",
1630 { { "a", true, true }, 1695 { { "a", true, true },
1631 { "b.com", false, false }, 1696 { "b.com", false, false },
1632 { "k a", false, true }, 1697 { "k a", false, true },
1633 kEmptyMatch, kEmptyMatch }, 1698 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1634 std::string() }, 1699 std::string() },
1635 1700
1636 // Ensure that the top result is ranked as highly as calculated verbatim. 1701 // Ensure that the top result is ranked as highly as calculated verbatim.
1637 // Ignore the suggested verbatim relevance if this constraint is violated. 1702 // Ignore the suggested verbatim relevance if this constraint is violated.
1638 // Note that keyword suggestions by default (not in suggested relevance 1703 // Note that keyword suggestions by default (not in suggested relevance
1639 // mode) score more highly than the default verbatim. 1704 // mode) score more highly than the default verbatim.
1640 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1705 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1641 { { "a", true, true }, 1706 { { "a", true, true },
1642 { "a1", true, true }, 1707 { "a1", true, true },
1643 { "k a", false, true }, 1708 { "k a", false, true },
1644 kEmptyMatch, kEmptyMatch }, 1709 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1645 std::string() }, 1710 std::string() },
1646 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1711 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1647 { { "a", true, true }, 1712 { { "a", true, true },
1648 { "a1", true, true }, 1713 { "a1", true, true },
1649 { "k a", false, true }, 1714 { "k a", false, true },
1650 kEmptyMatch, kEmptyMatch}, 1715 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1651 std::string() }, 1716 std::string() },
1652 // Continuing the same category of tests, but make sure we keep the 1717 // Continuing the same category of tests, but make sure we keep the
1653 // suggested relevance scores even as we discard the verbatim relevance 1718 // suggested relevance scores even as we discard the verbatim relevance
1654 // scores. 1719 // scores.
1655 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1720 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
1656 "\"google:verbatimrelevance\":0}]", 1721 "\"google:verbatimrelevance\":0}]",
1657 { { "a", true, true }, 1722 { { "a", true, true },
1658 { "k a", false, true }, 1723 { "k a", false, true },
1659 { "a1", true, true }, 1724 { "a1", true, true },
1660 kEmptyMatch, kEmptyMatch}, 1725 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1661 std::string() }, 1726 std::string() },
1662 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," 1727 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
1663 "\"google:verbatimrelevance\":0}]", 1728 "\"google:verbatimrelevance\":0}]",
1664 { { "a", true, true }, 1729 { { "a", true, true },
1665 { "k a", false, true }, 1730 { "k a", false, true },
1666 { "a2", true, true }, 1731 { "a2", true, true },
1667 { "a1", true, true }, 1732 { "a1", true, true },
1668 kEmptyMatch }, 1733 kEmptyMatch, kEmptyMatch },
1669 std::string() }, 1734 std::string() },
1670 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," 1735 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
1671 "\"google:verbatimrelevance\":2}]", 1736 "\"google:verbatimrelevance\":2}]",
1672 { { "a", true, true }, 1737 { { "a", true, true },
1673 { "k a", false, true }, 1738 { "k a", false, true },
1674 { "a2", true, true }, 1739 { "a2", true, true },
1675 { "a1", true, true }, 1740 { "a1", true, true },
1676 kEmptyMatch }, 1741 kEmptyMatch, kEmptyMatch },
1677 std::string() }, 1742 std::string() },
1678 1743
1679 // Ensure that all suggestions are considered, regardless of order. 1744 // Ensure that all suggestions are considered, regardless of order.
1680 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," 1745 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[],"
1681 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1746 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1682 { { "a", true, true }, 1747 { { "a", true, true },
1683 { "k a", false, true }, 1748 { "k a", false, true },
1684 { "h", true, false }, 1749 { "h", true, false },
1685 { "g", true, false }, 1750 { "g", true, false },
1686 { "f", true, false } }, 1751 { "f", true, false },
1752 { "e", true, false } },
1687 std::string() }, 1753 std::string() },
1688 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," 1754 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\","
1689 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," 1755 "\"http://e.com\", \"http://f.com\", \"http://g.com\","
1690 "\"http://h.com\"],[],[]," 1756 "\"http://h.com\"],[],[],"
1691 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," 1757 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\","
1692 "\"NAVIGATION\", \"NAVIGATION\"," 1758 "\"NAVIGATION\", \"NAVIGATION\","
1693 "\"NAVIGATION\", \"NAVIGATION\"," 1759 "\"NAVIGATION\", \"NAVIGATION\","
1694 "\"NAVIGATION\"]," 1760 "\"NAVIGATION\"],"
1695 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1761 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1696 { { "a", true, true }, 1762 { { "a", true, true },
1697 { "k a", false, true }, 1763 { "k a", false, true },
1698 { "h.com", false, false }, 1764 { "h.com", false, false },
1699 { "g.com", false, false }, 1765 { "g.com", false, false },
1700 { "f.com", false, false } }, 1766 { "f.com", false, false },
1767 { "e.com", false, false } },
1701 std::string() }, 1768 std::string() },
1702 1769
1703 // Ensure that incorrectly sized suggestion relevance lists are ignored. 1770 // Ensure that incorrectly sized suggestion relevance lists are ignored.
1704 // Note that keyword suggestions by default (not in suggested relevance 1771 // Note that keyword suggestions by default (not in suggested relevance
1705 // mode) score more highly than the default verbatim. 1772 // mode) score more highly than the default verbatim.
1706 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", 1773 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]",
1707 { { "a", true, true }, 1774 { { "a", true, true },
1708 { "a1", true, true }, 1775 { "a1", true, true },
1709 { "a2", true, true }, 1776 { "a2", true, true },
1710 { "k a", false, true }, 1777 { "k a", false, true },
1711 kEmptyMatch }, 1778 kEmptyMatch, kEmptyMatch },
1712 std::string() }, 1779 std::string() },
1713 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", 1780 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]",
1714 { { "a", true, true }, 1781 { { "a", true, true },
1715 { "a1", true, true }, 1782 { "a1", true, true },
1716 { "k a", false, true }, 1783 { "k a", false, true },
1717 kEmptyMatch, kEmptyMatch}, 1784 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1718 std::string() }, 1785 std::string() },
1719 // In this case, ignored the suggested relevance scores means we keep 1786 // In this case, ignored the suggested relevance scores means we keep
1720 // only one navsuggest result. 1787 // only one navsuggest result.
1721 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1788 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1722 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1789 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1723 "\"google:suggestrelevance\":[1]}]", 1790 "\"google:suggestrelevance\":[1]}]",
1724 { { "a", true, true }, 1791 { { "a", true, true },
1725 { "a1.com", false, true }, 1792 { "a1.com", false, true },
1726 { "k a", false, true }, 1793 { "k a", false, true },
1727 kEmptyMatch, kEmptyMatch}, 1794 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1728 std::string() }, 1795 std::string() },
1729 { "[\"a\",[\"http://a1.com\"],[],[]," 1796 { "[\"a\",[\"http://a1.com\"],[],[],"
1730 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1797 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1731 "\"google:suggestrelevance\":[9999, 1]}]", 1798 "\"google:suggestrelevance\":[9999, 1]}]",
1732 { { "a", true, true }, 1799 { { "a", true, true },
1733 { "a1.com", false, true }, 1800 { "a1.com", false, true },
1734 { "k a", false, true }, 1801 { "k a", false, true },
1735 kEmptyMatch, kEmptyMatch}, 1802 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1736 std::string() }, 1803 std::string() },
1737 1804
1738 // Ensure that all 'verbatim' results are merged with their maximum score. 1805 // Ensure that all 'verbatim' results are merged with their maximum score.
1739 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1806 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1740 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1807 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1741 { { "a2", true, true }, 1808 { { "a2", true, true },
1742 { "a", true, true }, 1809 { "a", true, true },
1743 { "a1", true, true }, 1810 { "a1", true, true },
1744 { "k a", false, true }, 1811 { "k a", false, true },
1745 kEmptyMatch }, 1812 kEmptyMatch, kEmptyMatch },
1746 "2" }, 1813 "2" },
1747 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1814 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1748 "{\"google:suggestrelevance\":[9998, 9997, 9999]," 1815 "{\"google:suggestrelevance\":[9998, 9997, 9999],"
1749 "\"google:verbatimrelevance\":0}]", 1816 "\"google:verbatimrelevance\":0}]",
1750 { { "a2", true, true }, 1817 { { "a2", true, true },
1751 { "a", true, true }, 1818 { "a", true, true },
1752 { "a1", true, true }, 1819 { "a1", true, true },
1753 { "k a", false, true }, 1820 { "k a", false, true },
1754 kEmptyMatch }, 1821 kEmptyMatch, kEmptyMatch },
1755 "2" }, 1822 "2" },
1756 1823
1757 // Ensure that verbatim is always generated without other suggestions. 1824 // Ensure that verbatim is always generated without other suggestions.
1758 // TODO(mpearson): Ensure the value of verbatimrelevance is respected 1825 // TODO(mpearson): Ensure the value of verbatimrelevance is respected
1759 // (except when suggested relevances are ignored). 1826 // (except when suggested relevances are ignored).
1760 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1827 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1761 { { "a", true, true }, 1828 { { "a", true, true },
1762 { "k a", false, true }, 1829 { "k a", false, true },
1763 kEmptyMatch, kEmptyMatch, kEmptyMatch}, 1830 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch },
1764 std::string() }, 1831 std::string() },
1765 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1832 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1766 { { "a", true, true }, 1833 { { "a", true, true },
1767 { "k a", false, true }, 1834 { "k a", false, true },
1768 kEmptyMatch, kEmptyMatch, kEmptyMatch}, 1835 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch },
1769 std::string() }, 1836 std::string() },
1770 1837
1771 // Check that navsuggestions will be demoted below queries. 1838 // Check that navsuggestions will be demoted below queries.
1772 // (Navsuggestions are not allowed to appear first.) In the process, 1839 // (Navsuggestions are not allowed to appear first.) In the process,
1773 // make sure the navsuggestions still remain in the same order. 1840 // make sure the navsuggestions still remain in the same order.
1774 // First, check the situation where navsuggest scores more than verbatim 1841 // First, check the situation where navsuggest scores more than verbatim
1775 // and there are no query suggestions. 1842 // and there are no query suggestions.
1776 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1843 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1777 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1844 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1778 "\"google:verbatimrelevance\":9990," 1845 "\"google:verbatimrelevance\":9990,"
1779 "\"google:suggestrelevance\":[9998, 9999]}]", 1846 "\"google:suggestrelevance\":[9998, 9999]}]",
1780 { { "a", true, true }, 1847 { { "a", true, true },
1781 { "a2.com", false, true }, 1848 { "a2.com", false, true },
1782 { "a1.com", false, true }, 1849 { "a1.com", false, true },
1783 { "k a", false, true }, 1850 { "k a", false, true },
1784 kEmptyMatch }, 1851 kEmptyMatch, kEmptyMatch },
1785 std::string() }, 1852 std::string() },
1786 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1853 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1787 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1854 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1788 "\"google:verbatimrelevance\":9990," 1855 "\"google:verbatimrelevance\":9990,"
1789 "\"google:suggestrelevance\":[9999, 9998]}]", 1856 "\"google:suggestrelevance\":[9999, 9998]}]",
1790 { { "a", true, true }, 1857 { { "a", true, true },
1791 { "a1.com", false, true }, 1858 { "a1.com", false, true },
1792 { "a2.com", false, true }, 1859 { "a2.com", false, true },
1793 { "k a", false, true }, 1860 { "k a", false, true },
1794 kEmptyMatch }, 1861 kEmptyMatch, kEmptyMatch },
1795 std::string() }, 1862 std::string() },
1796 { "[\"a\",[\"https://a/\"],[],[]," 1863 { "[\"a\",[\"https://a/\"],[],[],"
1797 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1864 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1798 "\"google:suggestrelevance\":[9999]}]", 1865 "\"google:suggestrelevance\":[9999]}]",
1799 { { "a", true, true }, 1866 { { "a", true, true },
1800 { "https://a", false, true }, 1867 { "https://a", false, true },
1801 { "k a", false, true }, 1868 { "k a", false, true },
1802 kEmptyMatch, 1869 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1803 kEmptyMatch },
1804 std::string() }, 1870 std::string() },
1805 // Check when navsuggest scores more than verbatim and there is query 1871 // Check when navsuggest scores more than verbatim and there is query
1806 // suggestion but it scores lower. 1872 // suggestion but it scores lower.
1807 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1873 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1808 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1874 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1809 "\"google:verbatimrelevance\":9990," 1875 "\"google:verbatimrelevance\":9990,"
1810 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", 1876 "\"google:suggestrelevance\":[9998, 9999, 1300]}]",
1811 { { "a", true, true }, 1877 { { "a", true, true },
1812 { "a2.com", false, true }, 1878 { "a2.com", false, true },
1813 { "a1.com", false, true }, 1879 { "a1.com", false, true },
1814 { "a3", true, true }, 1880 { "a3", true, true },
1815 { "k a", false, true } }, 1881 { "k a", false, true },
1882 kEmptyMatch },
1816 std::string() }, 1883 std::string() },
1817 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1884 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1818 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1885 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1819 "\"google:verbatimrelevance\":9990," 1886 "\"google:verbatimrelevance\":9990,"
1820 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", 1887 "\"google:suggestrelevance\":[9999, 9998, 1300]}]",
1821 { { "a", true, true }, 1888 { { "a", true, true },
1822 { "a1.com", false, true }, 1889 { "a1.com", false, true },
1823 { "a2.com", false, true }, 1890 { "a2.com", false, true },
1824 { "a3", true, true }, 1891 { "a3", true, true },
1825 { "k a", false, true } }, 1892 { "k a", false, true },
1893 kEmptyMatch },
1826 std::string() }, 1894 std::string() },
1827 // Check when navsuggest scores more than a query suggestion. There is 1895 // Check when navsuggest scores more than a query suggestion. There is
1828 // a verbatim but it scores lower. 1896 // a verbatim but it scores lower.
1829 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1897 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1830 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1898 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1831 "\"google:verbatimrelevance\":9990," 1899 "\"google:verbatimrelevance\":9990,"
1832 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", 1900 "\"google:suggestrelevance\":[9998, 9999, 9997]}]",
1833 { { "a3", true, true }, 1901 { { "a3", true, true },
1834 { "a2.com", false, true }, 1902 { "a2.com", false, true },
1835 { "a1.com", false, true }, 1903 { "a1.com", false, true },
1836 { "a", true, true }, 1904 { "a", true, true },
1837 { "k a", false, true } }, 1905 { "k a", false, true },
1906 kEmptyMatch },
1838 "3" }, 1907 "3" },
1839 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1908 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1840 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1909 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1841 "\"google:verbatimrelevance\":9990," 1910 "\"google:verbatimrelevance\":9990,"
1842 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", 1911 "\"google:suggestrelevance\":[9999, 9998, 9997]}]",
1843 { { "a3", true, true }, 1912 { { "a3", true, true },
1844 { "a1.com", false, true }, 1913 { "a1.com", false, true },
1845 { "a2.com", false, true }, 1914 { "a2.com", false, true },
1846 { "a", true, true }, 1915 { "a", true, true },
1847 { "k a", false, true } }, 1916 { "k a", false, true },
1917 kEmptyMatch },
1848 "3" }, 1918 "3" },
1849 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1919 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1850 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1920 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1851 "\"google:verbatimrelevance\":0," 1921 "\"google:verbatimrelevance\":0,"
1852 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", 1922 "\"google:suggestrelevance\":[9998, 9999, 9997]}]",
1853 { { "a3", true, true }, 1923 { { "a3", true, true },
1854 { "a2.com", false, true }, 1924 { "a2.com", false, true },
1855 { "a1.com", false, true }, 1925 { "a1.com", false, true },
1856 { "k a", false, true }, 1926 { "k a", false, true },
1857 kEmptyMatch }, 1927 kEmptyMatch, kEmptyMatch },
1858 "3" }, 1928 "3" },
1859 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1929 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1860 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1930 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1861 "\"google:verbatimrelevance\":0," 1931 "\"google:verbatimrelevance\":0,"
1862 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", 1932 "\"google:suggestrelevance\":[9999, 9998, 9997]}]",
1863 { { "a3", true, true }, 1933 { { "a3", true, true },
1864 { "a1.com", false, true }, 1934 { "a1.com", false, true },
1865 { "a2.com", false, true }, 1935 { "a2.com", false, true },
1866 { "k a", false, true }, 1936 { "k a", false, true },
1867 kEmptyMatch }, 1937 kEmptyMatch, kEmptyMatch },
1868 "3" }, 1938 "3" },
1869 // Check when there is neither verbatim nor a query suggestion that, 1939 // Check when there is neither verbatim nor a query suggestion that,
1870 // because we can't demote navsuggestions below a query suggestion, 1940 // because we can't demote navsuggestions below a query suggestion,
1871 // we abandon suggested relevance scores entirely. One consequence is 1941 // we abandon suggested relevance scores entirely. One consequence is
1872 // that this means we restore the keyword verbatim match. Note 1942 // that this means we restore the keyword verbatim match. Note
1873 // that in this case of abandoning suggested relevance scores, we still 1943 // that in this case of abandoning suggested relevance scores, we still
1874 // keep the navsuggestions in the same order, but we revert to only allowing 1944 // keep the navsuggestions in the same order, but we revert to only allowing
1875 // one navigation to appear because the scores are completely local. 1945 // one navigation to appear because the scores are completely local.
1876 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1946 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1877 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1947 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1878 "\"google:verbatimrelevance\":0," 1948 "\"google:verbatimrelevance\":0,"
1879 "\"google:suggestrelevance\":[9998, 9999]}]", 1949 "\"google:suggestrelevance\":[9998, 9999]}]",
1880 { { "a", true, true }, 1950 { { "a", true, true },
1881 { "a2.com", false, true }, 1951 { "a2.com", false, true },
1882 { "k a", false, true }, 1952 { "k a", false, true },
1883 kEmptyMatch, kEmptyMatch}, 1953 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1884 std::string() }, 1954 std::string() },
1885 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1955 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1886 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1956 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1887 "\"google:verbatimrelevance\":0," 1957 "\"google:verbatimrelevance\":0,"
1888 "\"google:suggestrelevance\":[9999, 9998]}]", 1958 "\"google:suggestrelevance\":[9999, 9998]}]",
1889 { { "a", true, true }, 1959 { { "a", true, true },
1890 { "a1.com", false, true }, 1960 { "a1.com", false, true },
1891 { "k a", false, true }, 1961 { "k a", false, true },
1892 kEmptyMatch, kEmptyMatch}, 1962 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1893 std::string() }, 1963 std::string() },
1894 // More checks that everything works when it's not necessary to demote. 1964 // More checks that everything works when it's not necessary to demote.
1895 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1965 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1896 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1966 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1897 "\"google:verbatimrelevance\":9990," 1967 "\"google:verbatimrelevance\":9990,"
1898 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", 1968 "\"google:suggestrelevance\":[9997, 9998, 9999]}]",
1899 { { "a3", true, true }, 1969 { { "a3", true, true },
1900 { "a2.com", false, true }, 1970 { "a2.com", false, true },
1901 { "a1.com", false, true }, 1971 { "a1.com", false, true },
1902 { "a", true, true }, 1972 { "a", true, true },
1903 { "k a", false, true } }, 1973 { "k a", false, true },
1974 kEmptyMatch },
1904 "3" }, 1975 "3" },
1905 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1976 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1906 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1977 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1907 "\"google:verbatimrelevance\":9990," 1978 "\"google:verbatimrelevance\":9990,"
1908 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1979 "\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1909 { { "a3", true, true }, 1980 { { "a3", true, true },
1910 { "a1.com", false, true }, 1981 { "a1.com", false, true },
1911 { "a2.com", false, true }, 1982 { "a2.com", false, true },
1912 { "a", true, true }, 1983 { "a", true, true },
1913 { "k a", false, true } }, 1984 { "k a", false, true },
1985 kEmptyMatch },
1914 "3" }, 1986 "3" },
1915 }; 1987 };
1916 1988
1917 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { 1989 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
1918 QueryForInput(ASCIIToUTF16("k a"), false, true); 1990 QueryForInput(ASCIIToUTF16("k a"), false, true);
1919 1991
1920 // Set up a default fetcher with no results. 1992 // Set up a default fetcher with no results.
1921 net::TestURLFetcher* default_fetcher = 1993 net::TestURLFetcher* default_fetcher =
1922 test_factory_.GetFetcherByID( 1994 test_factory_.GetFetcherByID(
1923 SearchProvider::kDefaultProviderURLFetcherID); 1995 SearchProvider::kDefaultProviderURLFetcherID);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 matches[j].allowed_to_be_default_match) << description; 2028 matches[j].allowed_to_be_default_match) << description;
1957 } 2029 }
1958 // Ensure that no expected matches are missing. 2030 // Ensure that no expected matches are missing.
1959 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) 2031 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j)
1960 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << 2032 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) <<
1961 "Case # " << i << " " << description; 2033 "Case # " << i << " " << description;
1962 } 2034 }
1963 } 2035 }
1964 2036
1965 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { 2037 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) {
1966 // Enable Instant Extended in order to allow an increased number of
1967 // suggestions.
1968 chrome::EnableInstantExtendedAPIForTesting();
1969
1970 // We hardcode the string "term1" below, so ensure that the search term that 2038 // We hardcode the string "term1" below, so ensure that the search term that
1971 // got added to history already is that string. 2039 // got added to history already is that string.
1972 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); 2040 ASSERT_EQ(ASCIIToUTF16("term1"), term1_);
1973 string16 term = term1_.substr(0, term1_.length() - 1); 2041 string16 term = term1_.substr(0, term1_.length() - 1);
1974 2042
1975 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); 2043 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2);
1976 profile_.BlockUntilHistoryProcessesPendingRequests(); 2044 profile_.BlockUntilHistoryProcessesPendingRequests();
1977 2045
1978 struct { 2046 struct {
1979 const string16 input; 2047 const string16 input;
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 AutocompleteInput::OTHER, &profile_)); 3261 AutocompleteInput::OTHER, &profile_));
3194 encrypted_types.Remove(syncer::SESSIONS); 3262 encrypted_types.Remove(syncer::SESSIONS);
3195 service->OnEncryptedTypesChanged(encrypted_types, false); 3263 service->OnEncryptedTypesChanged(encrypted_types, false);
3196 3264
3197 // Check that there were no side effects from previous tests. 3265 // Check that there were no side effects from previous tests.
3198 EXPECT_TRUE(SearchProvider::CanSendURL( 3266 EXPECT_TRUE(SearchProvider::CanSendURL(
3199 GURL("http://www.google.com/search"), 3267 GURL("http://www.google.com/search"),
3200 GURL("https://www.google.com/complete/search"), &google_template_url, 3268 GURL("https://www.google.com/complete/search"), &google_template_url,
3201 AutocompleteInput::OTHER, &profile_)); 3269 AutocompleteInput::OTHER, &profile_));
3202 } 3270 }
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/chrome_content_browser_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698