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 <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" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // Tell the SearchProvider the default suggest query is done. | 434 // Tell the SearchProvider the default suggest query is done. |
435 default_fetcher->set_response_code(200); | 435 default_fetcher->set_response_code(200); |
436 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); | 436 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); |
437 } | 437 } |
438 | 438 |
439 void SearchProviderTest::ForcedQueryTestHelper( | 439 void SearchProviderTest::ForcedQueryTestHelper( |
440 const std::string& input, | 440 const std::string& input, |
441 const std::string& json, | 441 const std::string& json, |
442 const std::string expected_matches[3], | 442 const std::string expected_matches[3], |
443 const std::string& error_description) { | 443 const std::string& error_description) { |
444 // Send the query twice in order to bypass checks about whether a single | 444 QueryForInput(ASCIIToUTF16(input), false, false); |
445 // new reply can change the inline autocompletion. | 445 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( |
446 for (size_t i = 0; i < 2; i++) { | 446 SearchProvider::kDefaultProviderURLFetcherID); |
447 QueryForInput(ASCIIToUTF16(input), false, false); | 447 ASSERT_TRUE(fetcher); |
448 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | 448 fetcher->set_response_code(200); |
449 SearchProvider::kDefaultProviderURLFetcherID); | 449 fetcher->SetResponseString(json); |
450 ASSERT_TRUE(fetcher); | 450 fetcher->delegate()->OnURLFetchComplete(fetcher); |
451 fetcher->set_response_code(200); | 451 RunTillProviderDone(); |
452 fetcher->SetResponseString(json); | |
453 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
454 RunTillProviderDone(); | |
455 } | |
456 | 452 |
457 const ACMatches& matches = provider_->matches(); | 453 const ACMatches& matches = provider_->matches(); |
458 ASSERT_LE(matches.size(), 3u); | 454 ASSERT_LE(matches.size(), 3u); |
459 size_t i = 0; | 455 size_t i = 0; |
460 // Ensure that the returned matches equal the expectations. | 456 // Ensure that the returned matches equal the expectations. |
461 for (; i < matches.size(); ++i) { | 457 for (; i < matches.size(); ++i) { |
462 EXPECT_EQ(ASCIIToUTF16(expected_matches[i]), matches[i].contents) << | 458 EXPECT_EQ(ASCIIToUTF16(expected_matches[i]), matches[i].contents) << |
463 error_description; | 459 error_description; |
464 } | 460 } |
465 // Ensure that no expected matches are missing. | 461 // Ensure that no expected matches are missing. |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 fetcher->delegate()->OnURLFetchComplete(fetcher); | 1123 fetcher->delegate()->OnURLFetchComplete(fetcher); |
1128 fetcher = NULL; | 1124 fetcher = NULL; |
1129 | 1125 |
1130 // Run till the history results complete. | 1126 // Run till the history results complete. |
1131 RunTillProviderDone(); | 1127 RunTillProviderDone(); |
1132 | 1128 |
1133 // Make sure the only match is 'a.com' and it doesn't have a template_url. | 1129 // Make sure the only match is 'a.com' and it doesn't have a template_url. |
1134 AutocompleteMatch nav_match; | 1130 AutocompleteMatch nav_match; |
1135 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); | 1131 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); |
1136 EXPECT_TRUE(nav_match.keyword.empty()); | 1132 EXPECT_TRUE(nav_match.keyword.empty()); |
1137 EXPECT_FALSE(nav_match.allowed_to_be_default_match); | 1133 EXPECT_TRUE(nav_match.allowed_to_be_default_match); |
1138 EXPECT_FALSE(FindMatchWithDestination(GURL("http://a.com/b"), &nav_match)); | 1134 EXPECT_FALSE(FindMatchWithDestination(GURL("http://a.com/b"), &nav_match)); |
1139 } | 1135 } |
1140 | 1136 |
1141 // Verifies that the most relevant suggest results are added properly. | 1137 // Verifies that the most relevant suggest results are added properly. |
1142 TEST_F(SearchProviderTest, SuggestRelevance) { | 1138 TEST_F(SearchProviderTest, SuggestRelevance) { |
1143 QueryForInput(ASCIIToUTF16("a"), false, false); | 1139 QueryForInput(ASCIIToUTF16("a"), false, false); |
1144 | 1140 |
1145 // Make sure the default provider's suggest service was queried. | 1141 // Make sure the default provider's suggest service was queried. |
1146 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | 1142 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( |
1147 SearchProvider::kDefaultProviderURLFetcherID); | 1143 SearchProvider::kDefaultProviderURLFetcherID); |
(...skipping 12 matching lines...) Expand all Loading... |
1160 AutocompleteMatch verbatim, match_a1, match_a2, match_a3, match_a4; | 1156 AutocompleteMatch verbatim, match_a1, match_a2, match_a3, match_a4; |
1161 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a"), &verbatim)); | 1157 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a"), &verbatim)); |
1162 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a1"), &match_a1)); | 1158 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a1"), &match_a1)); |
1163 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a2"), &match_a2)); | 1159 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a2"), &match_a2)); |
1164 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a3"), &match_a3)); | 1160 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a3"), &match_a3)); |
1165 EXPECT_FALSE(FindMatchWithContents(ASCIIToUTF16("a4"), &match_a4)); | 1161 EXPECT_FALSE(FindMatchWithContents(ASCIIToUTF16("a4"), &match_a4)); |
1166 EXPECT_GT(verbatim.relevance, match_a1.relevance); | 1162 EXPECT_GT(verbatim.relevance, match_a1.relevance); |
1167 EXPECT_GT(match_a1.relevance, match_a2.relevance); | 1163 EXPECT_GT(match_a1.relevance, match_a2.relevance); |
1168 EXPECT_GT(match_a2.relevance, match_a3.relevance); | 1164 EXPECT_GT(match_a2.relevance, match_a3.relevance); |
1169 EXPECT_TRUE(verbatim.allowed_to_be_default_match); | 1165 EXPECT_TRUE(verbatim.allowed_to_be_default_match); |
1170 EXPECT_FALSE(match_a1.allowed_to_be_default_match); | 1166 EXPECT_TRUE(match_a1.allowed_to_be_default_match); |
1171 EXPECT_FALSE(match_a2.allowed_to_be_default_match); | 1167 EXPECT_TRUE(match_a2.allowed_to_be_default_match); |
1172 EXPECT_FALSE(match_a3.allowed_to_be_default_match); | 1168 EXPECT_TRUE(match_a3.allowed_to_be_default_match); |
1173 } | 1169 } |
1174 | 1170 |
1175 // Verifies that the default provider abandons suggested relevance scores | 1171 // Verifies that the default provider abandons suggested relevance scores |
1176 // when in keyword mode. This should happen regardless of whether the | 1172 // when in keyword mode. This should happen regardless of whether the |
1177 // keyword provider returns suggested relevance scores. | 1173 // keyword provider returns suggested relevance scores. |
1178 TEST_F(SearchProviderTest, DefaultProviderNoSuggestRelevanceInKeywordMode) { | 1174 TEST_F(SearchProviderTest, DefaultProviderNoSuggestRelevanceInKeywordMode) { |
1179 struct { | 1175 struct { |
1180 const std::string default_provider_json; | 1176 const std::string default_provider_json; |
1181 const std::string keyword_provider_json; | 1177 const std::string keyword_provider_json; |
1182 const std::string matches[5]; | 1178 const std::string matches[5]; |
(...skipping 12 matching lines...) Expand all Loading... |
1195 "{\"google:verbatimrelevance\":9700," | 1191 "{\"google:verbatimrelevance\":9700," |
1196 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," | 1192 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," |
1197 "\"google:suggestrelevance\":[9900, 9800]}]", | 1193 "\"google:suggestrelevance\":[9900, 9800]}]", |
1198 "[\"a\",[\"akeyword-query\"],[],[],{\"google:suggesttype\":[\"QUERY\"]," | 1194 "[\"a\",[\"akeyword-query\"],[],[],{\"google:suggesttype\":[\"QUERY\"]," |
1199 "\"google:verbatimrelevance\":9500," | 1195 "\"google:verbatimrelevance\":9500," |
1200 "\"google:suggestrelevance\":[9600]}]", | 1196 "\"google:suggestrelevance\":[9600]}]", |
1201 { "akeyword-query", "a", "k a", "adefault.com", "k adefault-query" } } | 1197 { "akeyword-query", "a", "k a", "adefault.com", "k adefault-query" } } |
1202 }; | 1198 }; |
1203 | 1199 |
1204 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1200 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
1205 // Send the query twice in order to bypass checks about whether a single | 1201 QueryForInput(ASCIIToUTF16("k a"), false, true); |
1206 // new reply can change the inline autocompletion. | 1202 net::TestURLFetcher* default_fetcher = |
1207 for (size_t j = 0; j < 2; j++) { | 1203 test_factory_.GetFetcherByID( |
1208 QueryForInput(ASCIIToUTF16("k a"), false, true); | 1204 SearchProvider::kDefaultProviderURLFetcherID); |
1209 net::TestURLFetcher* default_fetcher = | 1205 ASSERT_TRUE(default_fetcher); |
1210 test_factory_.GetFetcherByID( | 1206 default_fetcher->set_response_code(200); |
1211 SearchProvider::kDefaultProviderURLFetcherID); | 1207 default_fetcher->SetResponseString(cases[i].default_provider_json); |
1212 ASSERT_TRUE(default_fetcher); | 1208 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); |
1213 default_fetcher->set_response_code(200); | 1209 net::TestURLFetcher* keyword_fetcher = |
1214 default_fetcher->SetResponseString(cases[i].default_provider_json); | 1210 test_factory_.GetFetcherByID( |
1215 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); | 1211 SearchProvider::kKeywordProviderURLFetcherID); |
1216 net::TestURLFetcher* keyword_fetcher = | 1212 ASSERT_TRUE(keyword_fetcher); |
1217 test_factory_.GetFetcherByID( | 1213 keyword_fetcher->set_response_code(200); |
1218 SearchProvider::kKeywordProviderURLFetcherID); | 1214 keyword_fetcher->SetResponseString(cases[i].keyword_provider_json); |
1219 ASSERT_TRUE(keyword_fetcher); | 1215 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); |
1220 keyword_fetcher->set_response_code(200); | 1216 RunTillProviderDone(); |
1221 keyword_fetcher->SetResponseString(cases[i].keyword_provider_json); | |
1222 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); | |
1223 RunTillProviderDone(); | |
1224 } | |
1225 | 1217 |
1226 const std::string description = "for input with default_provider_json=" + | 1218 const std::string description = "for input with default_provider_json=" + |
1227 cases[i].default_provider_json + " and keyword_provider_json=" + | 1219 cases[i].default_provider_json + " and keyword_provider_json=" + |
1228 cases[i].keyword_provider_json; | 1220 cases[i].keyword_provider_json; |
1229 const ACMatches& matches = provider_->matches(); | 1221 const ACMatches& matches = provider_->matches(); |
1230 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 1222 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
1231 size_t j = 0; | 1223 size_t j = 0; |
1232 // Ensure that the returned matches equal the expectations. | 1224 // Ensure that the returned matches equal the expectations. |
1233 for (; j < matches.size(); ++j) { | 1225 for (; j < matches.size(); ++j) { |
1234 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), matches[j].contents) << | 1226 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), matches[j].contents) << |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1264 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
1273 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 1265 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
1274 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, | 1266 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
1275 kEmptyMatch, kEmptyMatch }, | 1267 kEmptyMatch, kEmptyMatch }, |
1276 std::string() }, | 1268 std::string() }, |
1277 | 1269 |
1278 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1270 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
1279 // Negative values will have no effect; the calculated value will be used. | 1271 // Negative values will have no effect; the calculated value will be used. |
1280 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1272 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
1281 "\"google:suggestrelevance\":[9998]}]", | 1273 "\"google:suggestrelevance\":[9998]}]", |
1282 { { "a", true}, { "a1", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1274 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1283 kEmptyMatch }, | 1275 kEmptyMatch }, |
1284 std::string() }, | 1276 std::string() }, |
1285 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1277 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
1286 "\"google:suggestrelevance\":[9999]}]", | 1278 "\"google:suggestrelevance\":[9999]}]", |
1287 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1279 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1288 kEmptyMatch }, | 1280 kEmptyMatch }, |
1289 "1" }, | 1281 "1" }, |
1290 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 1282 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
1291 "\"google:suggestrelevance\":[9999]}]", | 1283 "\"google:suggestrelevance\":[9999]}]", |
1292 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1284 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1293 kEmptyMatch }, | 1285 kEmptyMatch }, |
1294 "1" }, | 1286 "1" }, |
1295 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 1287 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
1296 "\"google:suggestrelevance\":[9999]}]", | 1288 "\"google:suggestrelevance\":[9999]}]", |
1297 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1289 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1298 kEmptyMatch }, | 1290 kEmptyMatch }, |
1299 "1" }, | 1291 "1" }, |
1300 { "[\"a\",[\"http://a.com\"],[],[]," | 1292 { "[\"a\",[\"http://a.com\"],[],[]," |
1301 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1293 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1302 "\"google:verbatimrelevance\":9999," | 1294 "\"google:verbatimrelevance\":9999," |
1303 "\"google:suggestrelevance\":[9998]}]", | 1295 "\"google:suggestrelevance\":[9998]}]", |
1304 { { "a", true }, { "a.com", false }, kEmptyMatch, kEmptyMatch, | 1296 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1305 kEmptyMatch, kEmptyMatch }, | 1297 kEmptyMatch }, |
1306 std::string() }, | 1298 std::string() }, |
1307 { "[\"a\",[\"http://a.com\"],[],[]," | 1299 { "[\"a\",[\"http://a.com\"],[],[]," |
1308 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1300 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1309 "\"google:verbatimrelevance\":9998," | 1301 "\"google:verbatimrelevance\":9998," |
1310 "\"google:suggestrelevance\":[9999]}]", | 1302 "\"google:suggestrelevance\":[9999]}]", |
1311 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1303 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1312 kEmptyMatch }, | 1304 kEmptyMatch }, |
1313 ".com" }, | 1305 ".com" }, |
1314 { "[\"a\",[\"http://a.com\"],[],[]," | 1306 { "[\"a\",[\"http://a.com\"],[],[]," |
1315 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1307 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1316 "\"google:verbatimrelevance\":0," | 1308 "\"google:verbatimrelevance\":0," |
1317 "\"google:suggestrelevance\":[9999]}]", | 1309 "\"google:suggestrelevance\":[9999]}]", |
1318 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1310 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1319 kEmptyMatch }, | 1311 kEmptyMatch }, |
1320 ".com" }, | 1312 ".com" }, |
1321 { "[\"a\",[\"http://a.com\"],[],[]," | 1313 { "[\"a\",[\"http://a.com\"],[],[]," |
1322 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1314 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1323 "\"google:verbatimrelevance\":-1," | 1315 "\"google:verbatimrelevance\":-1," |
1324 "\"google:suggestrelevance\":[9999]}]", | 1316 "\"google:suggestrelevance\":[9999]}]", |
1325 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1317 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1326 kEmptyMatch }, | 1318 kEmptyMatch }, |
1327 ".com" }, | 1319 ".com" }, |
1328 | 1320 |
1329 // Ensure that both types of relevance scores reorder matches together. | 1321 // Ensure that both types of relevance scores reorder matches together. |
1330 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1322 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
1331 "\"google:verbatimrelevance\":9998}]", | 1323 "\"google:verbatimrelevance\":9998}]", |
1332 { { "a1", true }, { "a", true }, { "a2", false }, kEmptyMatch, | 1324 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, |
1333 kEmptyMatch, kEmptyMatch }, | 1325 kEmptyMatch }, |
1334 "1" }, | 1326 "1" }, |
1335 | 1327 |
1336 // Check that an inlineable result appears first regardless of its score. | 1328 // Allow non-inlineable matches to be the highest-scoring match but, |
1337 // Also, if the result set lacks a single inlineable result, abandon the | 1329 // if the result set lacks a single inlineable result, abandon suggested |
1338 // request to suppress verbatim (verbatim_relevance=0), which will then | 1330 // relevance scores entirely. |
1339 // cause verbatim to appear (first). | |
1340 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1331 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
1341 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1332 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1342 kEmptyMatch }, | 1333 kEmptyMatch }, |
1343 std::string() }, | 1334 std::string() }, |
1344 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1335 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
1345 "\"google:verbatimrelevance\":0}]", | 1336 "\"google:verbatimrelevance\":0}]", |
1346 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1337 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1347 kEmptyMatch }, | 1338 kEmptyMatch }, |
1348 std::string() }, | 1339 std::string() }, |
1349 { "[\"a\",[\"http://b.com\"],[],[]," | 1340 { "[\"a\",[\"http://b.com\"],[],[]," |
1350 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1341 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1351 "\"google:suggestrelevance\":[9999]}]", | 1342 "\"google:suggestrelevance\":[9999]}]", |
1352 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, | 1343 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch, |
1353 kEmptyMatch, kEmptyMatch }, | 1344 kEmptyMatch, kEmptyMatch }, |
1354 std::string() }, | 1345 std::string() }, |
1355 { "[\"a\",[\"http://b.com\"],[],[]," | 1346 { "[\"a\",[\"http://b.com\"],[],[]," |
1356 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1347 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1357 "\"google:suggestrelevance\":[9999]," | 1348 "\"google:suggestrelevance\":[9999]," |
1358 "\"google:verbatimrelevance\":0}]", | 1349 "\"google:verbatimrelevance\":0}]", |
1359 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, | 1350 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, |
1360 kEmptyMatch, kEmptyMatch }, | 1351 kEmptyMatch, kEmptyMatch }, |
1361 std::string() }, | 1352 std::string() }, |
1362 | 1353 |
1363 // Allow low-scoring matches. | 1354 // Allow low-scoring matches. |
1364 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1355 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
1365 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1356 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1366 kEmptyMatch }, | 1357 kEmptyMatch }, |
1367 "1" }, | 1358 "1" }, |
1368 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":10}]", | 1359 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
1369 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1360 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1370 kEmptyMatch }, | 1361 kEmptyMatch }, |
1371 "1" }, | 1362 "1" }, |
1372 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[10]," | 1363 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
1373 "\"google:verbatimrelevance\":0}]", | 1364 "\"google:verbatimrelevance\":0}]", |
1374 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1365 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1375 kEmptyMatch }, | 1366 kEmptyMatch }, |
1376 "1" }, | 1367 "1" }, |
1377 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 20]," | 1368 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
1378 "\"google:verbatimrelevance\":0}]", | 1369 "\"google:verbatimrelevance\":0}]", |
1379 { { "a2", true }, { "a1", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1370 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1380 kEmptyMatch }, | 1371 kEmptyMatch }, |
1381 "2" }, | 1372 "2" }, |
1382 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 30]," | 1373 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
1383 "\"google:verbatimrelevance\":20}]", | 1374 "\"google:verbatimrelevance\":2}]", |
1384 { { "a2", true }, { "a", true }, { "a1", false }, kEmptyMatch, | 1375 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
1385 kEmptyMatch, kEmptyMatch }, | 1376 kEmptyMatch }, |
1386 "2" }, | 1377 "2" }, |
1387 { "[\"a\",[\"http://a.com\"],[],[]," | 1378 { "[\"a\",[\"http://a.com\"],[],[]," |
1388 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1379 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1389 "\"google:suggestrelevance\":[10]," | 1380 "\"google:suggestrelevance\":[1]," |
1390 "\"google:verbatimrelevance\":0}]", | 1381 "\"google:verbatimrelevance\":0}]", |
1391 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1382 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1392 kEmptyMatch }, | 1383 kEmptyMatch }, |
1393 ".com" }, | 1384 ".com" }, |
1394 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1385 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1395 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1386 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1396 "\"google:suggestrelevance\":[10, 20]," | 1387 "\"google:suggestrelevance\":[1, 2]," |
1397 "\"google:verbatimrelevance\":0}]", | 1388 "\"google:verbatimrelevance\":0}]", |
1398 { { "a2.com", true }, { "a1.com", false }, kEmptyMatch, kEmptyMatch, | 1389 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
1399 kEmptyMatch, kEmptyMatch }, | 1390 kEmptyMatch, kEmptyMatch }, |
1400 "2.com" }, | 1391 "2.com" }, |
1401 | 1392 |
1402 // Ensure that all suggestions are considered, regardless of order. | 1393 // Ensure that all suggestions are considered, regardless of order. |
1403 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1394 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
1404 "{\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", | 1395 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
1405 { { "a", true }, { "h", false }, { "g", false }, { "f", false }, | 1396 { { "a", true }, { "h", false }, { "g", false }, { "f", false }, |
1406 { "e", false }, { "d", false } }, | 1397 { "e", false }, { "d", false } }, |
1407 std::string() }, | 1398 std::string() }, |
1408 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1399 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
1409 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1400 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
1410 "\"http://h.com\"],[],[]," | 1401 "\"http://h.com\"],[],[]," |
1411 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1402 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
1412 "\"NAVIGATION\", \"NAVIGATION\"," | 1403 "\"NAVIGATION\", \"NAVIGATION\"," |
1413 "\"NAVIGATION\", \"NAVIGATION\"," | 1404 "\"NAVIGATION\", \"NAVIGATION\"," |
1414 "\"NAVIGATION\"]," | 1405 "\"NAVIGATION\"]," |
1415 "\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", | 1406 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
1416 { { "a", true }, { "h.com", false }, { "g.com", false }, | 1407 { { "a", true }, { "h.com", false }, { "g.com", false }, |
1417 { "f.com", false }, { "e.com", false }, { "d.com", false } }, | 1408 { "f.com", false }, { "e.com", false }, { "d.com", false } }, |
1418 std::string() }, | 1409 std::string() }, |
1419 | 1410 |
1420 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1411 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
1421 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10]}]", | 1412 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
1422 { { "a", true }, { "a1", false }, { "a2", false }, kEmptyMatch, | 1413 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, |
1423 kEmptyMatch, kEmptyMatch }, | 1414 kEmptyMatch }, |
1424 std::string() }, | 1415 std::string() }, |
1425 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 10]}]", | 1416 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
1426 { { "a", true }, { "a1", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1417 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1427 kEmptyMatch }, | 1418 kEmptyMatch }, |
1428 std::string() }, | 1419 std::string() }, |
1429 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1420 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1430 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1421 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1431 "\"google:suggestrelevance\":[10]}]", | 1422 "\"google:suggestrelevance\":[1]}]", |
1432 { { "a", true }, { "a1.com", false }, kEmptyMatch, kEmptyMatch, | 1423 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
1433 kEmptyMatch, kEmptyMatch }, | 1424 kEmptyMatch, kEmptyMatch }, |
1434 std::string() }, | 1425 std::string() }, |
1435 { "[\"a\",[\"http://a1.com\"],[],[]," | 1426 { "[\"a\",[\"http://a1.com\"],[],[]," |
1436 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1427 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1437 "\"google:suggestrelevance\":[9999, 10]}]", | 1428 "\"google:suggestrelevance\":[9999, 1]}]", |
1438 { { "a", true }, { "a1.com", false }, kEmptyMatch, kEmptyMatch, | 1429 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, |
1439 kEmptyMatch, kEmptyMatch }, | 1430 kEmptyMatch, kEmptyMatch }, |
1440 std::string() }, | 1431 std::string() }, |
1441 | 1432 |
1442 // Ensure that all 'verbatim' results are merged with their maximum score. | 1433 // Ensure that all 'verbatim' results are merged with their maximum score. |
1443 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1434 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
1444 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1435 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
1445 { { "a2", true }, { "a", true }, { "a1", false }, kEmptyMatch, | 1436 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
1446 kEmptyMatch, kEmptyMatch }, | 1437 kEmptyMatch }, |
1447 "2" }, | 1438 "2" }, |
1448 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1439 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
1449 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1440 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
1450 "\"google:verbatimrelevance\":0}]", | 1441 "\"google:verbatimrelevance\":0}]", |
1451 { { "a2", true }, { "a", true }, { "a1", false }, kEmptyMatch, | 1442 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, |
1452 kEmptyMatch, kEmptyMatch }, | 1443 kEmptyMatch }, |
1453 "2" }, | 1444 "2" }, |
1454 | 1445 |
1455 // Ensure that verbatim is always generated without other suggestions. | 1446 // Ensure that verbatim is always generated without other suggestions. |
1456 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). | 1447 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). |
1457 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1448 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
1458 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1449 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1459 kEmptyMatch }, | 1450 kEmptyMatch }, |
1460 std::string() }, | 1451 std::string() }, |
1461 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1452 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
1462 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1453 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, |
1463 kEmptyMatch }, | 1454 kEmptyMatch }, |
1464 std::string() }, | 1455 std::string() }, |
1465 }; | 1456 }; |
1466 | 1457 |
1467 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1458 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
1468 // Send the query twice in order to bypass checks about whether a single | 1459 QueryForInput(ASCIIToUTF16("a"), false, false); |
1469 // new reply can change the inline autocompletion. | 1460 net::TestURLFetcher* fetcher = |
1470 for (size_t j = 0; j < 2; j++) { | 1461 test_factory_.GetFetcherByID( |
1471 QueryForInput(ASCIIToUTF16("a"), false, false); | 1462 SearchProvider::kDefaultProviderURLFetcherID); |
1472 net::TestURLFetcher* fetcher = | 1463 ASSERT_TRUE(fetcher); |
1473 test_factory_.GetFetcherByID( | 1464 fetcher->set_response_code(200); |
1474 SearchProvider::kDefaultProviderURLFetcherID); | 1465 fetcher->SetResponseString(cases[i].json); |
1475 ASSERT_TRUE(fetcher); | 1466 fetcher->delegate()->OnURLFetchComplete(fetcher); |
1476 fetcher->set_response_code(200); | 1467 RunTillProviderDone(); |
1477 fetcher->SetResponseString(cases[i].json); | |
1478 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
1479 RunTillProviderDone(); | |
1480 } | |
1481 | 1468 |
1482 const std::string description = "for input with json=" + cases[i].json; | 1469 const std::string description = "for input with json=" + cases[i].json; |
1483 const ACMatches& matches = provider_->matches(); | 1470 const ACMatches& matches = provider_->matches(); |
1484 ASSERT_FALSE(matches.empty()); | 1471 ASSERT_FALSE(matches.empty()); |
1485 // Find the first match that's allowed to be the default match and check | 1472 // Find the first match that's allowed to be the default match and check |
1486 // its inline_autocompletion. | 1473 // its inline_autocompletion. |
1487 ACMatches::const_iterator it = FindDefaultMatch(matches); | 1474 ACMatches::const_iterator it = FindDefaultMatch(matches); |
1488 ASSERT_NE(matches.end(), it); | 1475 ASSERT_NE(matches.end(), it); |
1489 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 1476 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
1490 it->inline_autocompletion) << description; | 1477 it->inline_autocompletion) << description; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 { "b.com", false, false }, | 1547 { "b.com", false, false }, |
1561 { "k a", false, false }, | 1548 { "k a", false, false }, |
1562 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1549 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1563 std::string() }, | 1550 std::string() }, |
1564 | 1551 |
1565 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1552 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
1566 // Negative values will have no effect; the calculated value will be used. | 1553 // Negative values will have no effect; the calculated value will be used. |
1567 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1554 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
1568 "\"google:suggestrelevance\":[9998]}]", | 1555 "\"google:suggestrelevance\":[9998]}]", |
1569 { { "a", true, true }, | 1556 { { "a", true, true }, |
1570 { "a1", true, false }, | 1557 { "a1", true, true }, |
1571 { "k a", false, false }, | 1558 { "k a", false, false }, |
1572 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1559 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1573 std::string() }, | 1560 std::string() }, |
1574 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1561 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
1575 "\"google:suggestrelevance\":[9999]}]", | 1562 "\"google:suggestrelevance\":[9999]}]", |
1576 { { "a1", true, true }, | 1563 { { "a1", true, true }, |
1577 { "a", true, true }, | 1564 { "a", true, true }, |
1578 { "k a", false, false }, | 1565 { "k a", false, false }, |
1579 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1566 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1580 "1" }, | 1567 "1" }, |
(...skipping 18 matching lines...) Expand all Loading... |
1599 { "a.com", false, false }, | 1586 { "a.com", false, false }, |
1600 { "k a", false, false }, | 1587 { "k a", false, false }, |
1601 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1588 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1602 std::string() }, | 1589 std::string() }, |
1603 | 1590 |
1604 // Ensure that both types of relevance scores reorder matches together. | 1591 // Ensure that both types of relevance scores reorder matches together. |
1605 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1592 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
1606 "\"google:verbatimrelevance\":9998}]", | 1593 "\"google:verbatimrelevance\":9998}]", |
1607 { { "a1", true, true }, | 1594 { { "a1", true, true }, |
1608 { "a", true, true }, | 1595 { "a", true, true }, |
1609 { "a2", true, false }, | 1596 { "a2", true, true }, |
1610 { "k a", false, false }, | 1597 { "k a", false, false }, |
1611 kEmptyMatch, kEmptyMatch }, | 1598 kEmptyMatch, kEmptyMatch }, |
1612 "1" }, | 1599 "1" }, |
1613 | 1600 |
1614 // Check that an inlinable match appears first regardless of its score. | 1601 // Check that non-inlinable matches may be ranked as the highest result |
| 1602 // if there is at least one inlineable match. |
1615 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1603 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
1616 { { "a", true, true }, | 1604 { { "b", true, false }, |
1617 { "b", true, false }, | 1605 { "a", true, true }, |
1618 { "k a", false, false }, | 1606 { "k a", false, false }, |
1619 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1607 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1620 std::string() }, | 1608 std::string() }, |
1621 { "[\"a\",[\"http://b.com\"],[],[]," | 1609 { "[\"a\",[\"http://b.com\"],[],[]," |
1622 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1610 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1623 "\"google:suggestrelevance\":[9999]}]", | 1611 "\"google:suggestrelevance\":[9999]}]", |
1624 { { "a", true, true }, | 1612 { { "b.com", false, false }, |
1625 { "b.com", false, false }, | 1613 { "a", true, true }, |
1626 { "k a", false, false }, | 1614 { "k a", false, false }, |
1627 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1615 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1628 std::string() }, | 1616 std::string() }, |
1629 // If there is no inlineable match, restore the keyword verbatim score. | 1617 // On the other hand, if there is no inlineable match, restore |
1630 // It'll then appear first. | 1618 // the keyword verbatim score. |
1631 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1619 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
1632 "\"google:verbatimrelevance\":0}]", | 1620 "\"google:verbatimrelevance\":0}]", |
1633 { { "a", true, true }, | 1621 { { "b", true, false }, |
1634 { "b", true, false }, | 1622 { "a", true, true }, |
1635 { "k a", false, false }, | 1623 { "k a", false, false }, |
1636 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1624 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1637 std::string() }, | 1625 std::string() }, |
1638 { "[\"a\",[\"http://b.com\"],[],[]," | 1626 { "[\"a\",[\"http://b.com\"],[],[]," |
1639 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1627 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1640 "\"google:suggestrelevance\":[9999]," | 1628 "\"google:suggestrelevance\":[9999]," |
1641 "\"google:verbatimrelevance\":0}]", | 1629 "\"google:verbatimrelevance\":0}]", |
1642 { { "a", true, true }, | 1630 { { "b.com", false, false }, |
1643 { "b.com", false, false }, | 1631 { "a", true, true }, |
1644 { "k a", false, false }, | 1632 { "k a", false, false }, |
1645 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1633 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1646 std::string() }, | 1634 std::string() }, |
1647 | 1635 |
1648 // The top result does not have to score as highly as calculated | 1636 // The top result does not have to score as highly as calculated |
1649 // verbatim. i.e., there are no minimum score restrictions in | 1637 // verbatim. i.e., there are no minimum score restrictions in |
1650 // this provider. | 1638 // this provider. |
1651 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1639 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
1652 { { "a1", true, true }, | 1640 { { "a1", true, true }, |
1653 { "k a", false, false }, | 1641 { "k a", false, false }, |
1654 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1642 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1655 "1" }, | 1643 "1" }, |
1656 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":10}]", | 1644 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
1657 { { "a1", true, true }, | 1645 { { "a1", true, true }, |
1658 { "k a", false, false }, | 1646 { "k a", false, false }, |
1659 { "a", true, true }, | 1647 { "a", true, true }, |
1660 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1648 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1661 "1" }, | 1649 "1" }, |
1662 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[10]," | 1650 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
1663 "\"google:verbatimrelevance\":0}]", | 1651 "\"google:verbatimrelevance\":0}]", |
1664 { { "a1", true, true }, | 1652 { { "k a", false, false }, |
1665 { "k a", false, false }, | 1653 { "a1", true, true }, |
1666 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1654 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1667 "1" }, | 1655 "1" }, |
1668 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 20]," | 1656 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
1669 "\"google:verbatimrelevance\":0}]", | 1657 "\"google:verbatimrelevance\":0}]", |
1670 { { "a2", true, true }, | 1658 { |
1671 { "k a", false, false }, | 1659 { "k a", false, false }, |
1672 { "a1", true, false }, | 1660 { "a2", true, true }, |
| 1661 { "a1", true, true }, |
1673 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1662 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1674 "2" }, | 1663 "2" }, |
1675 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 30]," | 1664 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
1676 "\"google:verbatimrelevance\":20}]", | 1665 "\"google:verbatimrelevance\":2}]", |
1677 { { "a2", true, true }, | 1666 { { "k a", false, false }, |
1678 { "k a", false, false }, | 1667 { "a2", true, true }, |
1679 { "a", true, true }, | 1668 { "a", true, true }, |
1680 { "a1", true, false }, | 1669 { "a1", true, true }, |
1681 kEmptyMatch, kEmptyMatch }, | 1670 kEmptyMatch, kEmptyMatch }, |
1682 "2" }, | 1671 "2" }, |
1683 | 1672 |
1684 // Ensure that all suggestions are considered, regardless of order. | 1673 // Ensure that all suggestions are considered, regardless of order. |
1685 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1674 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
1686 "{\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", | 1675 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
1687 { { "a", true, true }, | 1676 { { "a", true, true }, |
1688 { "k a", false, false }, | 1677 { "k a", false, false }, |
1689 { "h", true, false }, | 1678 { "h", true, false }, |
1690 { "g", true, false }, | 1679 { "g", true, false }, |
1691 { "f", true, false }, | 1680 { "f", true, false }, |
1692 { "e", true, false } }, | 1681 { "e", true, false } }, |
1693 std::string() }, | 1682 std::string() }, |
1694 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1683 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
1695 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1684 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
1696 "\"http://h.com\"],[],[]," | 1685 "\"http://h.com\"],[],[]," |
1697 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1686 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
1698 "\"NAVIGATION\", \"NAVIGATION\"," | 1687 "\"NAVIGATION\", \"NAVIGATION\"," |
1699 "\"NAVIGATION\", \"NAVIGATION\"," | 1688 "\"NAVIGATION\", \"NAVIGATION\"," |
1700 "\"NAVIGATION\"]," | 1689 "\"NAVIGATION\"]," |
1701 "\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", | 1690 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
1702 { { "a", true, true }, | 1691 { { "a", true, true }, |
1703 { "k a", false, false }, | 1692 { "k a", false, false }, |
1704 { "h.com", false, false }, | 1693 { "h.com", false, false }, |
1705 { "g.com", false, false }, | 1694 { "g.com", false, false }, |
1706 { "f.com", false, false }, | 1695 { "f.com", false, false }, |
1707 { "e.com", false, false } }, | 1696 { "e.com", false, false } }, |
1708 std::string() }, | 1697 std::string() }, |
1709 | 1698 |
1710 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1699 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
1711 // Note that keyword suggestions by default (not in suggested relevance | 1700 // Note that keyword suggestions by default (not in suggested relevance |
1712 // mode) score more highly than the default verbatim. | 1701 // mode) score more highly than the default verbatim. |
1713 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1702 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
1714 { { "a", true, true }, | 1703 { { "a", true, true }, |
1715 { "a1", true, false }, | 1704 { "a1", true, true }, |
1716 { "a2", true, false }, | 1705 { "a2", true, true }, |
1717 { "k a", false, false }, | 1706 { "k a", false, false }, |
1718 kEmptyMatch, kEmptyMatch }, | 1707 kEmptyMatch, kEmptyMatch }, |
1719 std::string() }, | 1708 std::string() }, |
1720 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1709 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
1721 { { "a", true, true }, | 1710 { { "a", true, true }, |
1722 { "a1", true, false }, | 1711 { "a1", true, true }, |
1723 { "k a", false, false }, | 1712 { "k a", false, false }, |
1724 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1713 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1725 std::string() }, | 1714 std::string() }, |
1726 // In this case, ignoring the suggested relevance scores means we keep | 1715 // In this case, ignoring the suggested relevance scores means we keep |
1727 // only one navsuggest result. | 1716 // only one navsuggest result. |
1728 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1717 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1729 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1718 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1730 "\"google:suggestrelevance\":[1]}]", | 1719 "\"google:suggestrelevance\":[1]}]", |
1731 { { "a", true, true }, | 1720 { { "a", true, true }, |
1732 { "a1.com", false, false }, | 1721 { "a1.com", false, false }, |
1733 { "k a", false, false }, | 1722 { "k a", false, false }, |
1734 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1723 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1735 std::string() }, | 1724 std::string() }, |
1736 { "[\"a\",[\"http://a1.com\"],[],[]," | 1725 { "[\"a\",[\"http://a1.com\"],[],[]," |
1737 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1726 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1738 "\"google:suggestrelevance\":[9999, 1]}]", | 1727 "\"google:suggestrelevance\":[9999, 1]}]", |
1739 { { "a", true, true }, | 1728 { { "a", true, true }, |
1740 { "a1.com", false, false }, | 1729 { "a1.com", false, false }, |
1741 { "k a", false, false }, | 1730 { "k a", false, false }, |
1742 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1731 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1743 std::string() }, | 1732 std::string() }, |
1744 | 1733 |
1745 // Ensure that all 'verbatim' results are merged with their maximum score. | 1734 // Ensure that all 'verbatim' results are merged with their maximum score. |
1746 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1735 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
1747 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1736 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
1748 { { "a2", true, true }, | 1737 { { "a2", true, true }, |
1749 { "a", true, true }, | 1738 { "a", true, true }, |
1750 { "a1", true, false }, | 1739 { "a1", true, true }, |
1751 { "k a", false, false }, | 1740 { "k a", false, false }, |
1752 kEmptyMatch, kEmptyMatch }, | 1741 kEmptyMatch, kEmptyMatch }, |
1753 "2" }, | 1742 "2" }, |
1754 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1743 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
1755 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1744 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
1756 "\"google:verbatimrelevance\":0}]", | 1745 "\"google:verbatimrelevance\":0}]", |
1757 { { "a2", true, true }, | 1746 { { "a2", true, true }, |
1758 { "a", true, true }, | 1747 { "a", true, true }, |
1759 { "a1", true, false }, | 1748 { "a1", true, true }, |
1760 { "k a", false, false }, | 1749 { "k a", false, false }, |
1761 kEmptyMatch, kEmptyMatch }, | 1750 kEmptyMatch, kEmptyMatch }, |
1762 "2" }, | 1751 "2" }, |
1763 | 1752 |
1764 // Ensure that verbatim is always generated without other suggestions. | 1753 // Ensure that verbatim is always generated without other suggestions. |
1765 // TODO(mpearson): Ensure the value of verbatimrelevance is respected | 1754 // TODO(mpearson): Ensure the value of verbatimrelevance is respected |
1766 // (except when suggested relevances are ignored). | 1755 // (except when suggested relevances are ignored). |
1767 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1756 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
1768 { { "a", true, true }, | 1757 { { "k a", false, false }, |
1769 { "k a", false, false }, | 1758 { "a", true, true }, |
1770 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1759 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1771 std::string() }, | 1760 std::string() }, |
1772 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1761 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
1773 { { "a", true, true }, | 1762 { { "a", true, true }, |
1774 { "k a", false, false }, | 1763 { "k a", false, false }, |
1775 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1764 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1776 std::string() }, | 1765 std::string() }, |
1777 | 1766 |
1778 // In reorder mode, navsuggestions will not need to be demoted (because | 1767 // In reorder mode, navsuggestions will not need to be demoted (because |
1779 // they are marked as not allowed to be default match and will be | 1768 // they are marked as not allowed to be default match and will be |
1780 // reordered as necessary). | 1769 // reordered as necessary). |
1781 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1770 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1782 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1771 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1783 "\"google:verbatimrelevance\":9990," | 1772 "\"google:verbatimrelevance\":9990," |
1784 "\"google:suggestrelevance\":[9998, 9999]}]", | 1773 "\"google:suggestrelevance\":[9998, 9999]}]", |
1785 { { "a", true, true }, | 1774 { { "a2.com", false, false }, |
1786 { "a2.com", false, false }, | |
1787 { "a1.com", false, false }, | 1775 { "a1.com", false, false }, |
| 1776 { "a", true, true }, |
1788 { "k a", false, false }, | 1777 { "k a", false, false }, |
1789 kEmptyMatch, kEmptyMatch }, | 1778 kEmptyMatch, kEmptyMatch }, |
1790 std::string() }, | 1779 std::string() }, |
1791 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1780 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1792 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1781 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1793 "\"google:verbatimrelevance\":9990," | 1782 "\"google:verbatimrelevance\":9990," |
1794 "\"google:suggestrelevance\":[9999, 9998]}]", | 1783 "\"google:suggestrelevance\":[9999, 9998]}]", |
1795 { { "a", true, true }, | 1784 { { "a1.com", false, false }, |
1796 { "a1.com", false, false }, | |
1797 { "a2.com", false, false }, | 1785 { "a2.com", false, false }, |
| 1786 { "a", true, true }, |
1798 { "k a", false, false }, | 1787 { "k a", false, false }, |
1799 kEmptyMatch, kEmptyMatch }, | 1788 kEmptyMatch, kEmptyMatch }, |
1800 std::string() }, | 1789 std::string() }, |
1801 { "[\"a\",[\"https://a/\"],[],[]," | 1790 { "[\"a\",[\"https://a/\"],[],[]," |
1802 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1791 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1803 "\"google:suggestrelevance\":[9999]}]", | 1792 "\"google:suggestrelevance\":[9999]}]", |
1804 { { "a", true, true }, | 1793 { { "https://a", false, false }, |
1805 { "https://a", false, false }, | 1794 { "a", true, true }, |
1806 { "k a", false, false }, | 1795 { "k a", false, false }, |
1807 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1796 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1808 std::string() }, | 1797 std::string() }, |
1809 // Check when navsuggest scores more than verbatim and there is query | 1798 // Check when navsuggest scores more than verbatim and there is query |
1810 // suggestion but it scores lower. | 1799 // suggestion but it scores lower. |
1811 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1800 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1812 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1801 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1813 "\"google:verbatimrelevance\":9990," | 1802 "\"google:verbatimrelevance\":9990," |
1814 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", | 1803 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
1815 { { "a", true, true }, | 1804 { { "a2.com", false, false }, |
1816 { "a2.com", false, false }, | |
1817 { "a1.com", false, false }, | 1805 { "a1.com", false, false }, |
1818 { "a3", true, false }, | 1806 { "a", true, true }, |
| 1807 { "a3", true, true }, |
1819 { "k a", false, false }, | 1808 { "k a", false, false }, |
1820 kEmptyMatch }, | 1809 kEmptyMatch }, |
1821 std::string() }, | 1810 std::string() }, |
1822 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1811 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1823 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1812 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1824 "\"google:verbatimrelevance\":9990," | 1813 "\"google:verbatimrelevance\":9990," |
1825 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", | 1814 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
1826 { { "a", true, true }, | 1815 { { "a1.com", false, false }, |
1827 { "a1.com", false, false }, | |
1828 { "a2.com", false, false }, | 1816 { "a2.com", false, false }, |
1829 { "a3", true, false }, | 1817 { "a", true, true }, |
| 1818 { "a3", true, true }, |
1830 { "k a", false, false }, | 1819 { "k a", false, false }, |
1831 kEmptyMatch }, | 1820 kEmptyMatch }, |
1832 std::string() }, | 1821 std::string() }, |
1833 // Check when navsuggest scores more than a query suggestion. There is | 1822 // Check when navsuggest scores more than a query suggestion. There is |
1834 // a verbatim but it scores lower. | 1823 // a verbatim but it scores lower. |
1835 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1824 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1836 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1825 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1837 "\"google:verbatimrelevance\":9990," | 1826 "\"google:verbatimrelevance\":9990," |
1838 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1827 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
1839 { { "a3", true, true }, | 1828 { { "a2.com", false, false }, |
1840 { "a2.com", false, false }, | |
1841 { "a1.com", false, false }, | 1829 { "a1.com", false, false }, |
| 1830 { "a3", true, true }, |
1842 { "a", true, true }, | 1831 { "a", true, true }, |
1843 { "k a", false, false }, | 1832 { "k a", false, false }, |
1844 kEmptyMatch }, | 1833 kEmptyMatch }, |
1845 "3" }, | 1834 "3" }, |
1846 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1835 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1847 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1836 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1848 "\"google:verbatimrelevance\":9990," | 1837 "\"google:verbatimrelevance\":9990," |
1849 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 1838 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
1850 { { "a3", true, true }, | 1839 { { "a1.com", false, false }, |
1851 { "a1.com", false, false }, | |
1852 { "a2.com", false, false }, | 1840 { "a2.com", false, false }, |
| 1841 { "a3", true, true }, |
1853 { "a", true, true }, | 1842 { "a", true, true }, |
1854 { "k a", false, false }, | 1843 { "k a", false, false }, |
1855 kEmptyMatch }, | 1844 kEmptyMatch }, |
1856 "3" }, | 1845 "3" }, |
1857 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1846 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1858 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1847 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1859 "\"google:verbatimrelevance\":0," | 1848 "\"google:verbatimrelevance\":0," |
1860 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1849 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
1861 { { "a3", true, true }, | 1850 { { "a2.com", false, false }, |
1862 { "a2.com", false, false }, | |
1863 { "a1.com", false, false }, | 1851 { "a1.com", false, false }, |
| 1852 { "a3", true, true }, |
1864 { "k a", false, false }, | 1853 { "k a", false, false }, |
1865 kEmptyMatch, kEmptyMatch }, | 1854 kEmptyMatch, kEmptyMatch }, |
1866 "3" }, | 1855 "3" }, |
1867 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1856 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1868 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1857 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1869 "\"google:verbatimrelevance\":0," | 1858 "\"google:verbatimrelevance\":0," |
1870 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 1859 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
1871 { { "a3", true, true }, | 1860 { { "a1.com", false, false }, |
1872 { "a1.com", false, false }, | |
1873 { "a2.com", false, false }, | 1861 { "a2.com", false, false }, |
| 1862 { "a3", true, true }, |
1874 { "k a", false, false }, | 1863 { "k a", false, false }, |
1875 kEmptyMatch, kEmptyMatch }, | 1864 kEmptyMatch, kEmptyMatch }, |
1876 "3" }, | 1865 "3" }, |
1877 // Check when there is neither verbatim nor a query suggestion that, | 1866 // Check when there is neither verbatim nor a query suggestion that, |
1878 // because we can't demote navsuggestions below a query suggestion, | 1867 // because we can't demote navsuggestions below a query suggestion, |
1879 // we restore the keyword verbatim score. | 1868 // we restore the keyword verbatim score. |
1880 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1869 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1881 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1870 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1882 "\"google:verbatimrelevance\":0," | 1871 "\"google:verbatimrelevance\":0," |
1883 "\"google:suggestrelevance\":[9998, 9999]}]", | 1872 "\"google:suggestrelevance\":[9998, 9999]}]", |
1884 { { "a", true, true }, | 1873 { { "a2.com", false, false }, |
1885 { "a2.com", false, false }, | |
1886 { "a1.com", false, false }, | 1874 { "a1.com", false, false }, |
| 1875 { "a", true, true }, |
1887 { "k a", false, false }, | 1876 { "k a", false, false }, |
1888 kEmptyMatch, kEmptyMatch }, | 1877 kEmptyMatch, kEmptyMatch }, |
1889 std::string() }, | 1878 std::string() }, |
1890 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1879 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1891 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1880 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1892 "\"google:verbatimrelevance\":0," | 1881 "\"google:verbatimrelevance\":0," |
1893 "\"google:suggestrelevance\":[9999, 9998]}]", | 1882 "\"google:suggestrelevance\":[9999, 9998]}]", |
1894 { { "a", true, true }, | 1883 { { "a1.com", false, false }, |
1895 { "a1.com", false, false }, | |
1896 { "a2.com", false, false }, | 1884 { "a2.com", false, false }, |
| 1885 { "a", true, true }, |
1897 { "k a", false, false }, | 1886 { "k a", false, false }, |
1898 kEmptyMatch, kEmptyMatch }, | 1887 kEmptyMatch, kEmptyMatch }, |
1899 std::string() }, | 1888 std::string() }, |
1900 // More checks that everything works when it's not necessary to demote. | 1889 // More checks that everything works when it's not necessary to demote. |
1901 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1890 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1902 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1891 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1903 "\"google:verbatimrelevance\":9990," | 1892 "\"google:verbatimrelevance\":9990," |
1904 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", | 1893 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
1905 { { "a3", true, true }, | 1894 { { "a3", true, true }, |
1906 { "a2.com", false, false }, | 1895 { "a2.com", false, false }, |
1907 { "a1.com", false, false }, | 1896 { "a1.com", false, false }, |
1908 { "a", true, true }, | 1897 { "a", true, true }, |
1909 { "k a", false, false }, | 1898 { "k a", false, false }, |
1910 kEmptyMatch }, | 1899 kEmptyMatch }, |
1911 "3" }, | 1900 "3" }, |
1912 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1901 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1913 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1902 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1914 "\"google:verbatimrelevance\":9990," | 1903 "\"google:verbatimrelevance\":9990," |
1915 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1904 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
1916 { { "a3", true, true }, | 1905 { { "a3", true, true }, |
1917 { "a1.com", false, false }, | 1906 { "a1.com", false, false }, |
1918 { "a2.com", false, false }, | 1907 { "a2.com", false, false }, |
1919 { "a", true, true }, | 1908 { "a", true, true }, |
1920 { "k a", false, false }, | 1909 { "k a", false, false }, |
1921 kEmptyMatch }, | 1910 kEmptyMatch }, |
1922 "3" }, | 1911 "3" }, |
1923 }; | 1912 }; |
1924 | 1913 |
1925 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1914 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
1926 // Send the query twice in order to bypass checks about whether a single | 1915 QueryForInput(ASCIIToUTF16("k a"), false, true); |
1927 // new reply can change the inline autocompletion. | |
1928 for (size_t j = 0; j < 2; j++) { | |
1929 QueryForInput(ASCIIToUTF16("k a"), false, true); | |
1930 | 1916 |
1931 // Set up a default fetcher with no results. | 1917 // Set up a default fetcher with no results. |
1932 net::TestURLFetcher* default_fetcher = | 1918 net::TestURLFetcher* default_fetcher = |
1933 test_factory_.GetFetcherByID( | 1919 test_factory_.GetFetcherByID( |
1934 SearchProvider::kDefaultProviderURLFetcherID); | 1920 SearchProvider::kDefaultProviderURLFetcherID); |
1935 ASSERT_TRUE(default_fetcher); | 1921 ASSERT_TRUE(default_fetcher); |
1936 default_fetcher->set_response_code(200); | 1922 default_fetcher->set_response_code(200); |
1937 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); | 1923 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); |
1938 default_fetcher = NULL; | 1924 default_fetcher = NULL; |
1939 | 1925 |
1940 // Set up a keyword fetcher with provided results. | 1926 // Set up a keyword fetcher with provided results. |
1941 net::TestURLFetcher* keyword_fetcher = | 1927 net::TestURLFetcher* keyword_fetcher = |
1942 test_factory_.GetFetcherByID( | 1928 test_factory_.GetFetcherByID( |
1943 SearchProvider::kKeywordProviderURLFetcherID); | 1929 SearchProvider::kKeywordProviderURLFetcherID); |
1944 ASSERT_TRUE(keyword_fetcher); | 1930 ASSERT_TRUE(keyword_fetcher); |
1945 keyword_fetcher->set_response_code(200); | 1931 keyword_fetcher->set_response_code(200); |
1946 keyword_fetcher->SetResponseString(cases[i].json); | 1932 keyword_fetcher->SetResponseString(cases[i].json); |
1947 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); | 1933 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); |
1948 keyword_fetcher = NULL; | 1934 keyword_fetcher = NULL; |
1949 RunTillProviderDone(); | 1935 RunTillProviderDone(); |
1950 } | |
1951 | 1936 |
1952 const std::string description = "for input with json=" + cases[i].json; | 1937 const std::string description = "for input with json=" + cases[i].json; |
1953 const ACMatches& matches = provider_->matches(); | 1938 const ACMatches& matches = provider_->matches(); |
1954 ASSERT_FALSE(matches.empty()); | 1939 ASSERT_FALSE(matches.empty()); |
1955 // Find the first match that's allowed to be the default match and check | 1940 // Find the first match that's allowed to be the default match and check |
1956 // its inline_autocompletion. | 1941 // its inline_autocompletion. |
1957 ACMatches::const_iterator it = FindDefaultMatch(matches); | 1942 ACMatches::const_iterator it = FindDefaultMatch(matches); |
1958 ASSERT_NE(matches.end(), it); | 1943 ASSERT_NE(matches.end(), it); |
1959 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 1944 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
1960 it->inline_autocompletion) << description; | 1945 it->inline_autocompletion) << description; |
1961 | 1946 |
1962 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 1947 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
1963 size_t j = 0; | 1948 size_t j = 0; |
1964 // Ensure that the returned matches equal the expectations. | 1949 // Ensure that the returned matches equal the expectations. |
1965 for (; j < matches.size(); ++j) { | 1950 for (; j < matches.size(); ++j) { |
1966 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), | 1951 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), |
1967 matches[j].contents) << description; | 1952 matches[j].contents) << description; |
1968 EXPECT_EQ(cases[i].matches[j].from_keyword, | 1953 EXPECT_EQ(cases[i].matches[j].from_keyword, |
1969 matches[j].keyword == ASCIIToUTF16("k")) << description; | 1954 matches[j].keyword == ASCIIToUTF16("k")) << description; |
1970 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, | 1955 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, |
1971 matches[j].allowed_to_be_default_match) << description; | 1956 matches[j].allowed_to_be_default_match) << description; |
1972 } | 1957 } |
1973 // Ensure that no expected matches are missing. | 1958 // Ensure that no expected matches are missing. |
1974 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) | 1959 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) |
1975 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << | 1960 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << |
1976 "Case # " << i << " " << description; | 1961 "Case # " << i << " " << description; |
1977 } | 1962 } |
1978 } | 1963 } |
1979 | 1964 |
1980 TEST_F(SearchProviderTest, DontInlineAutocompleteAsynchronously) { | |
1981 struct Match { | |
1982 std::string contents; | |
1983 bool allowed_to_be_default_match; | |
1984 }; | |
1985 const Match kEmptyMatch = { kNotApplicable, false }; | |
1986 // This test sends two separate queries, each receiving different JSON | |
1987 // replies, and checks that receiving the second reply doesn't cause | |
1988 // an unexpected inline autcompletion. | |
1989 struct { | |
1990 const std::string first_json; | |
1991 const std::string second_json; | |
1992 const Match matches[4]; | |
1993 } cases[] = { | |
1994 // A simple test that verifies we inline autocomplete if the new top | |
1995 // suggestion is the same as the old inline autocompleted suggestion. | |
1996 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," | |
1997 "{\"google:verbatimrelevance\":1300," | |
1998 "\"google:suggestrelevance\":[1302, 1301]}]", | |
1999 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," | |
2000 "{\"google:verbatimrelevance\":1300," | |
2001 "\"google:suggestrelevance\":[1302, 1301]}]", | |
2002 { { "ab1", true }, { "ab2", false }, { "ab", true }, kEmptyMatch } }, | |
2003 // Ditto, just for a navigation suggestion. | |
2004 { "[\"a\",[\"ab1.com\", \"ab2.com\"],[],[]," | |
2005 "{\"google:verbatimrelevance\":1300," | |
2006 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | |
2007 "\"google:suggestrelevance\":[1302, 1301]}]", | |
2008 "[\"ab\",[\"ab1.com\", \"ab2.com\"],[],[]," | |
2009 "{\"google:verbatimrelevance\":1300," | |
2010 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | |
2011 "\"google:suggestrelevance\":[1302, 1301]}]", | |
2012 { { "ab1.com", true }, { "ab2.com", false }, { "ab", true }, | |
2013 kEmptyMatch } }, | |
2014 // A more realistic test of the same situation. | |
2015 { "[\"a\",[\"abcdef\", \"abcdef.com\", \"abc\"],[],[]," | |
2016 "{\"google:verbatimrelevance\":900," | |
2017 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\", \"QUERY\"]," | |
2018 "\"google:suggestrelevance\":[1250, 1200, 1000]}]", | |
2019 "[\"ab\",[\"abcdef\", \"abcdef.com\", \"abc\"],[],[]," | |
2020 "{\"google:verbatimrelevance\":900," | |
2021 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\", \"QUERY\"]," | |
2022 "\"google:suggestrelevance\":[1250, 1200, 1000]}]", | |
2023 { { "abcdef", true }, { "abcdef.com", false }, { "abc", false }, | |
2024 { "ab", true } } }, | |
2025 | |
2026 // Without an original inline autcompletion, a new inline autcompletion | |
2027 // should be rejected. | |
2028 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," | |
2029 "{\"google:verbatimrelevance\":1300," | |
2030 "\"google:suggestrelevance\":[900, 800]}]", | |
2031 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," | |
2032 "{\"google:suggestrelevance\":[1302, 1301]," | |
2033 "\"google:verbatimrelevance\":1300}]", | |
2034 { { "ab", true }, { "ab1", false }, { "ab2", false }, kEmptyMatch } }, | |
2035 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," | |
2036 "{\"google:verbatimrelevance\":1300," | |
2037 "\"google:suggestrelevance\":[900, 800]}]", | |
2038 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," | |
2039 "{\"google:verbatimrelevance\":1300," | |
2040 "\"google:suggestrelevance\":[1301, 1302]}]", | |
2041 { { "ab", true }, { "ab2", false }, { "ab1", false }, kEmptyMatch } }, | |
2042 // Now, the same verifications but with the new inline autocompletion as a | |
2043 // navsuggestion. The new autocompletion should still be rejected. | |
2044 { "[\"a\",[\"ab1.com\", \"ab2.com\"],[],[]," | |
2045 "{\"google:verbatimrelevance\":1300," | |
2046 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | |
2047 "\"google:suggestrelevance\":[900, 800]}]", | |
2048 "[\"ab\",[\"ab1.com\", \"ab2.com\"],[],[]," | |
2049 "{\"google:verbatimrelevance\":1300," | |
2050 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | |
2051 "\"google:suggestrelevance\":[1302, 1301]}]", | |
2052 { { "ab", true }, { "ab1.com", false }, { "ab2.com", false }, | |
2053 kEmptyMatch } }, | |
2054 { "[\"a\",[\"ab1.com\", \"ab2.com\"],[],[]," | |
2055 "{\"google:verbatimrelevance\":1300," | |
2056 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | |
2057 "\"google:suggestrelevance\":[900, 800]}]", | |
2058 "[\"ab\",[\"ab1.com\", \"ab2.com\"],[],[]," | |
2059 "{\"google:verbatimrelevance\":1300," | |
2060 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | |
2061 "\"google:suggestrelevance\":[1301, 1302]}]", | |
2062 { { "ab", true }, { "ab2.com", false }, { "ab1.com", false }, | |
2063 kEmptyMatch } }, | |
2064 }; | |
2065 | |
2066 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | |
2067 // First, send the query "a" and receive the provided JSON reply, | |
2068 // |first_json|. | |
2069 QueryForInput(ASCIIToUTF16("a"), false, false); | |
2070 net::TestURLFetcher* first_fetcher = | |
2071 test_factory_.GetFetcherByID( | |
2072 SearchProvider::kDefaultProviderURLFetcherID); | |
2073 ASSERT_TRUE(first_fetcher); | |
2074 first_fetcher->set_response_code(200); | |
2075 first_fetcher->SetResponseString(cases[i].first_json); | |
2076 first_fetcher->delegate()->OnURLFetchComplete(first_fetcher); | |
2077 RunTillProviderDone(); | |
2078 | |
2079 // Then, send the query "ab" and get the provided JSON reply, | |
2080 // |second_json|. | |
2081 QueryForInput(ASCIIToUTF16("ab"), false, false); | |
2082 net::TestURLFetcher* second_fetcher = | |
2083 test_factory_.GetFetcherByID( | |
2084 SearchProvider::kDefaultProviderURLFetcherID); | |
2085 ASSERT_TRUE(second_fetcher); | |
2086 second_fetcher->set_response_code(200); | |
2087 second_fetcher->SetResponseString(cases[i].second_json); | |
2088 second_fetcher->delegate()->OnURLFetchComplete(second_fetcher); | |
2089 RunTillProviderDone(); | |
2090 | |
2091 // Finally, check that we have the expected results. | |
2092 const std::string description = "for input with first_json=" + | |
2093 cases[i].first_json + " and second_json=" + cases[i].second_json; | |
2094 const ACMatches& matches = provider_->matches(); | |
2095 ASSERT_FALSE(matches.empty()); | |
2096 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | |
2097 size_t j = 0; | |
2098 // Ensure that the returned matches equal the expectations. | |
2099 for (; j < matches.size(); ++j) { | |
2100 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), | |
2101 matches[j].contents) << description; | |
2102 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, | |
2103 matches[j].allowed_to_be_default_match) << description; | |
2104 } | |
2105 // Ensure that no expected matches are missing. | |
2106 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) | |
2107 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << | |
2108 "Case # " << j << " " << description; | |
2109 } | |
2110 } | |
2111 | |
2112 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { | 1965 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { |
2113 // We hardcode the string "term1" below, so ensure that the search term that | 1966 // We hardcode the string "term1" below, so ensure that the search term that |
2114 // got added to history already is that string. | 1967 // got added to history already is that string. |
2115 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); | 1968 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); |
2116 base::string16 term = term1_.substr(0, term1_.length() - 1); | 1969 base::string16 term = term1_.substr(0, term1_.length() - 1); |
2117 | 1970 |
2118 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); | 1971 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); |
2119 profile_.BlockUntilHistoryProcessesPendingRequests(); | 1972 profile_.BlockUntilHistoryProcessesPendingRequests(); |
2120 | 1973 |
2121 struct { | 1974 struct { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 AutocompleteMatch::Type match_type; | 2058 AutocompleteMatch::Type match_type; |
2206 bool allowed_to_be_default_match; | 2059 bool allowed_to_be_default_match; |
2207 }; | 2060 }; |
2208 const DefaultFetcherUrlInputMatch kEmptyMatch = | 2061 const DefaultFetcherUrlInputMatch kEmptyMatch = |
2209 { kNotApplicable, AutocompleteMatchType::NUM_TYPES, false }; | 2062 { kNotApplicable, AutocompleteMatchType::NUM_TYPES, false }; |
2210 struct { | 2063 struct { |
2211 const std::string input; | 2064 const std::string input; |
2212 const std::string json; | 2065 const std::string json; |
2213 const DefaultFetcherUrlInputMatch output[4]; | 2066 const DefaultFetcherUrlInputMatch output[4]; |
2214 } cases[] = { | 2067 } cases[] = { |
2215 // Ensure NAVIGATION matches are allowed to be listed first for URL input. | 2068 // Ensure NAVIGATION matches are allowed to be listed first for URL |
2216 // Non-inlineable matches should not be allowed to be the default match. | 2069 // input regardless of whether the match is inlineable. Note that |
2217 // Note that the top-scoring inlineable match is moved to the top | 2070 // non-inlineable matches should not be allowed to be the default match. |
2218 // regardless of its score. | |
2219 { "a.com", "[\"a.com\",[\"http://b.com/\"],[],[]," | 2071 { "a.com", "[\"a.com\",[\"http://b.com/\"],[],[]," |
2220 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2072 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2221 "\"google:suggestrelevance\":[9999]}]", | 2073 "\"google:suggestrelevance\":[9999]}]", |
2222 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2074 { { "b.com", AutocompleteMatchType::NAVSUGGEST, false }, |
2223 { "b.com", AutocompleteMatchType::NAVSUGGEST, false }, | 2075 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2224 kEmptyMatch, kEmptyMatch } }, | 2076 kEmptyMatch, kEmptyMatch } }, |
2225 { "a.com", "[\"a.com\",[\"https://b.com\"],[],[]," | 2077 { "a.com", "[\"a.com\",[\"https://b.com\"],[],[]," |
2226 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2078 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2227 "\"google:suggestrelevance\":[9999]}]", | 2079 "\"google:suggestrelevance\":[9999]}]", |
2228 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2080 { { "https://b.com", AutocompleteMatchType::NAVSUGGEST, false }, |
2229 { "https://b.com", AutocompleteMatchType::NAVSUGGEST, false }, | 2081 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2230 kEmptyMatch, kEmptyMatch } }, | 2082 kEmptyMatch, kEmptyMatch } }, |
2231 { "a.com", "[\"a.com\",[\"http://a.com/a\"],[],[]," | 2083 { "a.com", "[\"a.com\",[\"http://a.com/a\"],[],[]," |
2232 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2084 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2233 "\"google:suggestrelevance\":[9999]}]", | 2085 "\"google:suggestrelevance\":[9999]}]", |
2234 { { "a.com/a", AutocompleteMatchType::NAVSUGGEST, true }, | 2086 { { "a.com/a", AutocompleteMatchType::NAVSUGGEST, true }, |
2235 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2087 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2236 kEmptyMatch, kEmptyMatch } }, | 2088 kEmptyMatch, kEmptyMatch } }, |
2237 { "a.com", "[\"a.com\",[\"https://a.com\"],[],[]," | 2089 { "a.com", "[\"a.com\",[\"https://a.com\"],[],[]," |
2238 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2090 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2239 "\"google:suggestrelevance\":[9999]}]", | 2091 "\"google:suggestrelevance\":[9999]}]", |
2240 { { "https://a.com", AutocompleteMatchType::NAVSUGGEST, true }, | 2092 { { "https://a.com", AutocompleteMatchType::NAVSUGGEST, true }, |
2241 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2093 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2242 kEmptyMatch, kEmptyMatch } }, | 2094 kEmptyMatch, kEmptyMatch } }, |
2243 | 2095 |
2244 // Ensure topmost inlineable SUGGEST matches are NOT allowed for URL | 2096 // Ensure topmost inlineable SUGGEST matches are NOT allowed for URL |
2245 // input. SearchProvider disregards search and verbatim suggested | 2097 // input. SearchProvider disregards search and verbatim suggested |
2246 // relevances. | 2098 // relevances. |
2247 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," | 2099 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," |
2248 "{\"google:suggestrelevance\":[9999]}]", | 2100 "{\"google:suggestrelevance\":[9999]}]", |
2249 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2101 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2250 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2102 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, |
2251 kEmptyMatch, kEmptyMatch } }, | 2103 kEmptyMatch, kEmptyMatch } }, |
2252 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," | 2104 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," |
2253 "{\"google:suggestrelevance\":[9999]}]", | 2105 "{\"google:suggestrelevance\":[9999]}]", |
2254 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2106 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2255 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2107 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, |
2256 kEmptyMatch, kEmptyMatch } }, | 2108 kEmptyMatch, kEmptyMatch } }, |
2257 | 2109 |
2258 // Ensure the fallback mechanism allows inlinable NAVIGATION matches. | 2110 // Ensure the fallback mechanism allows inlinable NAVIGATION matches. |
2259 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," | 2111 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," |
2260 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," | 2112 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," |
2261 "\"google:suggestrelevance\":[9999, 9998]}]", | 2113 "\"google:suggestrelevance\":[9999, 9998]}]", |
2262 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, | 2114 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, |
2263 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2115 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2264 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2116 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, |
2265 kEmptyMatch } }, | 2117 kEmptyMatch } }, |
2266 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," | 2118 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," |
2267 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," | 2119 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," |
2268 "\"google:suggestrelevance\":[9998, 9997]," | 2120 "\"google:suggestrelevance\":[9998, 9997]," |
2269 "\"google:verbatimrelevance\":9999}]", | 2121 "\"google:verbatimrelevance\":9999}]", |
2270 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, | 2122 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, |
2271 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2123 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2272 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2124 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, |
2273 kEmptyMatch } }, | 2125 kEmptyMatch } }, |
2274 | 2126 |
2275 // Ensure non-inlineable SUGGEST matches are allowed for URL input | 2127 // Ensure topmost non-inlineable SUGGEST matches are allowed for URL |
2276 // assuming the best inlineable match is not a query (i.e., is a | 2128 // input assuming the top inlineable match is not a query (i.e., is a |
2277 // NAVSUGGEST). The best inlineable match will be at the top of the | 2129 // NAVSUGGEST). |
2278 // list regardless of its score. | |
2279 { "a.com", "[\"a.com\",[\"info\"],[],[]," | 2130 { "a.com", "[\"a.com\",[\"info\"],[],[]," |
2280 "{\"google:suggestrelevance\":[9999]}]", | 2131 "{\"google:suggestrelevance\":[9999]}]", |
2281 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2132 { { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
2282 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2133 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2283 kEmptyMatch, kEmptyMatch } }, | 2134 kEmptyMatch, kEmptyMatch } }, |
2284 { "a.com", "[\"a.com\",[\"info\"],[],[]," | 2135 { "a.com", "[\"a.com\",[\"info\"],[],[]," |
2285 "{\"google:suggestrelevance\":[9999]}]", | 2136 "{\"google:suggestrelevance\":[9999]}]", |
2286 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2137 { { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
2287 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2138 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2288 kEmptyMatch, kEmptyMatch } }, | 2139 kEmptyMatch, kEmptyMatch } }, |
2289 }; | 2140 }; |
2290 | 2141 |
2291 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2142 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
2292 // Send the query twice in order to bypass checks about whether a single | 2143 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); |
2293 // new reply can change the inline autocompletion. | 2144 net::TestURLFetcher* fetcher = |
2294 for (size_t j = 0; j < 2; j++) { | 2145 test_factory_.GetFetcherByID( |
2295 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); | 2146 SearchProvider::kDefaultProviderURLFetcherID); |
2296 net::TestURLFetcher* fetcher = | 2147 ASSERT_TRUE(fetcher); |
2297 test_factory_.GetFetcherByID( | 2148 fetcher->set_response_code(200); |
2298 SearchProvider::kDefaultProviderURLFetcherID); | 2149 fetcher->SetResponseString(cases[i].json); |
2299 ASSERT_TRUE(fetcher); | 2150 fetcher->delegate()->OnURLFetchComplete(fetcher); |
2300 fetcher->set_response_code(200); | 2151 RunTillProviderDone(); |
2301 fetcher->SetResponseString(cases[i].json); | |
2302 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
2303 RunTillProviderDone(); | |
2304 } | |
2305 | 2152 |
2306 const std::string description = "input=" + cases[i].input + " json=" + | |
2307 cases[i].json; | |
2308 size_t j = 0; | 2153 size_t j = 0; |
2309 const ACMatches& matches = provider_->matches(); | 2154 const ACMatches& matches = provider_->matches(); |
2310 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].output)) << | 2155 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].output)); |
2311 description; | |
2312 // Ensure that the returned matches equal the expectations. | 2156 // Ensure that the returned matches equal the expectations. |
2313 for (; j < matches.size(); ++j) { | 2157 for (; j < matches.size(); ++j) { |
2314 EXPECT_EQ(ASCIIToUTF16(cases[i].output[j].match_contents), | 2158 EXPECT_EQ(ASCIIToUTF16(cases[i].output[j].match_contents), |
2315 matches[j].contents) << description; | 2159 matches[j].contents); |
2316 EXPECT_EQ(cases[i].output[j].match_type, matches[j].type) << description; | 2160 EXPECT_EQ(cases[i].output[j].match_type, matches[j].type); |
2317 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, | 2161 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, |
2318 matches[j].allowed_to_be_default_match) << description; | 2162 matches[j].allowed_to_be_default_match); |
2319 } | 2163 } |
2320 // Ensure that no expected matches are missing. | 2164 // Ensure that no expected matches are missing. |
2321 for (; j < ARRAYSIZE_UNSAFE(cases[i].output); ++j) { | 2165 for (; j < ARRAYSIZE_UNSAFE(cases[i].output); ++j) { |
2322 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents) << | 2166 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents); |
2323 description; | |
2324 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, | 2167 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, |
2325 cases[i].output[j].match_type) << description; | 2168 cases[i].output[j].match_type); |
2326 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match) << | 2169 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match); |
2327 description; | |
2328 } | 2170 } |
2329 } | 2171 } |
2330 } | 2172 } |
2331 | 2173 |
2332 // A basic test that verifies the field trial triggered parsing logic. | 2174 // A basic test that verifies the field trial triggered parsing logic. |
2333 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { | 2175 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { |
2334 QueryForInput(ASCIIToUTF16("foo"), false, false); | 2176 QueryForInput(ASCIIToUTF16("foo"), false, false); |
2335 | 2177 |
2336 // Make sure the default providers suggest service was queried. | 2178 // Make sure the default providers suggest service was queried. |
2337 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | 2179 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 "?www.abc.com", "c.com", true, false }, | 2372 "?www.abc.com", "c.com", true, false }, |
2531 { "?ab", "http://www.abc.com", | 2373 { "?ab", "http://www.abc.com", |
2532 "?www.abc.com", "c.com", true, false }, | 2374 "?www.abc.com", "c.com", true, false }, |
2533 { "?abc.com", "http://www.abc.com", | 2375 { "?abc.com", "http://www.abc.com", |
2534 "?www.abc.com", "", true, true }, | 2376 "?www.abc.com", "", true, true }, |
2535 }; | 2377 }; |
2536 | 2378 |
2537 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2379 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
2538 // First test regular mode. | 2380 // First test regular mode. |
2539 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); | 2381 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); |
2540 SearchSuggestionParser::NavigationResult result( | 2382 AutocompleteMatch match( |
2541 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), | 2383 provider_->NavigationToMatch(SearchSuggestionParser::NavigationResult( |
2542 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), | 2384 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), |
2543 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()); | 2385 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), |
2544 result.set_received_after_last_keystroke(false); | 2386 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()))); |
2545 AutocompleteMatch match(provider_->NavigationToMatch(result)); | |
2546 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 2387 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
2547 match.inline_autocompletion); | 2388 match.inline_autocompletion); |
2548 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); | 2389 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); |
2549 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode, | 2390 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode, |
2550 match.allowed_to_be_default_match); | 2391 match.allowed_to_be_default_match); |
2551 | 2392 |
2552 // Then test prevent-inline-autocomplete mode. | 2393 // Then test prevent-inline-autocomplete mode. |
2553 QueryForInput(ASCIIToUTF16(cases[i].input), true, false); | 2394 QueryForInput(ASCIIToUTF16(cases[i].input), true, false); |
2554 SearchSuggestionParser::NavigationResult result_prevent_inline( | |
2555 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), | |
2556 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), | |
2557 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()); | |
2558 result_prevent_inline.set_received_after_last_keystroke(false); | |
2559 AutocompleteMatch match_prevent_inline( | 2395 AutocompleteMatch match_prevent_inline( |
2560 provider_->NavigationToMatch(result_prevent_inline)); | 2396 provider_->NavigationToMatch(SearchSuggestionParser::NavigationResult( |
| 2397 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), |
| 2398 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), |
| 2399 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()))); |
2561 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 2400 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
2562 match_prevent_inline.inline_autocompletion); | 2401 match_prevent_inline.inline_autocompletion); |
2563 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), | 2402 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), |
2564 match_prevent_inline.fill_into_edit); | 2403 match_prevent_inline.fill_into_edit); |
2565 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode, | 2404 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode, |
2566 match_prevent_inline.allowed_to_be_default_match); | 2405 match_prevent_inline.allowed_to_be_default_match); |
2567 } | 2406 } |
2568 } | 2407 } |
2569 | 2408 |
2570 // Verifies that "http://" is not trimmed for input that is a leading substring. | 2409 // Verifies that "http://" is not trimmed for input that is a leading substring. |
2571 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { | 2410 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { |
2572 const base::string16 input(ASCIIToUTF16("ht")); | 2411 const base::string16 input(ASCIIToUTF16("ht")); |
2573 const base::string16 url(ASCIIToUTF16("http://a.com")); | 2412 const base::string16 url(ASCIIToUTF16("http://a.com")); |
2574 SearchSuggestionParser::NavigationResult result( | 2413 const SearchSuggestionParser::NavigationResult result( |
2575 ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), | 2414 ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), |
2576 AutocompleteMatchType::NAVSUGGEST, | 2415 AutocompleteMatchType::NAVSUGGEST, |
2577 base::string16(), std::string(), false, 0, false, input, std::string()); | 2416 base::string16(), std::string(), false, 0, false, input, std::string()); |
2578 result.set_received_after_last_keystroke(false); | |
2579 | 2417 |
2580 // Check the offset and strings when inline autocompletion is allowed. | 2418 // Check the offset and strings when inline autocompletion is allowed. |
2581 QueryForInput(input, false, false); | 2419 QueryForInput(input, false, false); |
2582 AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); | 2420 AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); |
2583 EXPECT_EQ(url, match_inline.fill_into_edit); | 2421 EXPECT_EQ(url, match_inline.fill_into_edit); |
2584 EXPECT_EQ(url.substr(2), match_inline.inline_autocompletion); | 2422 EXPECT_EQ(url.substr(2), match_inline.inline_autocompletion); |
2585 EXPECT_TRUE(match_inline.allowed_to_be_default_match); | 2423 EXPECT_TRUE(match_inline.allowed_to_be_default_match); |
2586 EXPECT_EQ(url, match_inline.contents); | 2424 EXPECT_EQ(url, match_inline.contents); |
2587 | 2425 |
2588 // Check the same strings when inline autocompletion is prevented. | 2426 // Check the same strings when inline autocompletion is prevented. |
2589 QueryForInput(input, true, false); | 2427 QueryForInput(input, true, false); |
2590 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); | 2428 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); |
2591 EXPECT_EQ(url, match_prevent.fill_into_edit); | 2429 EXPECT_EQ(url, match_prevent.fill_into_edit); |
2592 EXPECT_FALSE(match_prevent.allowed_to_be_default_match); | 2430 EXPECT_FALSE(match_prevent.allowed_to_be_default_match); |
2593 EXPECT_EQ(url, match_prevent.contents); | 2431 EXPECT_EQ(url, match_prevent.contents); |
2594 } | 2432 } |
2595 | 2433 |
2596 // Verifies that input "w" marks a more significant domain label than "www.". | 2434 // Verifies that input "w" marks a more significant domain label than "www.". |
2597 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { | 2435 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { |
2598 QueryForInput(ASCIIToUTF16("w"), false, false); | 2436 QueryForInput(ASCIIToUTF16("w"), false, false); |
2599 SearchSuggestionParser::NavigationResult result( | 2437 AutocompleteMatch match( |
2600 ChromeAutocompleteSchemeClassifier(&profile_), | 2438 provider_->NavigationToMatch(SearchSuggestionParser::NavigationResult( |
2601 GURL("http://www.wow.com"), AutocompleteMatchType::NAVSUGGEST, | 2439 ChromeAutocompleteSchemeClassifier(&profile_), |
2602 base::string16(), std::string(), false, 0, false, ASCIIToUTF16("w"), | 2440 GURL("http://www.wow.com"), |
2603 std::string()); | 2441 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), |
2604 result.set_received_after_last_keystroke(false); | 2442 false, 0, false, ASCIIToUTF16("w"), std::string()))); |
2605 AutocompleteMatch match(provider_->NavigationToMatch(result)); | |
2606 EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion); | 2443 EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion); |
2607 EXPECT_TRUE(match.allowed_to_be_default_match); | 2444 EXPECT_TRUE(match.allowed_to_be_default_match); |
2608 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit); | 2445 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit); |
2609 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents); | 2446 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents); |
2610 | 2447 |
2611 // Ensure that the match for input "w" is marked on "wow" and not "www". | 2448 // Ensure that the match for input "w" is marked on "wow" and not "www". |
2612 ASSERT_EQ(3U, match.contents_class.size()); | 2449 ASSERT_EQ(3U, match.contents_class.size()); |
2613 EXPECT_EQ(0U, match.contents_class[0].offset); | 2450 EXPECT_EQ(0U, match.contents_class[0].offset); |
2614 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 2451 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
2615 match.contents_class[0].style); | 2452 match.contents_class[0].style); |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3431 // Mismatching input will return empty prefetch data. | 3268 // Mismatching input will return empty prefetch data. |
3432 AutocompleteInput input2(base::ASCIIToUTF16("weather n"), | 3269 AutocompleteInput input2(base::ASCIIToUTF16("weather n"), |
3433 base::string16::npos, base::string16(), GURL(), | 3270 base::string16::npos, base::string16(), GURL(), |
3434 metrics::OmniboxEventProto::INVALID_SPEC, false, | 3271 metrics::OmniboxEventProto::INVALID_SPEC, false, |
3435 false, true, true, | 3272 false, true, true, |
3436 ChromeAutocompleteSchemeClassifier(&profile_)); | 3273 ChromeAutocompleteSchemeClassifier(&profile_)); |
3437 provider_->DoAnswersQuery(input2); | 3274 provider_->DoAnswersQuery(input2); |
3438 EXPECT_TRUE(provider_->prefetch_data_.full_query_text.empty()); | 3275 EXPECT_TRUE(provider_->prefetch_data_.full_query_text.empty()); |
3439 EXPECT_TRUE(provider_->prefetch_data_.query_type.empty()); | 3276 EXPECT_TRUE(provider_->prefetch_data_.query_type.empty()); |
3440 } | 3277 } |
OLD | NEW |