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