Index: chrome/browser/autocomplete/search_provider_unittest.cc |
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc |
index 63270764cda23230ac0e17e58692534840630e2e..d2146fd80b55a8fc07a29cb4a2e412348bf6836d 100644 |
--- a/chrome/browser/autocomplete/search_provider_unittest.cc |
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc |
@@ -61,18 +61,22 @@ class SearchProviderTest : public testing::Test, |
public AutocompleteProviderListener { |
public: |
struct ResultInfo { |
- ResultInfo() : result_type(AutocompleteMatchType::NUM_TYPES) { |
+ ResultInfo() : result_type(AutocompleteMatchType::NUM_TYPES), |
+ allowed_to_be_default_match(false) { |
} |
ResultInfo(GURL gurl, |
AutocompleteMatch::Type result_type, |
+ bool allowed_to_be_default_match, |
string16 fill_into_edit) |
: gurl(gurl), |
result_type(result_type), |
+ allowed_to_be_default_match(allowed_to_be_default_match), |
fill_into_edit(fill_into_edit) { |
} |
const GURL gurl; |
const AutocompleteMatch::Type result_type; |
+ const bool allowed_to_be_default_match; |
const string16 fill_into_edit; |
}; |
@@ -268,7 +272,8 @@ void SearchProviderTest::RunTest(TestData* cases, |
diagnostic_details; |
// All callers that use this helper function at the moment produce |
// matches that are always allowed to be the default match. |
- EXPECT_TRUE(matches[j].allowed_to_be_default_match); |
+ EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, |
+ matches[j].allowed_to_be_default_match) << diagnostic_details; |
} |
} |
} |
@@ -833,7 +838,7 @@ TEST_F(SearchProviderTest, KeywordOrderingAndDescriptions) { |
EXPECT_GT(result.match_at(1).relevance, result.match_at(2).relevance); |
EXPECT_TRUE(result.match_at(0).allowed_to_be_default_match); |
EXPECT_TRUE(result.match_at(1).allowed_to_be_default_match); |
- EXPECT_TRUE(result.match_at(2).allowed_to_be_default_match); |
+ EXPECT_FALSE(result.match_at(2).allowed_to_be_default_match); |
// The two keyword results should come with the keyword we expect. |
EXPECT_EQ(ASCIIToUTF16("k"), result.match_at(0).keyword); |
@@ -858,9 +863,11 @@ TEST_F(SearchProviderTest, KeywordVerbatim) { |
{ ASCIIToUTF16("k foo"), 2, |
{ ResultInfo(GURL("http://keyword/foo"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k foo")), |
ResultInfo(GURL("http://defaultturl/k%20foo"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("k foo") ) } }, |
// Make sure extra whitespace after the keyword doesn't change the |
@@ -868,9 +875,11 @@ TEST_F(SearchProviderTest, KeywordVerbatim) { |
{ ASCIIToUTF16("k foo"), 2, |
{ ResultInfo(GURL("http://keyword/foo"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k foo")), |
ResultInfo(GURL("http://defaultturl/k%20%20%20foo"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("k foo")) } }, |
// Leading whitespace should be stripped before SearchProvider gets the |
// input; hence there are no tests here about how it handles those inputs. |
@@ -880,9 +889,11 @@ TEST_F(SearchProviderTest, KeywordVerbatim) { |
{ ASCIIToUTF16("k foo bar"), 2, |
{ ResultInfo(GURL("http://keyword/foo%20%20bar"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k foo bar")), |
ResultInfo(GURL("http://defaultturl/k%20%20foo%20%20bar"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("k foo bar")) } }, |
// Note in the above test case we don't test trailing whitespace because |
// SearchProvider still doesn't handle this well. See related bugs: |
@@ -893,23 +904,29 @@ TEST_F(SearchProviderTest, KeywordVerbatim) { |
{ ASCIIToUTF16("www.k foo"), 2, |
{ ResultInfo(GURL("http://keyword/foo"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k foo")), |
ResultInfo(GURL("http://defaultturl/www.k%20foo"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("www.k foo")) } }, |
{ ASCIIToUTF16("http://k foo"), 2, |
{ ResultInfo(GURL("http://keyword/foo"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k foo")), |
ResultInfo(GURL("http://defaultturl/http%3A//k%20foo"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("http://k foo")) } }, |
{ ASCIIToUTF16("http://www.k foo"), 2, |
{ ResultInfo(GURL("http://keyword/foo"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k foo")), |
ResultInfo(GURL("http://defaultturl/http%3A//www.k%20foo"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("http://www.k foo")) } }, |
// A keyword with no remaining input shouldn't get a keyword |
@@ -917,10 +934,12 @@ TEST_F(SearchProviderTest, KeywordVerbatim) { |
{ ASCIIToUTF16("k"), 1, |
{ ResultInfo(GURL("http://defaultturl/k"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ true, |
ASCIIToUTF16("k")) } }, |
{ ASCIIToUTF16("k "), 1, |
{ ResultInfo(GURL("http://defaultturl/k%20"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ true, |
ASCIIToUTF16("k ")) } } |
// The fact that verbatim queries to keyword are handled by KeywordProvider |
@@ -958,9 +977,11 @@ TEST_F(SearchProviderTest, CommandLineOverrides) { |
{ ASCIIToUTF16("k a"), 2, |
{ ResultInfo(GURL("http://keyword/a"), |
AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
+ true, |
ASCIIToUTF16("k a")), |
ResultInfo(GURL("http://www.bar.com/k%20a?a=b"), |
AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
+ false, |
ASCIIToUTF16("k a")) } }, |
}; |
@@ -1604,10 +1625,15 @@ TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { |
const std::string description = "for input with json=" + cases[i].json; |
const ACMatches& matches = provider_->matches(); |
- // The top match must inline and score as highly as calculated verbatim. |
ASSERT_FALSE(matches.empty()); |
+ // Find the first match that's allowed to be the default match and check |
+ // its inline_autocompletion. |
+ ACMatches::const_iterator it = matches.begin(); |
+ while ((it != matches.end()) && !it->allowed_to_be_default_match) |
+ ++it; |
+ ASSERT_NE(matches.end(), it); |
EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
- matches[0].inline_autocompletion) << description; |
+ it->inline_autocompletion) << description; |
ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
size_t j = 0; |
@@ -1650,7 +1676,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
// the default provider verbatim. |
{ "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "c", true, false }, |
{ "b", true, false }, |
kEmptyMatch, kEmptyMatch }, |
@@ -1658,12 +1684,9 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
// Again, check that relevance scores reorder matches, just this |
// time with navigation matches. This also checks that with |
// suggested relevance scores we allow multiple navsuggest results. |
- // It's odd that navsuggest results that come from a keyword |
- // provider are marked as not a keyword result. I think this |
- // comes from them not going to a keyword search engine). |
- // TODO(mpearson): Investigate the implications (if any) of |
- // tagging these results appropriately. If so, do it because it |
- // makes more sense. |
+ // Note that navsuggest results that come from a keyword provider |
+ // are marked as not a keyword result. (They don't go to a |
+ // keyword search engine.) |
{ "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:suggestrelevance\":[1301, 1302, 1303]}]", |
@@ -1671,7 +1694,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ "d", true, false }, |
{ "c.com", false, false }, |
{ "b.com", false, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
std::string() }, |
@@ -1681,7 +1704,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
{ { "a", true, true }, |
{ "b.com", false, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -1691,27 +1714,27 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:suggestrelevance\":[9998]}]", |
{ { "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a1", true, true }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a1", true, true }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"http://a.com\"],[],[]," |
@@ -1719,8 +1742,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9999," |
"\"google:suggestrelevance\":[9998]}]", |
{ { "a", true, true }, |
- { "a.com", false, true }, |
- { "k a", false, true }, |
+ { "a.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -1730,7 +1753,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ { "a1", true, true }, |
{ "a", true, true }, |
{ "a2", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"1" }, |
@@ -1739,14 +1762,14 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
{ { "a", true, true }, |
{ "b", true, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
"\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
{ "b", true, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://b.com\"],[],[]," |
@@ -1754,7 +1777,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a", true, true }, |
{ "b.com", false, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://b.com\"],[],[]," |
@@ -1763,7 +1786,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
{ "b.com", false, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -1774,13 +1797,13 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
{ { "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// Continuing the same category of tests, but make sure we keep the |
@@ -1789,14 +1812,14 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
"\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "a1", true, true }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
"\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "a2", true, true }, |
{ "a1", true, true }, |
kEmptyMatch, kEmptyMatch }, |
@@ -1804,7 +1827,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
"\"google:verbatimrelevance\":2}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "a2", true, true }, |
{ "a1", true, true }, |
kEmptyMatch, kEmptyMatch }, |
@@ -1814,7 +1837,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
"{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "h", true, false }, |
{ "g", true, false }, |
{ "f", true, false }, |
@@ -1829,7 +1852,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "h.com", false, false }, |
{ "g.com", false, false }, |
{ "f.com", false, false }, |
@@ -1843,13 +1866,13 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ { "a", true, true }, |
{ "a1", true, true }, |
{ "a2", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
{ { "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// In this case, ignoring the suggested relevance scores means we keep |
@@ -1858,16 +1881,16 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
"\"google:suggestrelevance\":[1]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[9999, 1]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -1877,7 +1900,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ { "a2", true, true }, |
{ "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"2" }, |
{ "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
@@ -1886,7 +1909,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
{ { "a2", true, true }, |
{ "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"2" }, |
@@ -1895,12 +1918,12 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
// (except when suggested relevances are ignored). |
{ "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -1914,9 +1937,9 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9999]}]", |
{ { "a", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
@@ -1924,17 +1947,17 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9999, 9998]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"https://a/\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[9999]}]", |
- { { "a", true, true }, |
- { "https://a", false, true }, |
- { "k a", false, true }, |
+ { { "a", true, true }, |
+ { "https://a", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// Check when navsuggest scores more than verbatim and there is query |
@@ -1944,10 +1967,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
{ { "a", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
+ { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
{ "a3", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
@@ -1955,10 +1978,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
+ { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
{ "a3", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
std::string() }, |
// Check when navsuggest scores more than a query suggestion. There is |
@@ -1968,10 +1991,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
{ { "a3", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
+ { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
@@ -1979,10 +2002,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
{ { "a3", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
+ { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
@@ -1990,9 +2013,9 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
{ { "a3", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
@@ -2000,9 +2023,9 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
{ { "a3", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"3" }, |
// Check when there is neither verbatim nor a query suggestion that, |
@@ -2017,8 +2040,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9998, 9999]}]", |
{ { "a", true, true }, |
- { "a2.com", false, true }, |
- { "k a", false, true }, |
+ { "a2.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
@@ -2026,8 +2049,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9999, 9998]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// More checks that everything works when it's not necessary to demote. |
@@ -2036,10 +2059,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
{ { "a3", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
+ { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
@@ -2047,10 +2070,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
{ { "a3", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
+ { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
}; |
@@ -2127,7 +2150,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
// the default provider verbatim. |
{ "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "c", true, false }, |
{ "b", true, false }, |
kEmptyMatch, kEmptyMatch }, |
@@ -2135,12 +2158,9 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
// Again, check that relevance scores reorder matches, just this |
// time with navigation matches. This also checks that with |
// suggested relevance scores we allow multiple navsuggest results. |
- // It's odd that navsuggest results that come from a keyword |
- // provider are marked as not a keyword result. I think this |
- // comes from them not going to a keyword search engine. |
- // TODO(mpearson): Investigate the implications (if any) of |
- // tagging these results appropriately. If so, do it because it |
- // makes more sense. |
+ // Note that navsuggest results that come from a keyword provider |
+ // are marked as not a keyword result. (They don't go to a |
+ // keyword search engine.) |
{ "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:suggestrelevance\":[1301, 1302, 1303]}]", |
@@ -2148,7 +2168,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
{ "d", true, false }, |
{ "c.com", false, false }, |
{ "b.com", false, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
std::string() }, |
@@ -2158,7 +2178,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
{ { "a", true, true }, |
{ "b.com", false, false }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -2168,27 +2188,27 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"google:suggestrelevance\":[9998]}]", |
{ { "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a1", true, true }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "a1", true, true }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"http://a.com\"],[],[]," |
@@ -2196,8 +2216,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"google:verbatimrelevance\":9999," |
"\"google:suggestrelevance\":[9998]}]", |
{ { "a", true, true }, |
- { "a.com", false, true }, |
- { "k a", false, true }, |
+ { "a.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -2207,7 +2227,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
{ { "a1", true, true }, |
{ "a", true, true }, |
{ "a2", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"1" }, |
@@ -2216,30 +2236,34 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
{ "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
{ { "b", true, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
- { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
Mark P
2013/11/14 22:56:39
I moved this case below, to the "on the other hand
|
- "\"google:verbatimrelevance\":0}]", |
- { { "b", true, false }, |
- { "k a", false, true }, |
- kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
- std::string() }, |
{ "[\"a\",[\"http://b.com\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[9999]}]", |
{ { "b.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
+ kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
+ std::string() }, |
+ // On the other hand, if there is no inlineable match, abandon all |
+ // relevance scores (queries and navsuggestions). |
+ { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
+ "\"google:verbatimrelevance\":0}]", |
+ { { "a", true, true }, |
+ { "b", true, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://b.com\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[9999]," |
"\"google:verbatimrelevance\":0}]", |
- { { "b.com", false, false }, |
- { "k a", false, true }, |
- kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
+ { { "a", true, true }, |
+ { "b.com", false, false }, |
+ { "k a", false, false }, |
+ kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// The top result does not have to score as highly as calculated |
@@ -2247,43 +2271,43 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
// this provider. |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
{ { "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
{ { "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "a", true, true }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
"1" }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
"\"google:verbatimrelevance\":0}]", |
- { { "k a", false, true }, |
+ { { "k a", false, false }, |
{ "a1", true, true }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
- std::string() }, |
+ "1" }, |
{ "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
"\"google:verbatimrelevance\":0}]", |
{ |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "a2", true, true }, |
{ "a1", true, true }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
- std::string() }, |
+ "2" }, |
{ "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
"\"google:verbatimrelevance\":2}]", |
- { { "k a", false, true }, |
+ { { "k a", false, false }, |
{ "a2", true, true }, |
{ "a", true, true }, |
{ "a1", true, true }, |
kEmptyMatch, kEmptyMatch }, |
- std::string() }, |
+ "2" }, |
// Ensure that all suggestions are considered, regardless of order. |
{ "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
"{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "h", true, false }, |
{ "g", true, false }, |
{ "f", true, false }, |
@@ -2298,7 +2322,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
{ "h.com", false, false }, |
{ "g.com", false, false }, |
{ "f.com", false, false }, |
@@ -2312,13 +2336,13 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
{ { "a", true, true }, |
{ "a1", true, true }, |
{ "a2", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
{ { "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// In this case, ignoring the suggested relevance scores means we keep |
@@ -2327,16 +2351,16 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
"\"google:suggestrelevance\":[1]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[9999, 1]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
@@ -2346,7 +2370,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
{ { "a2", true, true }, |
{ "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"2" }, |
{ "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
@@ -2355,7 +2379,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
{ { "a2", true, true }, |
{ "a", true, true }, |
{ "a1", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"2" }, |
@@ -2363,47 +2387,45 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
// TODO(mpearson): Ensure the value of verbatimrelevance is respected |
// (except when suggested relevances are ignored). |
{ "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
- { { "k a", false, true }, |
+ { { "k a", false, false }, |
{ "a", true, true }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
{ { "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
- // Check that navsuggestions will be demoted below queries. |
- // (Navsuggestions are not allowed to appear first.) In the process, |
- // make sure the navsuggestions still remain in the same order. |
- // First, check the situation where navsuggest scores more than verbatim |
- // and there are no query suggestions. |
+ // In reorder mode, navsuggestions will not need to be demoted (because |
+ // they are marked as not allowed to be default match and will be |
+ // reordered as necessary). |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9999]}]", |
- { { "a", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
+ { "a", true, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9999, 9998]}]", |
- { { "a", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
- { "k a", false, true }, |
+ { { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
+ { "a", true, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"https://a/\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\"]," |
"\"google:suggestrelevance\":[9999]}]", |
- { { "a", true, true }, |
- { "https://a", false, true }, |
- { "k a", false, true }, |
+ { { "https://a", false, false }, |
+ { "a", true, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// Check when navsuggest scores more than verbatim and there is query |
@@ -2412,22 +2434,22 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
- { { "a", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
+ { { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
+ { "a", true, true }, |
{ "a3", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
- { { "a", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
+ { { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
+ { "a", true, true }, |
{ "a3", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
std::string() }, |
// Check when navsuggest scores more than a query suggestion. There is |
@@ -2436,42 +2458,42 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
- { { "a3", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
+ { { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
+ { "a3", true, true }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
- { { "a3", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
+ { { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
+ { "a3", true, true }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
- { { "a3", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
+ { "a3", true, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
"{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
- { { "a3", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
- { "k a", false, true }, |
+ { { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
+ { "a3", true, true }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch }, |
"3" }, |
// Check when there is neither verbatim nor a query suggestion that, |
@@ -2486,8 +2508,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9998, 9999]}]", |
{ { "a", true, true }, |
- { "a2.com", false, true }, |
- { "k a", false, true }, |
+ { "a2.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
@@ -2495,8 +2517,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"google:verbatimrelevance\":0," |
"\"google:suggestrelevance\":[9999, 9998]}]", |
{ { "a", true, true }, |
- { "a1.com", false, true }, |
- { "k a", false, true }, |
+ { "a1.com", false, false }, |
+ { "k a", false, false }, |
kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
std::string() }, |
// More checks that everything works when it's not necessary to demote. |
@@ -2505,10 +2527,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
{ { "a3", true, true }, |
- { "a2.com", false, true }, |
- { "a1.com", false, true }, |
+ { "a2.com", false, false }, |
+ { "a1.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
{ "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
@@ -2516,10 +2538,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
"\"google:verbatimrelevance\":9990," |
"\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
{ { "a3", true, true }, |
- { "a1.com", false, true }, |
- { "a2.com", false, true }, |
+ { "a1.com", false, false }, |
+ { "a2.com", false, false }, |
{ "a", true, true }, |
- { "k a", false, true }, |
+ { "k a", false, false }, |
kEmptyMatch }, |
"3" }, |
}; |
@@ -2557,10 +2579,15 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevanceWithReorder) { |
const std::string description = "for input with json=" + cases[i].json; |
const ACMatches& matches = provider_->matches(); |
- // The top match must inline and score as highly as calculated verbatim. |
ASSERT_FALSE(matches.empty()); |
+ // Find the first match that's allowed to be the default match and check |
+ // its inline_autocompletion. |
+ ACMatches::const_iterator it = matches.begin(); |
+ while ((it != matches.end()) && !it->allowed_to_be_default_match) |
+ ++it; |
+ ASSERT_NE(matches.end(), it); |
EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
- matches[0].inline_autocompletion) << description; |
+ it->inline_autocompletion) << description; |
ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
size_t j = 0; |