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