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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 // TemplateURL has a valid suggest and search URL. | 54 // TemplateURL has a valid suggest and search URL. |
55 // . The URL created by using the search term term1_ with default_t_url_ is | 55 // . The URL created by using the search term term1_ with default_t_url_ is |
56 // added to history. | 56 // added to history. |
57 // . The URL created by using the search term keyword_term_ with keyword_t_url_ | 57 // . The URL created by using the search term keyword_term_ with keyword_t_url_ |
58 // is added to history. | 58 // is added to history. |
59 // . test_factory_ is set as the URLFetcherFactory. | 59 // . test_factory_ is set as the URLFetcherFactory. |
60 class SearchProviderTest : public testing::Test, | 60 class SearchProviderTest : public testing::Test, |
61 public AutocompleteProviderListener { | 61 public AutocompleteProviderListener { |
62 public: | 62 public: |
63 struct ResultInfo { | 63 struct ResultInfo { |
64 ResultInfo() : result_type(AutocompleteMatchType::NUM_TYPES) { | 64 ResultInfo() : result_type(AutocompleteMatchType::NUM_TYPES), |
65 allowed_to_be_default_match(false) { | |
65 } | 66 } |
66 ResultInfo(GURL gurl, | 67 ResultInfo(GURL gurl, |
67 AutocompleteMatch::Type result_type, | 68 AutocompleteMatch::Type result_type, |
69 bool allowed_to_be_default_match, | |
68 string16 fill_into_edit) | 70 string16 fill_into_edit) |
69 : gurl(gurl), | 71 : gurl(gurl), |
70 result_type(result_type), | 72 result_type(result_type), |
73 allowed_to_be_default_match(allowed_to_be_default_match), | |
71 fill_into_edit(fill_into_edit) { | 74 fill_into_edit(fill_into_edit) { |
72 } | 75 } |
73 | 76 |
74 const GURL gurl; | 77 const GURL gurl; |
75 const AutocompleteMatch::Type result_type; | 78 const AutocompleteMatch::Type result_type; |
79 const bool allowed_to_be_default_match; | |
76 const string16 fill_into_edit; | 80 const string16 fill_into_edit; |
77 }; | 81 }; |
78 | 82 |
79 struct TestData { | 83 struct TestData { |
80 const string16 input; | 84 const string16 input; |
81 const size_t num_results; | 85 const size_t num_results; |
82 const ResultInfo output[3]; | 86 const ResultInfo output[3]; |
83 }; | 87 }; |
84 | 88 |
85 SearchProviderTest() | 89 SearchProviderTest() |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 EXPECT_EQ(cases[i].num_results, matches.size()) << diagnostic_details; | 263 EXPECT_EQ(cases[i].num_results, matches.size()) << diagnostic_details; |
260 if (matches.size() == cases[i].num_results) { | 264 if (matches.size() == cases[i].num_results) { |
261 for (size_t j = 0; j < cases[i].num_results; ++j) { | 265 for (size_t j = 0; j < cases[i].num_results; ++j) { |
262 EXPECT_EQ(cases[i].output[j].gurl, matches[j].destination_url) << | 266 EXPECT_EQ(cases[i].output[j].gurl, matches[j].destination_url) << |
263 diagnostic_details; | 267 diagnostic_details; |
264 EXPECT_EQ(cases[i].output[j].result_type, matches[j].type) << | 268 EXPECT_EQ(cases[i].output[j].result_type, matches[j].type) << |
265 diagnostic_details; | 269 diagnostic_details; |
266 EXPECT_EQ(cases[i].output[j].fill_into_edit, | 270 EXPECT_EQ(cases[i].output[j].fill_into_edit, |
267 matches[j].fill_into_edit) << | 271 matches[j].fill_into_edit) << |
268 diagnostic_details; | 272 diagnostic_details; |
269 // All callers that use this helper function at the moment produce | 273 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, |
270 // matches that are always allowed to be the default match. | 274 matches[j].allowed_to_be_default_match) << diagnostic_details; |
271 EXPECT_TRUE(matches[j].allowed_to_be_default_match); | |
272 } | 275 } |
273 } | 276 } |
274 } | 277 } |
275 } | 278 } |
276 | 279 |
277 void SearchProviderTest::OnProviderUpdate(bool updated_matches) { | 280 void SearchProviderTest::OnProviderUpdate(bool updated_matches) { |
278 if (run_loop_ && provider_->done()) { | 281 if (run_loop_ && provider_->done()) { |
279 run_loop_->Quit(); | 282 run_loop_->Quit(); |
280 run_loop_ = NULL; | 283 run_loop_ = NULL; |
281 } | 284 } |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 ASSERT_EQ(3u, result.size()); | 829 ASSERT_EQ(3u, result.size()); |
827 EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, result.match_at(0).type); | 830 EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, result.match_at(0).type); |
828 EXPECT_EQ(AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 831 EXPECT_EQ(AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
829 result.match_at(1).type); | 832 result.match_at(1).type); |
830 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 833 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
831 result.match_at(2).type); | 834 result.match_at(2).type); |
832 EXPECT_GT(result.match_at(0).relevance, result.match_at(1).relevance); | 835 EXPECT_GT(result.match_at(0).relevance, result.match_at(1).relevance); |
833 EXPECT_GT(result.match_at(1).relevance, result.match_at(2).relevance); | 836 EXPECT_GT(result.match_at(1).relevance, result.match_at(2).relevance); |
834 EXPECT_TRUE(result.match_at(0).allowed_to_be_default_match); | 837 EXPECT_TRUE(result.match_at(0).allowed_to_be_default_match); |
835 EXPECT_TRUE(result.match_at(1).allowed_to_be_default_match); | 838 EXPECT_TRUE(result.match_at(1).allowed_to_be_default_match); |
836 EXPECT_TRUE(result.match_at(2).allowed_to_be_default_match); | 839 EXPECT_FALSE(result.match_at(2).allowed_to_be_default_match); |
837 | 840 |
838 // The two keyword results should come with the keyword we expect. | 841 // The two keyword results should come with the keyword we expect. |
839 EXPECT_EQ(ASCIIToUTF16("k"), result.match_at(0).keyword); | 842 EXPECT_EQ(ASCIIToUTF16("k"), result.match_at(0).keyword); |
840 EXPECT_EQ(ASCIIToUTF16("k"), result.match_at(1).keyword); | 843 EXPECT_EQ(ASCIIToUTF16("k"), result.match_at(1).keyword); |
841 // The default provider has a different keyword. (We don't explicitly | 844 // The default provider has a different keyword. (We don't explicitly |
842 // set it during this test, so all we do is assert that it's different.) | 845 // set it during this test, so all we do is assert that it's different.) |
843 EXPECT_NE(result.match_at(0).keyword, result.match_at(2).keyword); | 846 EXPECT_NE(result.match_at(0).keyword, result.match_at(2).keyword); |
844 | 847 |
845 // The top result will always have a description. The third result, | 848 // The top result will always have a description. The third result, |
846 // coming from a different provider than the first two, should also. | 849 // coming from a different provider than the first two, should also. |
847 // Whether the second result has one doesn't matter much. (If it was | 850 // Whether the second result has one doesn't matter much. (If it was |
848 // missing, people would infer that it's the same search provider as | 851 // missing, people would infer that it's the same search provider as |
849 // the one above it.) | 852 // the one above it.) |
850 EXPECT_FALSE(result.match_at(0).description.empty()); | 853 EXPECT_FALSE(result.match_at(0).description.empty()); |
851 EXPECT_FALSE(result.match_at(2).description.empty()); | 854 EXPECT_FALSE(result.match_at(2).description.empty()); |
852 EXPECT_NE(result.match_at(0).description, result.match_at(2).description); | 855 EXPECT_NE(result.match_at(0).description, result.match_at(2).description); |
853 } | 856 } |
854 | 857 |
855 TEST_F(SearchProviderTest, KeywordVerbatim) { | 858 TEST_F(SearchProviderTest, KeywordVerbatim) { |
856 TestData cases[] = { | 859 TestData cases[] = { |
857 // Test a simple keyword input. | 860 // Test a simple keyword input. |
858 { ASCIIToUTF16("k foo"), 2, | 861 { ASCIIToUTF16("k foo"), 2, |
859 { ResultInfo(GURL("http://keyword/foo"), | 862 { ResultInfo(GURL("http://keyword/foo"), |
860 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 863 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
864 true, | |
861 ASCIIToUTF16("k foo")), | 865 ASCIIToUTF16("k foo")), |
862 ResultInfo(GURL("http://defaultturl/k%20foo"), | 866 ResultInfo(GURL("http://defaultturl/k%20foo"), |
863 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 867 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
868 false, | |
864 ASCIIToUTF16("k foo") ) } }, | 869 ASCIIToUTF16("k foo") ) } }, |
865 | 870 |
866 // Make sure extra whitespace after the keyword doesn't change the | 871 // Make sure extra whitespace after the keyword doesn't change the |
867 // keyword verbatim query. | 872 // keyword verbatim query. |
868 { ASCIIToUTF16("k foo"), 2, | 873 { ASCIIToUTF16("k foo"), 2, |
869 { ResultInfo(GURL("http://keyword/foo"), | 874 { ResultInfo(GURL("http://keyword/foo"), |
870 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 875 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
876 true, | |
871 ASCIIToUTF16("k foo")), | 877 ASCIIToUTF16("k foo")), |
872 ResultInfo(GURL("http://defaultturl/k%20%20%20foo"), | 878 ResultInfo(GURL("http://defaultturl/k%20%20%20foo"), |
873 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 879 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
880 false, | |
874 ASCIIToUTF16("k foo")) } }, | 881 ASCIIToUTF16("k foo")) } }, |
875 // Leading whitespace should be stripped before SearchProvider gets the | 882 // Leading whitespace should be stripped before SearchProvider gets the |
876 // input; hence there are no tests here about how it handles those inputs. | 883 // input; hence there are no tests here about how it handles those inputs. |
877 | 884 |
878 // But whitespace elsewhere in the query string should matter to both | 885 // But whitespace elsewhere in the query string should matter to both |
879 // matches. | 886 // matches. |
880 { ASCIIToUTF16("k foo bar"), 2, | 887 { ASCIIToUTF16("k foo bar"), 2, |
881 { ResultInfo(GURL("http://keyword/foo%20%20bar"), | 888 { ResultInfo(GURL("http://keyword/foo%20%20bar"), |
882 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 889 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
890 true, | |
883 ASCIIToUTF16("k foo bar")), | 891 ASCIIToUTF16("k foo bar")), |
884 ResultInfo(GURL("http://defaultturl/k%20%20foo%20%20bar"), | 892 ResultInfo(GURL("http://defaultturl/k%20%20foo%20%20bar"), |
885 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 893 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
894 false, | |
886 ASCIIToUTF16("k foo bar")) } }, | 895 ASCIIToUTF16("k foo bar")) } }, |
887 // Note in the above test case we don't test trailing whitespace because | 896 // Note in the above test case we don't test trailing whitespace because |
888 // SearchProvider still doesn't handle this well. See related bugs: | 897 // SearchProvider still doesn't handle this well. See related bugs: |
889 // 102690, 99239, 164635. | 898 // 102690, 99239, 164635. |
890 | 899 |
891 // Keywords can be prefixed by certain things that should get ignored | 900 // Keywords can be prefixed by certain things that should get ignored |
892 // when constructing the keyword match. | 901 // when constructing the keyword match. |
893 { ASCIIToUTF16("www.k foo"), 2, | 902 { ASCIIToUTF16("www.k foo"), 2, |
894 { ResultInfo(GURL("http://keyword/foo"), | 903 { ResultInfo(GURL("http://keyword/foo"), |
895 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 904 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
905 true, | |
896 ASCIIToUTF16("k foo")), | 906 ASCIIToUTF16("k foo")), |
897 ResultInfo(GURL("http://defaultturl/www.k%20foo"), | 907 ResultInfo(GURL("http://defaultturl/www.k%20foo"), |
898 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 908 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
909 false, | |
899 ASCIIToUTF16("www.k foo")) } }, | 910 ASCIIToUTF16("www.k foo")) } }, |
900 { ASCIIToUTF16("http://k foo"), 2, | 911 { ASCIIToUTF16("http://k foo"), 2, |
901 { ResultInfo(GURL("http://keyword/foo"), | 912 { ResultInfo(GURL("http://keyword/foo"), |
902 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 913 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
914 true, | |
903 ASCIIToUTF16("k foo")), | 915 ASCIIToUTF16("k foo")), |
904 ResultInfo(GURL("http://defaultturl/http%3A//k%20foo"), | 916 ResultInfo(GURL("http://defaultturl/http%3A//k%20foo"), |
905 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 917 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
918 false, | |
906 ASCIIToUTF16("http://k foo")) } }, | 919 ASCIIToUTF16("http://k foo")) } }, |
907 { ASCIIToUTF16("http://www.k foo"), 2, | 920 { ASCIIToUTF16("http://www.k foo"), 2, |
908 { ResultInfo(GURL("http://keyword/foo"), | 921 { ResultInfo(GURL("http://keyword/foo"), |
909 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 922 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
923 true, | |
910 ASCIIToUTF16("k foo")), | 924 ASCIIToUTF16("k foo")), |
911 ResultInfo(GURL("http://defaultturl/http%3A//www.k%20foo"), | 925 ResultInfo(GURL("http://defaultturl/http%3A//www.k%20foo"), |
912 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 926 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
927 false, | |
913 ASCIIToUTF16("http://www.k foo")) } }, | 928 ASCIIToUTF16("http://www.k foo")) } }, |
914 | 929 |
915 // A keyword with no remaining input shouldn't get a keyword | 930 // A keyword with no remaining input shouldn't get a keyword |
916 // verbatim match. | 931 // verbatim match. |
917 { ASCIIToUTF16("k"), 1, | 932 { ASCIIToUTF16("k"), 1, |
918 { ResultInfo(GURL("http://defaultturl/k"), | 933 { ResultInfo(GURL("http://defaultturl/k"), |
919 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 934 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
935 true, | |
920 ASCIIToUTF16("k")) } }, | 936 ASCIIToUTF16("k")) } }, |
921 { ASCIIToUTF16("k "), 1, | 937 { ASCIIToUTF16("k "), 1, |
922 { ResultInfo(GURL("http://defaultturl/k%20"), | 938 { ResultInfo(GURL("http://defaultturl/k%20"), |
923 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 939 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
940 true, | |
924 ASCIIToUTF16("k ")) } } | 941 ASCIIToUTF16("k ")) } } |
925 | 942 |
926 // The fact that verbatim queries to keyword are handled by KeywordProvider | 943 // The fact that verbatim queries to keyword are handled by KeywordProvider |
927 // not SearchProvider is tested in | 944 // not SearchProvider is tested in |
928 // chrome/browser/extensions/api/omnibox/omnibox_apitest.cc. | 945 // chrome/browser/extensions/api/omnibox/omnibox_apitest.cc. |
929 }; | 946 }; |
930 | 947 |
931 // Test not in keyword mode. | 948 // Test not in keyword mode. |
932 RunTest(cases, arraysize(cases), false); | 949 RunTest(cases, arraysize(cases), false); |
933 | 950 |
(...skipping 17 matching lines...) Expand all Loading... | |
951 | 968 |
952 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL, | 969 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL, |
953 "http://www.bar.com/"); | 970 "http://www.bar.com/"); |
954 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 971 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
955 switches::kExtraSearchQueryParams, "a=b"); | 972 switches::kExtraSearchQueryParams, "a=b"); |
956 | 973 |
957 TestData cases[] = { | 974 TestData cases[] = { |
958 { ASCIIToUTF16("k a"), 2, | 975 { ASCIIToUTF16("k a"), 2, |
959 { ResultInfo(GURL("http://keyword/a"), | 976 { ResultInfo(GURL("http://keyword/a"), |
960 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 977 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
978 true, | |
961 ASCIIToUTF16("k a")), | 979 ASCIIToUTF16("k a")), |
962 ResultInfo(GURL("http://www.bar.com/k%20a?a=b"), | 980 ResultInfo(GURL("http://www.bar.com/k%20a?a=b"), |
963 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 981 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
982 false, | |
964 ASCIIToUTF16("k a")) } }, | 983 ASCIIToUTF16("k a")) } }, |
965 }; | 984 }; |
966 | 985 |
967 RunTest(cases, arraysize(cases), false); | 986 RunTest(cases, arraysize(cases), false); |
968 } | 987 } |
969 | 988 |
970 // Verifies Navsuggest results don't set a TemplateURL, which Instant relies on. | 989 // Verifies Navsuggest results don't set a TemplateURL, which Instant relies on. |
971 // Also verifies that just the *first* navigational result is listed as a match | 990 // Also verifies that just the *first* navigational result is listed as a match |
972 // if suggested relevance scores were not sent. | 991 // if suggested relevance scores were not sent. |
973 TEST_F(SearchProviderTest, NavSuggestNoSuggestedRelevanceScores) { | 992 TEST_F(SearchProviderTest, NavSuggestNoSuggestedRelevanceScores) { |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1597 test_factory_.GetFetcherByID( | 1616 test_factory_.GetFetcherByID( |
1598 SearchProvider::kDefaultProviderURLFetcherID); | 1617 SearchProvider::kDefaultProviderURLFetcherID); |
1599 ASSERT_TRUE(fetcher); | 1618 ASSERT_TRUE(fetcher); |
1600 fetcher->set_response_code(200); | 1619 fetcher->set_response_code(200); |
1601 fetcher->SetResponseString(cases[i].json); | 1620 fetcher->SetResponseString(cases[i].json); |
1602 fetcher->delegate()->OnURLFetchComplete(fetcher); | 1621 fetcher->delegate()->OnURLFetchComplete(fetcher); |
1603 RunTillProviderDone(); | 1622 RunTillProviderDone(); |
1604 | 1623 |
1605 const std::string description = "for input with json=" + cases[i].json; | 1624 const std::string description = "for input with json=" + cases[i].json; |
1606 const ACMatches& matches = provider_->matches(); | 1625 const ACMatches& matches = provider_->matches(); |
1607 // The top match must inline and score as highly as calculated verbatim. | |
1608 ASSERT_FALSE(matches.empty()); | 1626 ASSERT_FALSE(matches.empty()); |
1627 // Find the first match that's allowed to be the default match and check | |
1628 // its inline_autocompletion. | |
1629 ACMatches::const_iterator it = matches.begin(); | |
1630 while ((it != matches.end()) && !it->allowed_to_be_default_match) | |
1631 ++it; | |
1632 ASSERT_NE(matches.end(), it); | |
1609 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 1633 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
1610 matches[0].inline_autocompletion) << description; | 1634 it->inline_autocompletion) << description; |
1611 | 1635 |
1612 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 1636 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
1613 size_t j = 0; | 1637 size_t j = 0; |
1614 // Ensure that the returned matches equal the expectations. | 1638 // Ensure that the returned matches equal the expectations. |
1615 for (; j < matches.size(); ++j) { | 1639 for (; j < matches.size(); ++j) { |
1616 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), | 1640 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), |
1617 matches[j].contents) << description; | 1641 matches[j].contents) << description; |
1618 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, | 1642 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, |
1619 matches[j].allowed_to_be_default_match) << description; | 1643 matches[j].allowed_to_be_default_match) << description; |
1620 } | 1644 } |
(...skipping 22 matching lines...) Expand all Loading... | |
1643 struct { | 1667 struct { |
1644 const std::string json; | 1668 const std::string json; |
1645 const KeywordFetcherMatch matches[6]; | 1669 const KeywordFetcherMatch matches[6]; |
1646 const std::string inline_autocompletion; | 1670 const std::string inline_autocompletion; |
1647 } cases[] = { | 1671 } cases[] = { |
1648 // Ensure that suggest relevance scores reorder matches and that | 1672 // Ensure that suggest relevance scores reorder matches and that |
1649 // the keyword verbatim (lacking a suggested verbatim score) beats | 1673 // the keyword verbatim (lacking a suggested verbatim score) beats |
1650 // the default provider verbatim. | 1674 // the default provider verbatim. |
1651 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 1675 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
1652 { { "a", true, true }, | 1676 { { "a", true, true }, |
1653 { "k a", false, true }, | 1677 { "k a", false, false }, |
1654 { "c", true, false }, | 1678 { "c", true, false }, |
1655 { "b", true, false }, | 1679 { "b", true, false }, |
1656 kEmptyMatch, kEmptyMatch }, | 1680 kEmptyMatch, kEmptyMatch }, |
1657 std::string() }, | 1681 std::string() }, |
1658 // Again, check that relevance scores reorder matches, just this | 1682 // Again, check that relevance scores reorder matches, just this |
1659 // time with navigation matches. This also checks that with | 1683 // time with navigation matches. This also checks that with |
1660 // suggested relevance scores we allow multiple navsuggest results. | 1684 // suggested relevance scores we allow multiple navsuggest results. |
1661 // It's odd that navsuggest results that come from a keyword | 1685 // Note that navsuggest results that come from a keyword provider |
1662 // provider are marked as not a keyword result. I think this | 1686 // are marked as not a keyword result. (They don't go to a |
1663 // comes from them not going to a keyword search engine). | 1687 // keyword search engine.) |
1664 // TODO(mpearson): Investigate the implications (if any) of | |
1665 // tagging these results appropriately. If so, do it because it | |
1666 // makes more sense. | |
1667 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," | 1688 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," |
1668 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1689 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1669 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", | 1690 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", |
1670 { { "a", true, true }, | 1691 { { "a", true, true }, |
1671 { "d", true, false }, | 1692 { "d", true, false }, |
1672 { "c.com", false, false }, | 1693 { "c.com", false, false }, |
1673 { "b.com", false, false }, | 1694 { "b.com", false, false }, |
1674 { "k a", false, true }, | 1695 { "k a", false, false }, |
1675 kEmptyMatch }, | 1696 kEmptyMatch }, |
1676 std::string() }, | 1697 std::string() }, |
1677 | 1698 |
1678 // Without suggested relevance scores, we should only allow one | 1699 // Without suggested relevance scores, we should only allow one |
1679 // navsuggest result to be be displayed. | 1700 // navsuggest result to be be displayed. |
1680 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1701 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
1681 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 1702 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
1682 { { "a", true, true }, | 1703 { { "a", true, true }, |
1683 { "b.com", false, false }, | 1704 { "b.com", false, false }, |
1684 { "k a", false, true }, | 1705 { "k a", false, false }, |
1685 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1706 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1686 std::string() }, | 1707 std::string() }, |
1687 | 1708 |
1688 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1709 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
1689 // Negative values will have no effect; the calculated value will be used. | 1710 // Negative values will have no effect; the calculated value will be used. |
1690 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1711 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
1691 "\"google:suggestrelevance\":[9998]}]", | 1712 "\"google:suggestrelevance\":[9998]}]", |
1692 { { "a", true, true }, | 1713 { { "a", true, true }, |
1693 { "a1", true, true }, | 1714 { "a1", true, true }, |
1694 { "k a", false, true }, | 1715 { "k a", false, false }, |
1695 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1716 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1696 std::string() }, | 1717 std::string() }, |
1697 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1718 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
1698 "\"google:suggestrelevance\":[9999]}]", | 1719 "\"google:suggestrelevance\":[9999]}]", |
1699 { { "a1", true, true }, | 1720 { { "a1", true, true }, |
1700 { "a", true, true }, | 1721 { "a", true, true }, |
1701 { "k a", false, true }, | 1722 { "k a", false, false }, |
1702 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1723 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1703 "1" }, | 1724 "1" }, |
1704 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 1725 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
1705 "\"google:suggestrelevance\":[9999]}]", | 1726 "\"google:suggestrelevance\":[9999]}]", |
1706 { { "a1", true, true }, | 1727 { { "a1", true, true }, |
1707 { "k a", false, true }, | 1728 { "k a", false, false }, |
1708 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1729 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1709 "1" }, | 1730 "1" }, |
1710 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 1731 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
1711 "\"google:suggestrelevance\":[9999]}]", | 1732 "\"google:suggestrelevance\":[9999]}]", |
1712 { { "a1", true, true }, | 1733 { { "a1", true, true }, |
1713 { "a", true, true }, | 1734 { "a", true, true }, |
1714 { "k a", false, true }, | 1735 { "k a", false, false }, |
1715 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1736 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1716 "1" }, | 1737 "1" }, |
1717 { "[\"a\",[\"http://a.com\"],[],[]," | 1738 { "[\"a\",[\"http://a.com\"],[],[]," |
1718 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1739 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1719 "\"google:verbatimrelevance\":9999," | 1740 "\"google:verbatimrelevance\":9999," |
1720 "\"google:suggestrelevance\":[9998]}]", | 1741 "\"google:suggestrelevance\":[9998]}]", |
1721 { { "a", true, true }, | 1742 { { "a", true, true }, |
1722 { "a.com", false, true }, | 1743 { "a.com", false, false }, |
1723 { "k a", false, true }, | 1744 { "k a", false, false }, |
1724 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1745 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1725 std::string() }, | 1746 std::string() }, |
1726 | 1747 |
1727 // Ensure that both types of relevance scores reorder matches together. | 1748 // Ensure that both types of relevance scores reorder matches together. |
1728 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1749 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
1729 "\"google:verbatimrelevance\":9998}]", | 1750 "\"google:verbatimrelevance\":9998}]", |
1730 { { "a1", true, true }, | 1751 { { "a1", true, true }, |
1731 { "a", true, true }, | 1752 { "a", true, true }, |
1732 { "a2", true, true }, | 1753 { "a2", true, true }, |
1733 { "k a", false, true }, | 1754 { "k a", false, false }, |
1734 kEmptyMatch, kEmptyMatch }, | 1755 kEmptyMatch, kEmptyMatch }, |
1735 "1" }, | 1756 "1" }, |
1736 | 1757 |
1737 // Ensure that only inlinable matches may be ranked as the highest result. | 1758 // Ensure that only inlinable matches may be ranked as the highest result. |
1738 // Ignore all suggested relevance scores if this constraint is violated. | 1759 // Ignore all suggested relevance scores if this constraint is violated. |
1739 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1760 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
1740 { { "a", true, true }, | 1761 { { "a", true, true }, |
1741 { "b", true, false }, | 1762 { "b", true, false }, |
1742 { "k a", false, true }, | 1763 { "k a", false, false }, |
1743 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1764 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1744 std::string() }, | 1765 std::string() }, |
1745 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1766 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
1746 "\"google:verbatimrelevance\":0}]", | 1767 "\"google:verbatimrelevance\":0}]", |
1747 { { "a", true, true }, | 1768 { { "a", true, true }, |
1748 { "b", true, false }, | 1769 { "b", true, false }, |
1749 { "k a", false, true }, | 1770 { "k a", false, false }, |
1750 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1771 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1751 std::string() }, | 1772 std::string() }, |
1752 { "[\"a\",[\"http://b.com\"],[],[]," | 1773 { "[\"a\",[\"http://b.com\"],[],[]," |
1753 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1774 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1754 "\"google:suggestrelevance\":[9999]}]", | 1775 "\"google:suggestrelevance\":[9999]}]", |
1755 { { "a", true, true }, | 1776 { { "a", true, true }, |
1756 { "b.com", false, false }, | 1777 { "b.com", false, false }, |
1757 { "k a", false, true }, | 1778 { "k a", false, false }, |
1758 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1779 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1759 std::string() }, | 1780 std::string() }, |
1760 { "[\"a\",[\"http://b.com\"],[],[]," | 1781 { "[\"a\",[\"http://b.com\"],[],[]," |
1761 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1782 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1762 "\"google:suggestrelevance\":[9999]," | 1783 "\"google:suggestrelevance\":[9999]," |
1763 "\"google:verbatimrelevance\":0}]", | 1784 "\"google:verbatimrelevance\":0}]", |
1764 { { "a", true, true }, | 1785 { { "a", true, true }, |
1765 { "b.com", false, false }, | 1786 { "b.com", false, false }, |
1766 { "k a", false, true }, | 1787 { "k a", false, false }, |
1767 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1788 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1768 std::string() }, | 1789 std::string() }, |
1769 | 1790 |
1770 // Ensure that the top result is ranked as highly as calculated verbatim. | 1791 // Ensure that the top result is ranked as highly as calculated verbatim. |
1771 // Ignore the suggested verbatim relevance if this constraint is violated. | 1792 // Ignore the suggested verbatim relevance if this constraint is violated. |
1772 // Note that keyword suggestions by default (not in suggested relevance | 1793 // Note that keyword suggestions by default (not in suggested relevance |
1773 // mode) score more highly than the default verbatim. | 1794 // mode) score more highly than the default verbatim. |
1774 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1795 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
1775 { { "a", true, true }, | 1796 { { "a", true, true }, |
1776 { "a1", true, true }, | 1797 { "a1", true, true }, |
1777 { "k a", false, true }, | 1798 { "k a", false, false }, |
1778 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1799 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1779 std::string() }, | 1800 std::string() }, |
1780 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 1801 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
1781 { { "a", true, true }, | 1802 { { "a", true, true }, |
1782 { "a1", true, true }, | 1803 { "a1", true, true }, |
1783 { "k a", false, true }, | 1804 { "k a", false, false }, |
1784 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1805 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1785 std::string() }, | 1806 std::string() }, |
1786 // Continuing the same category of tests, but make sure we keep the | 1807 // Continuing the same category of tests, but make sure we keep the |
1787 // suggested relevance scores even as we discard the verbatim relevance | 1808 // suggested relevance scores even as we discard the verbatim relevance |
1788 // scores. | 1809 // scores. |
1789 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 1810 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
1790 "\"google:verbatimrelevance\":0}]", | 1811 "\"google:verbatimrelevance\":0}]", |
1791 { { "a", true, true }, | 1812 { { "a", true, true }, |
1792 { "k a", false, true }, | 1813 { "k a", false, false }, |
1793 { "a1", true, true }, | 1814 { "a1", true, true }, |
1794 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1815 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1795 std::string() }, | 1816 std::string() }, |
1796 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 1817 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
1797 "\"google:verbatimrelevance\":0}]", | 1818 "\"google:verbatimrelevance\":0}]", |
1798 { { "a", true, true }, | 1819 { { "a", true, true }, |
1799 { "k a", false, true }, | 1820 { "k a", false, false }, |
1800 { "a2", true, true }, | 1821 { "a2", true, true }, |
1801 { "a1", true, true }, | 1822 { "a1", true, true }, |
1802 kEmptyMatch, kEmptyMatch }, | 1823 kEmptyMatch, kEmptyMatch }, |
1803 std::string() }, | 1824 std::string() }, |
1804 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 1825 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
1805 "\"google:verbatimrelevance\":2}]", | 1826 "\"google:verbatimrelevance\":2}]", |
1806 { { "a", true, true }, | 1827 { { "a", true, true }, |
1807 { "k a", false, true }, | 1828 { "k a", false, false }, |
1808 { "a2", true, true }, | 1829 { "a2", true, true }, |
1809 { "a1", true, true }, | 1830 { "a1", true, true }, |
1810 kEmptyMatch, kEmptyMatch }, | 1831 kEmptyMatch, kEmptyMatch }, |
1811 std::string() }, | 1832 std::string() }, |
1812 | 1833 |
1813 // Ensure that all suggestions are considered, regardless of order. | 1834 // Ensure that all suggestions are considered, regardless of order. |
1814 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1835 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
1815 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1836 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
1816 { { "a", true, true }, | 1837 { { "a", true, true }, |
1817 { "k a", false, true }, | 1838 { "k a", false, false }, |
1818 { "h", true, false }, | 1839 { "h", true, false }, |
1819 { "g", true, false }, | 1840 { "g", true, false }, |
1820 { "f", true, false }, | 1841 { "f", true, false }, |
1821 { "e", true, false } }, | 1842 { "e", true, false } }, |
1822 std::string() }, | 1843 std::string() }, |
1823 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1844 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
1824 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1845 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
1825 "\"http://h.com\"],[],[]," | 1846 "\"http://h.com\"],[],[]," |
1826 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1847 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
1827 "\"NAVIGATION\", \"NAVIGATION\"," | 1848 "\"NAVIGATION\", \"NAVIGATION\"," |
1828 "\"NAVIGATION\", \"NAVIGATION\"," | 1849 "\"NAVIGATION\", \"NAVIGATION\"," |
1829 "\"NAVIGATION\"]," | 1850 "\"NAVIGATION\"]," |
1830 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1851 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
1831 { { "a", true, true }, | 1852 { { "a", true, true }, |
1832 { "k a", false, true }, | 1853 { "k a", false, false }, |
1833 { "h.com", false, false }, | 1854 { "h.com", false, false }, |
1834 { "g.com", false, false }, | 1855 { "g.com", false, false }, |
1835 { "f.com", false, false }, | 1856 { "f.com", false, false }, |
1836 { "e.com", false, false } }, | 1857 { "e.com", false, false } }, |
1837 std::string() }, | 1858 std::string() }, |
1838 | 1859 |
1839 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1860 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
1840 // Note that keyword suggestions by default (not in suggested relevance | 1861 // Note that keyword suggestions by default (not in suggested relevance |
1841 // mode) score more highly than the default verbatim. | 1862 // mode) score more highly than the default verbatim. |
1842 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1863 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
1843 { { "a", true, true }, | 1864 { { "a", true, true }, |
1844 { "a1", true, true }, | 1865 { "a1", true, true }, |
1845 { "a2", true, true }, | 1866 { "a2", true, true }, |
1846 { "k a", false, true }, | 1867 { "k a", false, false }, |
1847 kEmptyMatch, kEmptyMatch }, | 1868 kEmptyMatch, kEmptyMatch }, |
1848 std::string() }, | 1869 std::string() }, |
1849 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1870 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
1850 { { "a", true, true }, | 1871 { { "a", true, true }, |
1851 { "a1", true, true }, | 1872 { "a1", true, true }, |
1852 { "k a", false, true }, | 1873 { "k a", false, false }, |
1853 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1874 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1854 std::string() }, | 1875 std::string() }, |
1855 // In this case, ignoring the suggested relevance scores means we keep | 1876 // In this case, ignoring the suggested relevance scores means we keep |
1856 // only one navsuggest result. | 1877 // only one navsuggest result. |
1857 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1878 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1858 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1879 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1859 "\"google:suggestrelevance\":[1]}]", | 1880 "\"google:suggestrelevance\":[1]}]", |
1860 { { "a", true, true }, | 1881 { { "a", true, true }, |
1861 { "a1.com", false, true }, | 1882 { "a1.com", false, false }, |
1862 { "k a", false, true }, | 1883 { "k a", false, false }, |
1863 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1884 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1864 std::string() }, | 1885 std::string() }, |
1865 { "[\"a\",[\"http://a1.com\"],[],[]," | 1886 { "[\"a\",[\"http://a1.com\"],[],[]," |
1866 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1887 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1867 "\"google:suggestrelevance\":[9999, 1]}]", | 1888 "\"google:suggestrelevance\":[9999, 1]}]", |
1868 { { "a", true, true }, | 1889 { { "a", true, true }, |
1869 { "a1.com", false, true }, | 1890 { "a1.com", false, false }, |
1870 { "k a", false, true }, | 1891 { "k a", false, false }, |
1871 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1892 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1872 std::string() }, | 1893 std::string() }, |
1873 | 1894 |
1874 // Ensure that all 'verbatim' results are merged with their maximum score. | 1895 // Ensure that all 'verbatim' results are merged with their maximum score. |
1875 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1896 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
1876 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1897 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
1877 { { "a2", true, true }, | 1898 { { "a2", true, true }, |
1878 { "a", true, true }, | 1899 { "a", true, true }, |
1879 { "a1", true, true }, | 1900 { "a1", true, true }, |
1880 { "k a", false, true }, | 1901 { "k a", false, false }, |
1881 kEmptyMatch, kEmptyMatch }, | 1902 kEmptyMatch, kEmptyMatch }, |
1882 "2" }, | 1903 "2" }, |
1883 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1904 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
1884 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1905 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
1885 "\"google:verbatimrelevance\":0}]", | 1906 "\"google:verbatimrelevance\":0}]", |
1886 { { "a2", true, true }, | 1907 { { "a2", true, true }, |
1887 { "a", true, true }, | 1908 { "a", true, true }, |
1888 { "a1", true, true }, | 1909 { "a1", true, true }, |
1889 { "k a", false, true }, | 1910 { "k a", false, false }, |
1890 kEmptyMatch, kEmptyMatch }, | 1911 kEmptyMatch, kEmptyMatch }, |
1891 "2" }, | 1912 "2" }, |
1892 | 1913 |
1893 // Ensure that verbatim is always generated without other suggestions. | 1914 // Ensure that verbatim is always generated without other suggestions. |
1894 // TODO(mpearson): Ensure the value of verbatimrelevance is respected | 1915 // TODO(mpearson): Ensure the value of verbatimrelevance is respected |
1895 // (except when suggested relevances are ignored). | 1916 // (except when suggested relevances are ignored). |
1896 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1917 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
1897 { { "a", true, true }, | 1918 { { "a", true, true }, |
1898 { "k a", false, true }, | 1919 { "k a", false, false }, |
1899 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1920 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1900 std::string() }, | 1921 std::string() }, |
1901 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1922 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
1902 { { "a", true, true }, | 1923 { { "a", true, true }, |
1903 { "k a", false, true }, | 1924 { "k a", false, false }, |
1904 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1925 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1905 std::string() }, | 1926 std::string() }, |
1906 | 1927 |
1907 // Check that navsuggestions will be demoted below queries. | 1928 // Check that navsuggestions will be demoted below queries. |
1908 // (Navsuggestions are not allowed to appear first.) In the process, | 1929 // (Navsuggestions are not allowed to appear first.) In the process, |
1909 // make sure the navsuggestions still remain in the same order. | 1930 // make sure the navsuggestions still remain in the same order. |
1910 // First, check the situation where navsuggest scores more than verbatim | 1931 // First, check the situation where navsuggest scores more than verbatim |
1911 // and there are no query suggestions. | 1932 // and there are no query suggestions. |
1912 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1933 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1913 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1934 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1914 "\"google:verbatimrelevance\":9990," | 1935 "\"google:verbatimrelevance\":9990," |
1915 "\"google:suggestrelevance\":[9998, 9999]}]", | 1936 "\"google:suggestrelevance\":[9998, 9999]}]", |
1916 { { "a", true, true }, | 1937 { { "a", true, true }, |
1917 { "a2.com", false, true }, | 1938 { "a2.com", false, false }, |
1918 { "a1.com", false, true }, | 1939 { "a1.com", false, false }, |
1919 { "k a", false, true }, | 1940 { "k a", false, false }, |
1920 kEmptyMatch, kEmptyMatch }, | 1941 kEmptyMatch, kEmptyMatch }, |
1921 std::string() }, | 1942 std::string() }, |
1922 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1943 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
1923 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1944 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
1924 "\"google:verbatimrelevance\":9990," | 1945 "\"google:verbatimrelevance\":9990," |
1925 "\"google:suggestrelevance\":[9999, 9998]}]", | 1946 "\"google:suggestrelevance\":[9999, 9998]}]", |
1926 { { "a", true, true }, | 1947 { { "a", true, true }, |
1927 { "a1.com", false, true }, | 1948 { "a1.com", false, false }, |
1928 { "a2.com", false, true }, | 1949 { "a2.com", false, false }, |
1929 { "k a", false, true }, | 1950 { "k a", false, false }, |
1930 kEmptyMatch, kEmptyMatch }, | 1951 kEmptyMatch, kEmptyMatch }, |
1931 std::string() }, | 1952 std::string() }, |
1932 { "[\"a\",[\"https://a/\"],[],[]," | 1953 { "[\"a\",[\"https://a/\"],[],[]," |
1933 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1954 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
1934 "\"google:suggestrelevance\":[9999]}]", | 1955 "\"google:suggestrelevance\":[9999]}]", |
1935 { { "a", true, true }, | 1956 { { "a", true, true }, |
1936 { "https://a", false, true }, | 1957 { "https://a", false, false }, |
1937 { "k a", false, true }, | 1958 { "k a", false, false }, |
1938 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1959 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
1939 std::string() }, | 1960 std::string() }, |
1940 // Check when navsuggest scores more than verbatim and there is query | 1961 // Check when navsuggest scores more than verbatim and there is query |
1941 // suggestion but it scores lower. | 1962 // suggestion but it scores lower. |
1942 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1963 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1943 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1964 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1944 "\"google:verbatimrelevance\":9990," | 1965 "\"google:verbatimrelevance\":9990," |
1945 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", | 1966 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
1946 { { "a", true, true }, | 1967 { { "a", true, true }, |
1947 { "a2.com", false, true }, | 1968 { "a2.com", false, false }, |
1948 { "a1.com", false, true }, | 1969 { "a1.com", false, false }, |
1949 { "a3", true, true }, | 1970 { "a3", true, true }, |
1950 { "k a", false, true }, | 1971 { "k a", false, false }, |
1951 kEmptyMatch }, | 1972 kEmptyMatch }, |
1952 std::string() }, | 1973 std::string() }, |
1953 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1974 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1954 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1975 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1955 "\"google:verbatimrelevance\":9990," | 1976 "\"google:verbatimrelevance\":9990," |
1956 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", | 1977 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
1957 { { "a", true, true }, | 1978 { { "a", true, true }, |
1958 { "a1.com", false, true }, | 1979 { "a1.com", false, false }, |
1959 { "a2.com", false, true }, | 1980 { "a2.com", false, false }, |
1960 { "a3", true, true }, | 1981 { "a3", true, true }, |
1961 { "k a", false, true }, | 1982 { "k a", false, false }, |
1962 kEmptyMatch }, | 1983 kEmptyMatch }, |
1963 std::string() }, | 1984 std::string() }, |
1964 // Check when navsuggest scores more than a query suggestion. There is | 1985 // Check when navsuggest scores more than a query suggestion. There is |
1965 // a verbatim but it scores lower. | 1986 // a verbatim but it scores lower. |
1966 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1987 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1967 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1988 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1968 "\"google:verbatimrelevance\":9990," | 1989 "\"google:verbatimrelevance\":9990," |
1969 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1990 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
1970 { { "a3", true, true }, | 1991 { { "a3", true, true }, |
1971 { "a2.com", false, true }, | 1992 { "a2.com", false, false }, |
1972 { "a1.com", false, true }, | 1993 { "a1.com", false, false }, |
1973 { "a", true, true }, | 1994 { "a", true, true }, |
1974 { "k a", false, true }, | 1995 { "k a", false, false }, |
1975 kEmptyMatch }, | 1996 kEmptyMatch }, |
1976 "3" }, | 1997 "3" }, |
1977 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1998 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1978 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1999 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1979 "\"google:verbatimrelevance\":9990," | 2000 "\"google:verbatimrelevance\":9990," |
1980 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 2001 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
1981 { { "a3", true, true }, | 2002 { { "a3", true, true }, |
1982 { "a1.com", false, true }, | 2003 { "a1.com", false, false }, |
1983 { "a2.com", false, true }, | 2004 { "a2.com", false, false }, |
1984 { "a", true, true }, | 2005 { "a", true, true }, |
1985 { "k a", false, true }, | 2006 { "k a", false, false }, |
1986 kEmptyMatch }, | 2007 kEmptyMatch }, |
1987 "3" }, | 2008 "3" }, |
1988 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2009 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1989 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2010 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
1990 "\"google:verbatimrelevance\":0," | 2011 "\"google:verbatimrelevance\":0," |
1991 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 2012 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
1992 { { "a3", true, true }, | 2013 { { "a3", true, true }, |
1993 { "a2.com", false, true }, | 2014 { "a2.com", false, false }, |
1994 { "a1.com", false, true }, | 2015 { "a1.com", false, false }, |
1995 { "k a", false, true }, | 2016 { "k a", false, false }, |
1996 kEmptyMatch, kEmptyMatch }, | 2017 kEmptyMatch, kEmptyMatch }, |
1997 "3" }, | 2018 "3" }, |
1998 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2019 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
1999 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2020 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2000 "\"google:verbatimrelevance\":0," | 2021 "\"google:verbatimrelevance\":0," |
2001 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 2022 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
2002 { { "a3", true, true }, | 2023 { { "a3", true, true }, |
2003 { "a1.com", false, true }, | 2024 { "a1.com", false, false }, |
2004 { "a2.com", false, true }, | 2025 { "a2.com", false, false }, |
2005 { "k a", false, true }, | 2026 { "k a", false, false }, |
2006 kEmptyMatch, kEmptyMatch }, | 2027 kEmptyMatch, kEmptyMatch }, |
2007 "3" }, | 2028 "3" }, |
2008 // Check when there is neither verbatim nor a query suggestion that, | 2029 // Check when there is neither verbatim nor a query suggestion that, |
2009 // because we can't demote navsuggestions below a query suggestion, | 2030 // because we can't demote navsuggestions below a query suggestion, |
2010 // we abandon suggested relevance scores entirely. One consequence is | 2031 // we abandon suggested relevance scores entirely. One consequence is |
2011 // that this means we restore the keyword verbatim match. Note | 2032 // that this means we restore the keyword verbatim match. Note |
2012 // that in this case of abandoning suggested relevance scores, we still | 2033 // that in this case of abandoning suggested relevance scores, we still |
2013 // keep the navsuggestions in the same order, but we revert to only allowing | 2034 // keep the navsuggestions in the same order, but we revert to only allowing |
2014 // one navigation to appear because the scores are completely local. | 2035 // one navigation to appear because the scores are completely local. |
2015 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2036 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2016 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2037 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2017 "\"google:verbatimrelevance\":0," | 2038 "\"google:verbatimrelevance\":0," |
2018 "\"google:suggestrelevance\":[9998, 9999]}]", | 2039 "\"google:suggestrelevance\":[9998, 9999]}]", |
2019 { { "a", true, true }, | 2040 { { "a", true, true }, |
2020 { "a2.com", false, true }, | 2041 { "a2.com", false, false }, |
2021 { "k a", false, true }, | 2042 { "k a", false, false }, |
2022 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2043 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2023 std::string() }, | 2044 std::string() }, |
2024 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2045 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2025 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2046 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2026 "\"google:verbatimrelevance\":0," | 2047 "\"google:verbatimrelevance\":0," |
2027 "\"google:suggestrelevance\":[9999, 9998]}]", | 2048 "\"google:suggestrelevance\":[9999, 9998]}]", |
2028 { { "a", true, true }, | 2049 { { "a", true, true }, |
2029 { "a1.com", false, true }, | 2050 { "a1.com", false, false }, |
2030 { "k a", false, true }, | 2051 { "k a", false, false }, |
2031 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2052 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2032 std::string() }, | 2053 std::string() }, |
2033 // More checks that everything works when it's not necessary to demote. | 2054 // More checks that everything works when it's not necessary to demote. |
2034 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2055 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2035 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2056 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2036 "\"google:verbatimrelevance\":9990," | 2057 "\"google:verbatimrelevance\":9990," |
2037 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", | 2058 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
2038 { { "a3", true, true }, | 2059 { { "a3", true, true }, |
2039 { "a2.com", false, true }, | 2060 { "a2.com", false, false }, |
2040 { "a1.com", false, true }, | 2061 { "a1.com", false, false }, |
2041 { "a", true, true }, | 2062 { "a", true, true }, |
2042 { "k a", false, true }, | 2063 { "k a", false, false }, |
2043 kEmptyMatch }, | 2064 kEmptyMatch }, |
2044 "3" }, | 2065 "3" }, |
2045 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2066 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2046 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2067 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2047 "\"google:verbatimrelevance\":9990," | 2068 "\"google:verbatimrelevance\":9990," |
2048 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 2069 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
2049 { { "a3", true, true }, | 2070 { { "a3", true, true }, |
2050 { "a1.com", false, true }, | 2071 { "a1.com", false, false }, |
2051 { "a2.com", false, true }, | 2072 { "a2.com", false, false }, |
2052 { "a", true, true }, | 2073 { "a", true, true }, |
2053 { "k a", false, true }, | 2074 { "k a", false, false }, |
2054 kEmptyMatch }, | 2075 kEmptyMatch }, |
2055 "3" }, | 2076 "3" }, |
2056 }; | 2077 }; |
2057 | 2078 |
2058 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2079 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
2059 QueryForInput(ASCIIToUTF16("k a"), false, true); | 2080 QueryForInput(ASCIIToUTF16("k a"), false, true); |
2060 | 2081 |
2061 // Set up a default fetcher with no results. | 2082 // Set up a default fetcher with no results. |
2062 net::TestURLFetcher* default_fetcher = | 2083 net::TestURLFetcher* default_fetcher = |
2063 test_factory_.GetFetcherByID( | 2084 test_factory_.GetFetcherByID( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2120 struct { | 2141 struct { |
2121 const std::string json; | 2142 const std::string json; |
2122 const KeywordFetcherMatch matches[6]; | 2143 const KeywordFetcherMatch matches[6]; |
2123 const std::string inline_autocompletion; | 2144 const std::string inline_autocompletion; |
2124 } cases[] = { | 2145 } cases[] = { |
2125 // Ensure that suggest relevance scores reorder matches and that | 2146 // Ensure that suggest relevance scores reorder matches and that |
2126 // the keyword verbatim (lacking a suggested verbatim score) beats | 2147 // the keyword verbatim (lacking a suggested verbatim score) beats |
2127 // the default provider verbatim. | 2148 // the default provider verbatim. |
2128 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 2149 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
2129 { { "a", true, true }, | 2150 { { "a", true, true }, |
2130 { "k a", false, true }, | 2151 { "k a", false, false }, |
2131 { "c", true, false }, | 2152 { "c", true, false }, |
2132 { "b", true, false }, | 2153 { "b", true, false }, |
2133 kEmptyMatch, kEmptyMatch }, | 2154 kEmptyMatch, kEmptyMatch }, |
2134 std::string() }, | 2155 std::string() }, |
2135 // Again, check that relevance scores reorder matches, just this | 2156 // Again, check that relevance scores reorder matches, just this |
2136 // time with navigation matches. This also checks that with | 2157 // time with navigation matches. This also checks that with |
2137 // suggested relevance scores we allow multiple navsuggest results. | 2158 // suggested relevance scores we allow multiple navsuggest results. |
2138 // It's odd that navsuggest results that come from a keyword | 2159 // Note that navsuggest results that come from a keyword provider |
2139 // provider are marked as not a keyword result. I think this | 2160 // are marked as not a keyword result. (They don't go to a |
2140 // comes from them not going to a keyword search engine. | 2161 // keyword search engine.) |
2141 // TODO(mpearson): Investigate the implications (if any) of | |
2142 // tagging these results appropriately. If so, do it because it | |
2143 // makes more sense. | |
2144 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," | 2162 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," |
2145 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2163 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2146 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", | 2164 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", |
2147 { { "a", true, true }, | 2165 { { "a", true, true }, |
2148 { "d", true, false }, | 2166 { "d", true, false }, |
2149 { "c.com", false, false }, | 2167 { "c.com", false, false }, |
2150 { "b.com", false, false }, | 2168 { "b.com", false, false }, |
2151 { "k a", false, true }, | 2169 { "k a", false, false }, |
2152 kEmptyMatch }, | 2170 kEmptyMatch }, |
2153 std::string() }, | 2171 std::string() }, |
2154 | 2172 |
2155 // Without suggested relevance scores, we should only allow one | 2173 // Without suggested relevance scores, we should only allow one |
2156 // navsuggest result to be be displayed. | 2174 // navsuggest result to be be displayed. |
2157 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 2175 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
2158 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 2176 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
2159 { { "a", true, true }, | 2177 { { "a", true, true }, |
2160 { "b.com", false, false }, | 2178 { "b.com", false, false }, |
2161 { "k a", false, true }, | 2179 { "k a", false, false }, |
2162 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2180 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2163 std::string() }, | 2181 std::string() }, |
2164 | 2182 |
2165 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 2183 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
2166 // Negative values will have no effect; the calculated value will be used. | 2184 // Negative values will have no effect; the calculated value will be used. |
2167 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 2185 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
2168 "\"google:suggestrelevance\":[9998]}]", | 2186 "\"google:suggestrelevance\":[9998]}]", |
2169 { { "a", true, true }, | 2187 { { "a", true, true }, |
2170 { "a1", true, true }, | 2188 { "a1", true, true }, |
2171 { "k a", false, true }, | 2189 { "k a", false, false }, |
2172 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2190 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2173 std::string() }, | 2191 std::string() }, |
2174 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 2192 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
2175 "\"google:suggestrelevance\":[9999]}]", | 2193 "\"google:suggestrelevance\":[9999]}]", |
2176 { { "a1", true, true }, | 2194 { { "a1", true, true }, |
2177 { "a", true, true }, | 2195 { "a", true, true }, |
2178 { "k a", false, true }, | 2196 { "k a", false, false }, |
2179 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2197 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2180 "1" }, | 2198 "1" }, |
2181 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 2199 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
2182 "\"google:suggestrelevance\":[9999]}]", | 2200 "\"google:suggestrelevance\":[9999]}]", |
2183 { { "a1", true, true }, | 2201 { { "a1", true, true }, |
2184 { "k a", false, true }, | 2202 { "k a", false, false }, |
2185 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2203 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2186 "1" }, | 2204 "1" }, |
2187 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 2205 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
2188 "\"google:suggestrelevance\":[9999]}]", | 2206 "\"google:suggestrelevance\":[9999]}]", |
2189 { { "a1", true, true }, | 2207 { { "a1", true, true }, |
2190 { "a", true, true }, | 2208 { "a", true, true }, |
2191 { "k a", false, true }, | 2209 { "k a", false, false }, |
2192 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2210 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2193 "1" }, | 2211 "1" }, |
2194 { "[\"a\",[\"http://a.com\"],[],[]," | 2212 { "[\"a\",[\"http://a.com\"],[],[]," |
2195 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2213 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2196 "\"google:verbatimrelevance\":9999," | 2214 "\"google:verbatimrelevance\":9999," |
2197 "\"google:suggestrelevance\":[9998]}]", | 2215 "\"google:suggestrelevance\":[9998]}]", |
2198 { { "a", true, true }, | 2216 { { "a", true, true }, |
2199 { "a.com", false, true }, | 2217 { "a.com", false, false }, |
2200 { "k a", false, true }, | 2218 { "k a", false, false }, |
2201 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2219 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2202 std::string() }, | 2220 std::string() }, |
2203 | 2221 |
2204 // Ensure that both types of relevance scores reorder matches together. | 2222 // Ensure that both types of relevance scores reorder matches together. |
2205 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 2223 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
2206 "\"google:verbatimrelevance\":9998}]", | 2224 "\"google:verbatimrelevance\":9998}]", |
2207 { { "a1", true, true }, | 2225 { { "a1", true, true }, |
2208 { "a", true, true }, | 2226 { "a", true, true }, |
2209 { "a2", true, true }, | 2227 { "a2", true, true }, |
2210 { "k a", false, true }, | 2228 { "k a", false, false }, |
2211 kEmptyMatch, kEmptyMatch }, | 2229 kEmptyMatch, kEmptyMatch }, |
2212 "1" }, | 2230 "1" }, |
2213 | 2231 |
2214 // Check that non-inlinable matches may be ranked as the highest result | 2232 // Check that non-inlinable matches may be ranked as the highest result |
2215 // if there is at least one inlineable match. | 2233 // if there is at least one inlineable match. |
2216 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 2234 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
2217 { { "b", true, false }, | 2235 { { "b", true, false }, |
2218 { "a", true, true }, | 2236 { "a", true, true }, |
2219 { "k a", false, true }, | 2237 { "k a", false, false }, |
2220 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2238 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2221 std::string() }, | 2239 std::string() }, |
2222 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | |
2223 "\"google:verbatimrelevance\":0}]", | |
2224 { { "b", true, false }, | |
2225 { "k a", false, true }, | |
2226 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | |
2227 std::string() }, | |
2228 { "[\"a\",[\"http://b.com\"],[],[]," | 2240 { "[\"a\",[\"http://b.com\"],[],[]," |
2229 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2241 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2230 "\"google:suggestrelevance\":[9999]}]", | 2242 "\"google:suggestrelevance\":[9999]}]", |
2231 { { "b.com", false, false }, | 2243 { { "b.com", false, false }, |
2232 { "a", true, true }, | 2244 { "a", true, true }, |
2233 { "k a", false, true }, | 2245 { "k a", false, false }, |
2246 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | |
2247 std::string() }, | |
2248 // On the other hand, if there is no inlineable match, restore | |
2249 // the keyword verbatim. | |
Peter Kasting
2013/11/19 02:58:24
Nit: "...score"?
Mark P
2013/11/20 19:05:52
Not necessary, I think, but added word "score" any
| |
2250 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | |
2251 "\"google:verbatimrelevance\":0}]", | |
2252 { { "b", true, false }, | |
2253 { "a", true, true }, | |
2254 { "k a", false, false }, | |
2234 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2255 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2235 std::string() }, | 2256 std::string() }, |
2236 { "[\"a\",[\"http://b.com\"],[],[]," | 2257 { "[\"a\",[\"http://b.com\"],[],[]," |
2237 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2258 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2238 "\"google:suggestrelevance\":[9999]," | 2259 "\"google:suggestrelevance\":[9999]," |
2239 "\"google:verbatimrelevance\":0}]", | 2260 "\"google:verbatimrelevance\":0}]", |
2240 { { "b.com", false, false }, | 2261 { { "b.com", false, false }, |
2241 { "k a", false, true }, | 2262 { "a", true, true }, |
2242 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2263 { "k a", false, false }, |
2264 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | |
2243 std::string() }, | 2265 std::string() }, |
2244 | 2266 |
2245 // The top result does not have to score as highly as calculated | 2267 // The top result does not have to score as highly as calculated |
2246 // verbatim. i.e., there are no minimum score restrictions in | 2268 // verbatim. i.e., there are no minimum score restrictions in |
2247 // this provider. | 2269 // this provider. |
2248 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 2270 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
2249 { { "a1", true, true }, | 2271 { { "a1", true, true }, |
2250 { "k a", false, true }, | 2272 { "k a", false, false }, |
2251 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2273 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2252 "1" }, | 2274 "1" }, |
2253 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 2275 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", |
2254 { { "a1", true, true }, | 2276 { { "a1", true, true }, |
2255 { "k a", false, true }, | 2277 { "k a", false, false }, |
2256 { "a", true, true }, | 2278 { "a", true, true }, |
2257 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2279 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2258 "1" }, | 2280 "1" }, |
2259 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 2281 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," |
2260 "\"google:verbatimrelevance\":0}]", | 2282 "\"google:verbatimrelevance\":0}]", |
2261 { { "k a", false, true }, | 2283 { { "k a", false, false }, |
2262 { "a1", true, true }, | 2284 { "a1", true, true }, |
2263 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2285 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2264 std::string() }, | 2286 "1" }, |
2265 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 2287 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," |
2266 "\"google:verbatimrelevance\":0}]", | 2288 "\"google:verbatimrelevance\":0}]", |
2267 { | 2289 { |
2268 { "k a", false, true }, | 2290 { "k a", false, false }, |
2269 { "a2", true, true }, | 2291 { "a2", true, true }, |
2270 { "a1", true, true }, | 2292 { "a1", true, true }, |
2271 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2293 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2272 std::string() }, | 2294 "2" }, |
2273 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 2295 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," |
2274 "\"google:verbatimrelevance\":2}]", | 2296 "\"google:verbatimrelevance\":2}]", |
2275 { { "k a", false, true }, | 2297 { { "k a", false, false }, |
2276 { "a2", true, true }, | 2298 { "a2", true, true }, |
2277 { "a", true, true }, | 2299 { "a", true, true }, |
2278 { "a1", true, true }, | 2300 { "a1", true, true }, |
2279 kEmptyMatch, kEmptyMatch }, | 2301 kEmptyMatch, kEmptyMatch }, |
2280 std::string() }, | 2302 "2" }, |
2281 | 2303 |
2282 // Ensure that all suggestions are considered, regardless of order. | 2304 // Ensure that all suggestions are considered, regardless of order. |
2283 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 2305 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
2284 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 2306 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
2285 { { "a", true, true }, | 2307 { { "a", true, true }, |
2286 { "k a", false, true }, | 2308 { "k a", false, false }, |
2287 { "h", true, false }, | 2309 { "h", true, false }, |
2288 { "g", true, false }, | 2310 { "g", true, false }, |
2289 { "f", true, false }, | 2311 { "f", true, false }, |
2290 { "e", true, false } }, | 2312 { "e", true, false } }, |
2291 std::string() }, | 2313 std::string() }, |
2292 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 2314 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
2293 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 2315 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
2294 "\"http://h.com\"],[],[]," | 2316 "\"http://h.com\"],[],[]," |
2295 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 2317 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
2296 "\"NAVIGATION\", \"NAVIGATION\"," | 2318 "\"NAVIGATION\", \"NAVIGATION\"," |
2297 "\"NAVIGATION\", \"NAVIGATION\"," | 2319 "\"NAVIGATION\", \"NAVIGATION\"," |
2298 "\"NAVIGATION\"]," | 2320 "\"NAVIGATION\"]," |
2299 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 2321 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", |
2300 { { "a", true, true }, | 2322 { { "a", true, true }, |
2301 { "k a", false, true }, | 2323 { "k a", false, false }, |
2302 { "h.com", false, false }, | 2324 { "h.com", false, false }, |
2303 { "g.com", false, false }, | 2325 { "g.com", false, false }, |
2304 { "f.com", false, false }, | 2326 { "f.com", false, false }, |
2305 { "e.com", false, false } }, | 2327 { "e.com", false, false } }, |
2306 std::string() }, | 2328 std::string() }, |
2307 | 2329 |
2308 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 2330 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
2309 // Note that keyword suggestions by default (not in suggested relevance | 2331 // Note that keyword suggestions by default (not in suggested relevance |
2310 // mode) score more highly than the default verbatim. | 2332 // mode) score more highly than the default verbatim. |
2311 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 2333 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
2312 { { "a", true, true }, | 2334 { { "a", true, true }, |
2313 { "a1", true, true }, | 2335 { "a1", true, true }, |
2314 { "a2", true, true }, | 2336 { "a2", true, true }, |
2315 { "k a", false, true }, | 2337 { "k a", false, false }, |
2316 kEmptyMatch, kEmptyMatch }, | 2338 kEmptyMatch, kEmptyMatch }, |
2317 std::string() }, | 2339 std::string() }, |
2318 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 2340 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
2319 { { "a", true, true }, | 2341 { { "a", true, true }, |
2320 { "a1", true, true }, | 2342 { "a1", true, true }, |
2321 { "k a", false, true }, | 2343 { "k a", false, false }, |
2322 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2344 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2323 std::string() }, | 2345 std::string() }, |
2324 // In this case, ignoring the suggested relevance scores means we keep | 2346 // In this case, ignoring the suggested relevance scores means we keep |
2325 // only one navsuggest result. | 2347 // only one navsuggest result. |
2326 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2348 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2327 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2349 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2328 "\"google:suggestrelevance\":[1]}]", | 2350 "\"google:suggestrelevance\":[1]}]", |
2329 { { "a", true, true }, | 2351 { { "a", true, true }, |
2330 { "a1.com", false, true }, | 2352 { "a1.com", false, false }, |
2331 { "k a", false, true }, | 2353 { "k a", false, false }, |
2332 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2354 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2333 std::string() }, | 2355 std::string() }, |
2334 { "[\"a\",[\"http://a1.com\"],[],[]," | 2356 { "[\"a\",[\"http://a1.com\"],[],[]," |
2335 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2357 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2336 "\"google:suggestrelevance\":[9999, 1]}]", | 2358 "\"google:suggestrelevance\":[9999, 1]}]", |
2337 { { "a", true, true }, | 2359 { { "a", true, true }, |
2338 { "a1.com", false, true }, | 2360 { "a1.com", false, false }, |
2339 { "k a", false, true }, | 2361 { "k a", false, false }, |
2340 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2362 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2341 std::string() }, | 2363 std::string() }, |
2342 | 2364 |
2343 // Ensure that all 'verbatim' results are merged with their maximum score. | 2365 // Ensure that all 'verbatim' results are merged with their maximum score. |
2344 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 2366 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
2345 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 2367 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
2346 { { "a2", true, true }, | 2368 { { "a2", true, true }, |
2347 { "a", true, true }, | 2369 { "a", true, true }, |
2348 { "a1", true, true }, | 2370 { "a1", true, true }, |
2349 { "k a", false, true }, | 2371 { "k a", false, false }, |
2350 kEmptyMatch, kEmptyMatch }, | 2372 kEmptyMatch, kEmptyMatch }, |
2351 "2" }, | 2373 "2" }, |
2352 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 2374 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
2353 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 2375 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
2354 "\"google:verbatimrelevance\":0}]", | 2376 "\"google:verbatimrelevance\":0}]", |
2355 { { "a2", true, true }, | 2377 { { "a2", true, true }, |
2356 { "a", true, true }, | 2378 { "a", true, true }, |
2357 { "a1", true, true }, | 2379 { "a1", true, true }, |
2358 { "k a", false, true }, | 2380 { "k a", false, false }, |
2359 kEmptyMatch, kEmptyMatch }, | 2381 kEmptyMatch, kEmptyMatch }, |
2360 "2" }, | 2382 "2" }, |
2361 | 2383 |
2362 // Ensure that verbatim is always generated without other suggestions. | 2384 // Ensure that verbatim is always generated without other suggestions. |
2363 // TODO(mpearson): Ensure the value of verbatimrelevance is respected | 2385 // TODO(mpearson): Ensure the value of verbatimrelevance is respected |
2364 // (except when suggested relevances are ignored). | 2386 // (except when suggested relevances are ignored). |
2365 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 2387 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
2366 { { "k a", false, true }, | 2388 { { "k a", false, false }, |
2367 { "a", true, true }, | 2389 { "a", true, true }, |
2368 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2390 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2369 std::string() }, | 2391 std::string() }, |
2370 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 2392 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
2371 { { "a", true, true }, | 2393 { { "a", true, true }, |
2372 { "k a", false, true }, | 2394 { "k a", false, false }, |
2373 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2395 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2374 std::string() }, | 2396 std::string() }, |
2375 | 2397 |
2376 // Check that navsuggestions will be demoted below queries. | 2398 // In reorder mode, navsuggestions will not need to be demoted (because |
2377 // (Navsuggestions are not allowed to appear first.) In the process, | 2399 // they are marked as not allowed to be default match and will be |
2378 // make sure the navsuggestions still remain in the same order. | 2400 // reordered as necessary). |
2379 // First, check the situation where navsuggest scores more than verbatim | |
2380 // and there are no query suggestions. | |
2381 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2401 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2382 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2402 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2383 "\"google:verbatimrelevance\":9990," | 2403 "\"google:verbatimrelevance\":9990," |
2384 "\"google:suggestrelevance\":[9998, 9999]}]", | 2404 "\"google:suggestrelevance\":[9998, 9999]}]", |
2385 { { "a", true, true }, | 2405 { { "a2.com", false, false }, |
2386 { "a2.com", false, true }, | 2406 { "a1.com", false, false }, |
2387 { "a1.com", false, true }, | 2407 { "a", true, true }, |
2388 { "k a", false, true }, | 2408 { "k a", false, false }, |
2389 kEmptyMatch, kEmptyMatch }, | 2409 kEmptyMatch, kEmptyMatch }, |
2390 std::string() }, | 2410 std::string() }, |
2391 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2411 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2392 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2412 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2393 "\"google:verbatimrelevance\":9990," | 2413 "\"google:verbatimrelevance\":9990," |
2394 "\"google:suggestrelevance\":[9999, 9998]}]", | 2414 "\"google:suggestrelevance\":[9999, 9998]}]", |
2395 { { "a", true, true }, | 2415 { { "a1.com", false, false }, |
2396 { "a1.com", false, true }, | 2416 { "a2.com", false, false }, |
2397 { "a2.com", false, true }, | 2417 { "a", true, true }, |
2398 { "k a", false, true }, | 2418 { "k a", false, false }, |
2399 kEmptyMatch, kEmptyMatch }, | 2419 kEmptyMatch, kEmptyMatch }, |
2400 std::string() }, | 2420 std::string() }, |
2401 { "[\"a\",[\"https://a/\"],[],[]," | 2421 { "[\"a\",[\"https://a/\"],[],[]," |
2402 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2422 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
2403 "\"google:suggestrelevance\":[9999]}]", | 2423 "\"google:suggestrelevance\":[9999]}]", |
2404 { { "a", true, true }, | 2424 { { "https://a", false, false }, |
2405 { "https://a", false, true }, | 2425 { "a", true, true }, |
2406 { "k a", false, true }, | 2426 { "k a", false, false }, |
2407 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2427 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
2408 std::string() }, | 2428 std::string() }, |
2409 // Check when navsuggest scores more than verbatim and there is query | 2429 // Check when navsuggest scores more than verbatim and there is query |
2410 // suggestion but it scores lower. | 2430 // suggestion but it scores lower. |
2411 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2431 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2412 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2432 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2413 "\"google:verbatimrelevance\":9990," | 2433 "\"google:verbatimrelevance\":9990," |
2414 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", | 2434 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
2415 { { "a", true, true }, | 2435 { { "a2.com", false, false }, |
2416 { "a2.com", false, true }, | 2436 { "a1.com", false, false }, |
2417 { "a1.com", false, true }, | 2437 { "a", true, true }, |
2418 { "a3", true, true }, | 2438 { "a3", true, true }, |
2419 { "k a", false, true }, | 2439 { "k a", false, false }, |
2420 kEmptyMatch }, | 2440 kEmptyMatch }, |
2421 std::string() }, | 2441 std::string() }, |
2422 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2442 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2423 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2443 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2424 "\"google:verbatimrelevance\":9990," | 2444 "\"google:verbatimrelevance\":9990," |
2425 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", | 2445 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
2426 { { "a", true, true }, | 2446 { { "a1.com", false, false }, |
2427 { "a1.com", false, true }, | 2447 { "a2.com", false, false }, |
2428 { "a2.com", false, true }, | 2448 { "a", true, true }, |
2429 { "a3", true, true }, | 2449 { "a3", true, true }, |
2430 { "k a", false, true }, | 2450 { "k a", false, false }, |
2431 kEmptyMatch }, | 2451 kEmptyMatch }, |
2432 std::string() }, | 2452 std::string() }, |
2433 // Check when navsuggest scores more than a query suggestion. There is | 2453 // Check when navsuggest scores more than a query suggestion. There is |
2434 // a verbatim but it scores lower. | 2454 // a verbatim but it scores lower. |
2435 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2455 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2436 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2456 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2437 "\"google:verbatimrelevance\":9990," | 2457 "\"google:verbatimrelevance\":9990," |
2438 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 2458 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
2439 { { "a3", true, true }, | 2459 { { "a2.com", false, false }, |
2440 { "a2.com", false, true }, | 2460 { "a1.com", false, false }, |
2441 { "a1.com", false, true }, | 2461 { "a3", true, true }, |
2442 { "a", true, true }, | 2462 { "a", true, true }, |
2443 { "k a", false, true }, | 2463 { "k a", false, false }, |
2444 kEmptyMatch }, | 2464 kEmptyMatch }, |
2445 "3" }, | 2465 "3" }, |
2446 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2466 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2447 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2467 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2448 "\"google:verbatimrelevance\":9990," | 2468 "\"google:verbatimrelevance\":9990," |
2449 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 2469 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
2450 { { "a3", true, true }, | 2470 { { "a1.com", false, false }, |
2451 { "a1.com", false, true }, | 2471 { "a2.com", false, false }, |
2452 { "a2.com", false, true }, | 2472 { "a3", true, true }, |
2453 { "a", true, true }, | 2473 { "a", true, true }, |
2454 { "k a", false, true }, | 2474 { "k a", false, false }, |
2455 kEmptyMatch }, | 2475 kEmptyMatch }, |
2456 "3" }, | 2476 "3" }, |
2457 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2477 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2458 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2478 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2459 "\"google:verbatimrelevance\":0," | 2479 "\"google:verbatimrelevance\":0," |
2460 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 2480 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
2461 { { "a3", true, true }, | 2481 { { "a2.com", false, false }, |
2462 { "a2.com", false, true }, | 2482 { "a1.com", false, false }, |
2463 { "a1.com", false, true }, | 2483 { "a3", true, true }, |
2464 { "k a", false, true }, | 2484 { "k a", false, false }, |
2465 kEmptyMatch, kEmptyMatch }, | 2485 kEmptyMatch, kEmptyMatch }, |
2466 "3" }, | 2486 "3" }, |
2467 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2487 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2468 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2488 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2469 "\"google:verbatimrelevance\":0," | 2489 "\"google:verbatimrelevance\":0," |
2470 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 2490 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
2471 { { "a3", true, true }, | 2491 { { "a1.com", false, false }, |
2472 { "a1.com", false, true }, | 2492 { "a2.com", false, false }, |
2473 { "a2.com", false, true }, | 2493 { "a3", true, true }, |
2474 { "k a", false, true }, | 2494 { "k a", false, false }, |
2475 kEmptyMatch, kEmptyMatch }, | 2495 kEmptyMatch, kEmptyMatch }, |
2476 "3" }, | 2496 "3" }, |
2477 // Check when there is neither verbatim nor a query suggestion that, | 2497 // Check when there is neither verbatim nor a query suggestion that, |
2478 // because we can't demote navsuggestions below a query suggestion, | 2498 // because we can't demote navsuggestions below a query suggestion, |
2479 // we abandon suggested relevance scores entirely. One consequence is | 2499 // we restore the keyword verbatim match. |
Peter Kasting
2013/11/19 02:58:24
Nit: match -> score?
Mark P
2013/11/20 19:05:52
Done.
| |
2480 // that this means we restore the keyword verbatim match. Note | |
2481 // that in this case of abandoning suggested relevance scores, we still | |
2482 // keep the navsuggestions in the same order, but we revert to only allowing | |
2483 // one navigation to appear because the scores are completely local. | |
2484 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2500 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2485 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2501 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2486 "\"google:verbatimrelevance\":0," | 2502 "\"google:verbatimrelevance\":0," |
2487 "\"google:suggestrelevance\":[9998, 9999]}]", | 2503 "\"google:suggestrelevance\":[9998, 9999]}]", |
2488 { { "a", true, true }, | 2504 { { "a2.com", false, false }, |
2489 { "a2.com", false, true }, | 2505 { "a1.com", false, false }, |
2490 { "k a", false, true }, | 2506 { "a", true, true }, |
2491 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2507 { "k a", false, false }, |
2508 kEmptyMatch, kEmptyMatch }, | |
2492 std::string() }, | 2509 std::string() }, |
2493 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 2510 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
2494 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 2511 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
2495 "\"google:verbatimrelevance\":0," | 2512 "\"google:verbatimrelevance\":0," |
2496 "\"google:suggestrelevance\":[9999, 9998]}]", | 2513 "\"google:suggestrelevance\":[9999, 9998]}]", |
2497 { { "a", true, true }, | 2514 { { "a1.com", false, false }, |
2498 { "a1.com", false, true }, | 2515 { "a2.com", false, false }, |
2499 { "k a", false, true }, | 2516 { "a", true, true }, |
2500 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 2517 { "k a", false, false }, |
2518 kEmptyMatch, kEmptyMatch }, | |
2501 std::string() }, | 2519 std::string() }, |
2502 // More checks that everything works when it's not necessary to demote. | 2520 // More checks that everything works when it's not necessary to demote. |
2503 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2521 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2504 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2522 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2505 "\"google:verbatimrelevance\":9990," | 2523 "\"google:verbatimrelevance\":9990," |
2506 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", | 2524 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
2507 { { "a3", true, true }, | 2525 { { "a3", true, true }, |
2508 { "a2.com", false, true }, | 2526 { "a2.com", false, false }, |
2509 { "a1.com", false, true }, | 2527 { "a1.com", false, false }, |
2510 { "a", true, true }, | 2528 { "a", true, true }, |
2511 { "k a", false, true }, | 2529 { "k a", false, false }, |
2512 kEmptyMatch }, | 2530 kEmptyMatch }, |
2513 "3" }, | 2531 "3" }, |
2514 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 2532 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
2515 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 2533 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
2516 "\"google:verbatimrelevance\":9990," | 2534 "\"google:verbatimrelevance\":9990," |
2517 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 2535 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
2518 { { "a3", true, true }, | 2536 { { "a3", true, true }, |
2519 { "a1.com", false, true }, | 2537 { "a1.com", false, false }, |
2520 { "a2.com", false, true }, | 2538 { "a2.com", false, false }, |
2521 { "a", true, true }, | 2539 { "a", true, true }, |
2522 { "k a", false, true }, | 2540 { "k a", false, false }, |
2523 kEmptyMatch }, | 2541 kEmptyMatch }, |
2524 "3" }, | 2542 "3" }, |
2525 }; | 2543 }; |
2526 | 2544 |
2527 std::map<std::string, std::string> params; | 2545 std::map<std::string, std::string> params; |
2528 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) + | 2546 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) + |
2529 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled; | 2547 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled; |
2530 ASSERT_TRUE(chrome_variations::AssociateVariationParams( | 2548 ASSERT_TRUE(chrome_variations::AssociateVariationParams( |
2531 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params)); | 2549 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params)); |
2532 base::FieldTrialList::CreateFieldTrial( | 2550 base::FieldTrialList::CreateFieldTrial( |
(...skipping 17 matching lines...) Expand all Loading... | |
2550 SearchProvider::kKeywordProviderURLFetcherID); | 2568 SearchProvider::kKeywordProviderURLFetcherID); |
2551 ASSERT_TRUE(keyword_fetcher); | 2569 ASSERT_TRUE(keyword_fetcher); |
2552 keyword_fetcher->set_response_code(200); | 2570 keyword_fetcher->set_response_code(200); |
2553 keyword_fetcher->SetResponseString(cases[i].json); | 2571 keyword_fetcher->SetResponseString(cases[i].json); |
2554 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); | 2572 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); |
2555 keyword_fetcher = NULL; | 2573 keyword_fetcher = NULL; |
2556 RunTillProviderDone(); | 2574 RunTillProviderDone(); |
2557 | 2575 |
2558 const std::string description = "for input with json=" + cases[i].json; | 2576 const std::string description = "for input with json=" + cases[i].json; |
2559 const ACMatches& matches = provider_->matches(); | 2577 const ACMatches& matches = provider_->matches(); |
2560 // The top match must inline and score as highly as calculated verbatim. | |
2561 ASSERT_FALSE(matches.empty()); | 2578 ASSERT_FALSE(matches.empty()); |
2579 // Find the first match that's allowed to be the default match and check | |
2580 // its inline_autocompletion. | |
2581 ACMatches::const_iterator it = matches.begin(); | |
2582 while ((it != matches.end()) && !it->allowed_to_be_default_match) | |
2583 ++it; | |
2584 ASSERT_NE(matches.end(), it); | |
2562 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 2585 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
2563 matches[0].inline_autocompletion) << description; | 2586 it->inline_autocompletion) << description; |
2564 | 2587 |
2565 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 2588 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
2566 size_t j = 0; | 2589 size_t j = 0; |
2567 // Ensure that the returned matches equal the expectations. | 2590 // Ensure that the returned matches equal the expectations. |
2568 for (; j < matches.size(); ++j) { | 2591 for (; j < matches.size(); ++j) { |
2569 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), | 2592 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), |
2570 matches[j].contents) << description; | 2593 matches[j].contents) << description; |
2571 EXPECT_EQ(cases[i].matches[j].from_keyword, | 2594 EXPECT_EQ(cases[i].matches[j].from_keyword, |
2572 matches[j].keyword == ASCIIToUTF16("k")) << description; | 2595 matches[j].keyword == ASCIIToUTF16("k")) << description; |
2573 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, | 2596 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3946 AutocompleteInput::OTHER, &profile_)); | 3969 AutocompleteInput::OTHER, &profile_)); |
3947 encrypted_types.Remove(syncer::SESSIONS); | 3970 encrypted_types.Remove(syncer::SESSIONS); |
3948 service->OnEncryptedTypesChanged(encrypted_types, false); | 3971 service->OnEncryptedTypesChanged(encrypted_types, false); |
3949 | 3972 |
3950 // Check that there were no side effects from previous tests. | 3973 // Check that there were no side effects from previous tests. |
3951 EXPECT_TRUE(SearchProvider::CanSendURL( | 3974 EXPECT_TRUE(SearchProvider::CanSendURL( |
3952 GURL("http://www.google.com/search"), | 3975 GURL("http://www.google.com/search"), |
3953 GURL("https://www.google.com/complete/search"), &google_template_url, | 3976 GURL("https://www.google.com/complete/search"), &google_template_url, |
3954 AutocompleteInput::OTHER, &profile_)); | 3977 AutocompleteInput::OTHER, &profile_)); |
3955 } | 3978 } |
OLD | NEW |