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