Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More test fixes. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
16 #include "chrome/browser/autocomplete/autocomplete_controller.h" 16 #include "chrome/browser/autocomplete/autocomplete_controller.h"
17 #include "chrome/browser/autocomplete/autocomplete_input.h" 17 #include "chrome/browser/autocomplete/autocomplete_input.h"
18 #include "chrome/browser/autocomplete/autocomplete_match.h" 18 #include "chrome/browser/autocomplete/autocomplete_match.h"
19 #include "chrome/browser/autocomplete/autocomplete_provider.h" 19 #include "chrome/browser/autocomplete/autocomplete_provider.h"
20 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 20 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
21 #include "chrome/browser/autocomplete/history_url_provider.h" 21 #include "chrome/browser/autocomplete/history_url_provider.h"
22 #include "chrome/browser/history/history_service.h" 22 #include "chrome/browser/history/history_service.h"
23 #include "chrome/browser/history/history_service_factory.h" 23 #include "chrome/browser/history/history_service_factory.h"
24 #include "chrome/browser/omnibox/omnibox_field_trial.h" 24 #include "chrome/browser/omnibox/omnibox_field_trial.h"
25 #include "chrome/browser/search/search.h"
26 #include "chrome/browser/search_engines/template_url.h" 25 #include "chrome/browser/search_engines/template_url.h"
27 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
28 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
29 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/metrics/variations/variations_util.h" 29 #include "chrome/common/metrics/variations/variations_util.h"
31 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
32 #include "chrome/test/base/testing_browser_process.h" 31 #include "chrome/test/base/testing_browser_process.h"
33 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
34 #include "components/variations/entropy_provider.h" 33 #include "components/variations/entropy_provider.h"
35 #include "content/public/test/test_browser_thread_bundle.h" 34 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 // case to this test, please consider adding it to the tests in 906 // case to this test, please consider adding it to the tests in
908 // KeywordFetcherSuggestRelevance below. 907 // KeywordFetcherSuggestRelevance below.
909 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { 908 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) {
910 struct DefaultFetcherMatch { 909 struct DefaultFetcherMatch {
911 std::string contents; 910 std::string contents;
912 bool allowed_to_be_default_match; 911 bool allowed_to_be_default_match;
913 }; 912 };
914 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; 913 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false };
915 struct { 914 struct {
916 const std::string json; 915 const std::string json;
917 const DefaultFetcherMatch matches[4]; 916 const DefaultFetcherMatch matches[6];
918 const std::string inline_autocompletion; 917 const std::string inline_autocompletion;
919 } cases[] = { 918 } cases[] = {
920 // Ensure that suggestrelevance scores reorder matches. 919 // Ensure that suggestrelevance scores reorder matches.
921 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 920 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
922 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, 921 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch,
922 kEmptyMatch, kEmptyMatch },
923 std::string() }, 923 std::string() },
924 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 924 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
925 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 925 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
926 "\"google:suggestrelevance\":[1, 2]}]", 926 "\"google:suggestrelevance\":[1, 2]}]",
927 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, 927 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch,
928 kEmptyMatch, kEmptyMatch },
928 std::string() }, 929 std::string() },
929 930
930 // Without suggested relevance scores, we should only allow one 931 // Without suggested relevance scores, we should only allow one
931 // navsuggest result to be be displayed. 932 // navsuggest result to be be displayed.
932 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 933 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
933 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", 934 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]",
934 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 935 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
936 kEmptyMatch, kEmptyMatch },
935 std::string() }, 937 std::string() },
936 938
937 // Ensure that verbatimrelevance scores reorder or suppress verbatim. 939 // Ensure that verbatimrelevance scores reorder or suppress verbatim.
938 // Negative values will have no effect; the calculated value will be used. 940 // Negative values will have no effect; the calculated value will be used.
939 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," 941 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999,"
940 "\"google:suggestrelevance\":[9998]}]", 942 "\"google:suggestrelevance\":[9998]}]",
941 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, 943 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
944 kEmptyMatch },
942 std::string() }, 945 std::string() },
943 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," 946 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998,"
944 "\"google:suggestrelevance\":[9999]}]", 947 "\"google:suggestrelevance\":[9999]}]",
945 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 948 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
949 kEmptyMatch },
946 "1" }, 950 "1" },
947 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," 951 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0,"
948 "\"google:suggestrelevance\":[9999]}]", 952 "\"google:suggestrelevance\":[9999]}]",
949 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 953 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
954 kEmptyMatch },
950 "1" }, 955 "1" },
951 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," 956 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1,"
952 "\"google:suggestrelevance\":[9999]}]", 957 "\"google:suggestrelevance\":[9999]}]",
953 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 958 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
959 kEmptyMatch },
954 "1" }, 960 "1" },
955 { "[\"a\",[\"http://a.com\"],[],[]," 961 { "[\"a\",[\"http://a.com\"],[],[],"
956 "{\"google:suggesttype\":[\"NAVIGATION\"]," 962 "{\"google:suggesttype\":[\"NAVIGATION\"],"
957 "\"google:verbatimrelevance\":9999," 963 "\"google:verbatimrelevance\":9999,"
958 "\"google:suggestrelevance\":[9998]}]", 964 "\"google:suggestrelevance\":[9998]}]",
959 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, 965 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
966 kEmptyMatch },
960 std::string() }, 967 std::string() },
961 { "[\"a\",[\"http://a.com\"],[],[]," 968 { "[\"a\",[\"http://a.com\"],[],[],"
962 "{\"google:suggesttype\":[\"NAVIGATION\"]," 969 "{\"google:suggesttype\":[\"NAVIGATION\"],"
963 "\"google:verbatimrelevance\":9998," 970 "\"google:verbatimrelevance\":9998,"
964 "\"google:suggestrelevance\":[9999]}]", 971 "\"google:suggestrelevance\":[9999]}]",
965 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 972 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
973 kEmptyMatch },
966 ".com" }, 974 ".com" },
967 { "[\"a\",[\"http://a.com\"],[],[]," 975 { "[\"a\",[\"http://a.com\"],[],[],"
968 "{\"google:suggesttype\":[\"NAVIGATION\"]," 976 "{\"google:suggesttype\":[\"NAVIGATION\"],"
969 "\"google:verbatimrelevance\":0," 977 "\"google:verbatimrelevance\":0,"
970 "\"google:suggestrelevance\":[9999]}]", 978 "\"google:suggestrelevance\":[9999]}]",
971 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 979 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
980 kEmptyMatch },
972 ".com" }, 981 ".com" },
973 { "[\"a\",[\"http://a.com\"],[],[]," 982 { "[\"a\",[\"http://a.com\"],[],[],"
974 "{\"google:suggesttype\":[\"NAVIGATION\"]," 983 "{\"google:suggesttype\":[\"NAVIGATION\"],"
975 "\"google:verbatimrelevance\":-1," 984 "\"google:verbatimrelevance\":-1,"
976 "\"google:suggestrelevance\":[9999]}]", 985 "\"google:suggestrelevance\":[9999]}]",
977 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 986 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
987 kEmptyMatch },
978 ".com" }, 988 ".com" },
979 989
980 // Ensure that both types of relevance scores reorder matches together. 990 // Ensure that both types of relevance scores reorder matches together.
981 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," 991 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997],"
982 "\"google:verbatimrelevance\":9998}]", 992 "\"google:verbatimrelevance\":9998}]",
983 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, 993 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
994 kEmptyMatch },
984 "1" }, 995 "1" },
985 996
986 // Ensure that only inlinable matches may be ranked as the highest result. 997 // Ensure that only inlinable matches may be ranked as the highest result.
987 // Ignore all suggested relevance scores if this constraint is violated. 998 // Ignore all suggested relevance scores if this constraint is violated.
988 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", 999 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]",
989 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, 1000 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1001 kEmptyMatch },
990 std::string() }, 1002 std::string() },
991 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," 1003 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999],"
992 "\"google:verbatimrelevance\":0}]", 1004 "\"google:verbatimrelevance\":0}]",
993 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, 1005 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1006 kEmptyMatch },
994 std::string() }, 1007 std::string() },
995 { "[\"a\",[\"http://b.com\"],[],[]," 1008 { "[\"a\",[\"http://b.com\"],[],[],"
996 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1009 "{\"google:suggesttype\":[\"NAVIGATION\"],"
997 "\"google:suggestrelevance\":[9999]}]", 1010 "\"google:suggestrelevance\":[9999]}]",
998 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1011 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1012 kEmptyMatch, kEmptyMatch },
999 std::string() }, 1013 std::string() },
1000 { "[\"a\",[\"http://b.com\"],[],[]," 1014 { "[\"a\",[\"http://b.com\"],[],[],"
1001 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1015 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1002 "\"google:suggestrelevance\":[9999]," 1016 "\"google:suggestrelevance\":[9999],"
1003 "\"google:verbatimrelevance\":0}]", 1017 "\"google:verbatimrelevance\":0}]",
1004 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1018 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1019 kEmptyMatch, kEmptyMatch },
1005 std::string() }, 1020 std::string() },
1006 { "[\"a\",[\"https://a/\"],[],[]," 1021 { "[\"a\",[\"https://a/\"],[],[],"
1007 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1022 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1008 "\"google:suggestrelevance\":[9999]}]", 1023 "\"google:suggestrelevance\":[9999]}]",
1009 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1024 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch,
1025 kEmptyMatch, kEmptyMatch },
1010 std::string() }, 1026 std::string() },
1011 1027
1012 // Ensure that the top result is ranked as highly as calculated verbatim. 1028 // Ensure that the top result is ranked as highly as calculated verbatim.
1013 // Ignore the suggested verbatim relevance if this constraint is violated. 1029 // Ignore the suggested verbatim relevance if this constraint is violated.
1014 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1030 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1015 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1031 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1032 kEmptyMatch },
1016 std::string() }, 1033 std::string() },
1017 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1034 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1018 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1035 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1036 kEmptyMatch },
1019 std::string() }, 1037 std::string() },
1020 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1038 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
1021 "\"google:verbatimrelevance\":0}]", 1039 "\"google:verbatimrelevance\":0}]",
1022 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1040 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1041 kEmptyMatch },
1023 std::string() }, 1042 std::string() },
1024 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," 1043 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
1025 "\"google:verbatimrelevance\":0}]", 1044 "\"google:verbatimrelevance\":0}]",
1026 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, 1045 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1046 kEmptyMatch },
1027 std::string() }, 1047 std::string() },
1028 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," 1048 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
1029 "\"google:verbatimrelevance\":2}]", 1049 "\"google:verbatimrelevance\":2}]",
1030 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, 1050 { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1051 kEmptyMatch },
1031 std::string() }, 1052 std::string() },
1032 { "[\"a\",[\"http://a.com\"],[],[]," 1053 { "[\"a\",[\"http://a.com\"],[],[],"
1033 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1054 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1034 "\"google:suggestrelevance\":[1]," 1055 "\"google:suggestrelevance\":[1],"
1035 "\"google:verbatimrelevance\":0}]", 1056 "\"google:verbatimrelevance\":0}]",
1036 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, 1057 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1058 kEmptyMatch },
1037 std::string() }, 1059 std::string() },
1038 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1060 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1039 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1061 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1040 "\"google:suggestrelevance\":[1, 2]," 1062 "\"google:suggestrelevance\":[1, 2],"
1041 "\"google:verbatimrelevance\":0}]", 1063 "\"google:verbatimrelevance\":0}]",
1042 { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch }, 1064 { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch,
1065 kEmptyMatch, kEmptyMatch },
1043 std::string() }, 1066 std::string() },
1044 1067
1045 // Ensure that all suggestions are considered, regardless of order. 1068 // Ensure that all suggestions are considered, regardless of order.
1046 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," 1069 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[],"
1047 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1070 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1048 { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, 1071 { { "a", true }, { "h", false }, { "g", false }, { "f", false },
1072 {"e", false }, {"d", false } },
1049 std::string() }, 1073 std::string() },
1050 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," 1074 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\","
1051 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," 1075 "\"http://e.com\", \"http://f.com\", \"http://g.com\","
1052 "\"http://h.com\"],[],[]," 1076 "\"http://h.com\"],[],[],"
1053 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," 1077 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\","
1054 "\"NAVIGATION\", \"NAVIGATION\"," 1078 "\"NAVIGATION\", \"NAVIGATION\","
1055 "\"NAVIGATION\", \"NAVIGATION\"," 1079 "\"NAVIGATION\", \"NAVIGATION\","
1056 "\"NAVIGATION\"]," 1080 "\"NAVIGATION\"],"
1057 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1081 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1058 { { "a", true }, { "h.com", false }, { "g.com", false }, 1082 { { "a", true }, { "h.com", false }, { "g.com", false },
1059 { "f.com", false } }, 1083 { "f.com", false }, {"e.com", false }, {"d.com", false } },
1060 std::string() }, 1084 std::string() },
1061 1085
1062 // Ensure that incorrectly sized suggestion relevance lists are ignored. 1086 // Ensure that incorrectly sized suggestion relevance lists are ignored.
1063 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", 1087 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]",
1064 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, 1088 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1089 kEmptyMatch },
1065 std::string() }, 1090 std::string() },
1066 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", 1091 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]",
1067 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1092 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1093 kEmptyMatch },
1068 std::string() }, 1094 std::string() },
1069 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1095 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1070 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1096 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1071 "\"google:suggestrelevance\":[1]}]", 1097 "\"google:suggestrelevance\":[1]}]",
1072 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1098 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1099 kEmptyMatch, kEmptyMatch },
1073 std::string() }, 1100 std::string() },
1074 { "[\"a\",[\"http://a1.com\"],[],[]," 1101 { "[\"a\",[\"http://a1.com\"],[],[],"
1075 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1102 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1076 "\"google:suggestrelevance\":[9999, 1]}]", 1103 "\"google:suggestrelevance\":[9999, 1]}]",
1077 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1104 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1105 kEmptyMatch, kEmptyMatch },
1078 std::string() }, 1106 std::string() },
1079 1107
1080 // Ensure that all 'verbatim' results are merged with their maximum score. 1108 // Ensure that all 'verbatim' results are merged with their maximum score.
1081 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1109 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1082 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1110 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1083 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1111 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1112 kEmptyMatch },
1084 "2" }, 1113 "2" },
1085 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1114 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1086 "{\"google:suggestrelevance\":[9998, 9997, 9999]," 1115 "{\"google:suggestrelevance\":[9998, 9997, 9999],"
1087 "\"google:verbatimrelevance\":0}]", 1116 "\"google:verbatimrelevance\":0}]",
1088 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1117 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1118 kEmptyMatch },
1089 "2" }, 1119 "2" },
1090 1120
1091 // Ensure that verbatim is always generated without other suggestions. 1121 // Ensure that verbatim is always generated without other suggestions.
1092 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). 1122 // TODO(msw): Ensure verbatimrelevance is respected (except suppression).
1093 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1123 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1094 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1124 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1125 kEmptyMatch },
1095 std::string() }, 1126 std::string() },
1096 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1127 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1097 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1128 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1129 kEmptyMatch },
1098 std::string() }, 1130 std::string() },
1099 }; 1131 };
1100 1132
1101 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { 1133 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
1102 QueryForInput(ASCIIToUTF16("a"), false, false); 1134 QueryForInput(ASCIIToUTF16("a"), false, false);
1103 net::TestURLFetcher* fetcher = 1135 net::TestURLFetcher* fetcher =
1104 test_factory_.GetFetcherByID( 1136 test_factory_.GetFetcherByID(
1105 SearchProvider::kDefaultProviderURLFetcherID); 1137 SearchProvider::kDefaultProviderURLFetcherID);
1106 ASSERT_TRUE(fetcher); 1138 ASSERT_TRUE(fetcher);
1107 fetcher->set_response_code(200); 1139 fetcher->set_response_code(200);
(...skipping 30 matching lines...) Expand all
1138 // causes SearchProvider to allow some constraints to be violated that it 1170 // causes SearchProvider to allow some constraints to be violated that it
1139 // wouldn't normally because the omnibox will fix the problems later. 1171 // wouldn't normally because the omnibox will fix the problems later.
1140 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { 1172 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) {
1141 struct DefaultFetcherMatch { 1173 struct DefaultFetcherMatch {
1142 std::string contents; 1174 std::string contents;
1143 bool allowed_to_be_default_match; 1175 bool allowed_to_be_default_match;
1144 }; 1176 };
1145 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; 1177 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false };
1146 struct { 1178 struct {
1147 const std::string json; 1179 const std::string json;
1148 const DefaultFetcherMatch matches[4]; 1180 const DefaultFetcherMatch matches[6];
1149 const std::string inline_autocompletion; 1181 const std::string inline_autocompletion;
1150 } cases[] = { 1182 } cases[] = {
1151 // Ensure that suggestrelevance scores reorder matches. 1183 // Ensure that suggestrelevance scores reorder matches.
1152 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 1184 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
1153 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, 1185 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, kEmptyMatch,
1186 kEmptyMatch },
1154 std::string() }, 1187 std::string() },
1155 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1188 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1156 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1189 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1157 "\"google:suggestrelevance\":[1, 2]}]", 1190 "\"google:suggestrelevance\":[1, 2]}]",
1158 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, 1191 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch,
1192 kEmptyMatch, kEmptyMatch },
1159 std::string() }, 1193 std::string() },
1160 1194
1161 // Without suggested relevance scores, we should only allow one 1195 // Without suggested relevance scores, we should only allow one
1162 // navsuggest result to be be displayed. 1196 // navsuggest result to be be displayed.
1163 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1197 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1164 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", 1198 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]",
1165 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1199 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1200 kEmptyMatch, kEmptyMatch },
1166 std::string() }, 1201 std::string() },
1167 1202
1168 // Ensure that verbatimrelevance scores reorder or suppress verbatim. 1203 // Ensure that verbatimrelevance scores reorder or suppress verbatim.
1169 // Negative values will have no effect; the calculated value will be used. 1204 // Negative values will have no effect; the calculated value will be used.
1170 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," 1205 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999,"
1171 "\"google:suggestrelevance\":[9998]}]", 1206 "\"google:suggestrelevance\":[9998]}]",
1172 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1207 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1208 kEmptyMatch },
1173 std::string() }, 1209 std::string() },
1174 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," 1210 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998,"
1175 "\"google:suggestrelevance\":[9999]}]", 1211 "\"google:suggestrelevance\":[9999]}]",
1176 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1212 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1213 kEmptyMatch },
1177 "1" }, 1214 "1" },
1178 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," 1215 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0,"
1179 "\"google:suggestrelevance\":[9999]}]", 1216 "\"google:suggestrelevance\":[9999]}]",
1180 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1217 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1218 kEmptyMatch },
1181 "1" }, 1219 "1" },
1182 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," 1220 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1,"
1183 "\"google:suggestrelevance\":[9999]}]", 1221 "\"google:suggestrelevance\":[9999]}]",
1184 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1222 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1223 kEmptyMatch },
1185 "1" }, 1224 "1" },
1186 { "[\"a\",[\"http://a.com\"],[],[]," 1225 { "[\"a\",[\"http://a.com\"],[],[],"
1187 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1226 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1188 "\"google:verbatimrelevance\":9999," 1227 "\"google:verbatimrelevance\":9999,"
1189 "\"google:suggestrelevance\":[9998]}]", 1228 "\"google:suggestrelevance\":[9998]}]",
1190 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, 1229 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1230 kEmptyMatch },
1191 std::string() }, 1231 std::string() },
1192 { "[\"a\",[\"http://a.com\"],[],[]," 1232 { "[\"a\",[\"http://a.com\"],[],[],"
1193 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1233 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1194 "\"google:verbatimrelevance\":9998," 1234 "\"google:verbatimrelevance\":9998,"
1195 "\"google:suggestrelevance\":[9999]}]", 1235 "\"google:suggestrelevance\":[9999]}]",
1196 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1236 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1237 kEmptyMatch },
1197 ".com" }, 1238 ".com" },
1198 { "[\"a\",[\"http://a.com\"],[],[]," 1239 { "[\"a\",[\"http://a.com\"],[],[],"
1199 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1240 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1200 "\"google:verbatimrelevance\":0," 1241 "\"google:verbatimrelevance\":0,"
1201 "\"google:suggestrelevance\":[9999]}]", 1242 "\"google:suggestrelevance\":[9999]}]",
1202 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1243 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1244 kEmptyMatch },
1203 ".com" }, 1245 ".com" },
1204 { "[\"a\",[\"http://a.com\"],[],[]," 1246 { "[\"a\",[\"http://a.com\"],[],[],"
1205 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1247 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1206 "\"google:verbatimrelevance\":-1," 1248 "\"google:verbatimrelevance\":-1,"
1207 "\"google:suggestrelevance\":[9999]}]", 1249 "\"google:suggestrelevance\":[9999]}]",
1208 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1250 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1251 kEmptyMatch },
1209 ".com" }, 1252 ".com" },
1210 1253
1211 // Ensure that both types of relevance scores reorder matches together. 1254 // Ensure that both types of relevance scores reorder matches together.
1212 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," 1255 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997],"
1213 "\"google:verbatimrelevance\":9998}]", 1256 "\"google:verbatimrelevance\":9998}]",
1214 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, 1257 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1258 kEmptyMatch },
1215 "1" }, 1259 "1" },
1216 1260
1217 // Allow non-inlineable matches to be the highest-scoring match but, 1261 // Allow non-inlineable matches to be the highest-scoring match but,
1218 // if the result set lacks a single inlineable result, abandon suggested 1262 // if the result set lacks a single inlineable result, abandon suggested
1219 // relevance scores entirely. 1263 // relevance scores entirely.
1220 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", 1264 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]",
1221 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1265 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1266 kEmptyMatch },
1222 std::string() }, 1267 std::string() },
1223 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," 1268 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999],"
1224 "\"google:verbatimrelevance\":0}]", 1269 "\"google:verbatimrelevance\":0}]",
1225 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, 1270 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1271 kEmptyMatch },
1226 std::string() }, 1272 std::string() },
1227 { "[\"a\",[\"http://b.com\"],[],[]," 1273 { "[\"a\",[\"http://b.com\"],[],[],"
1228 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1274 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1229 "\"google:suggestrelevance\":[9999]}]", 1275 "\"google:suggestrelevance\":[9999]}]",
1230 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1276 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch,
1277 kEmptyMatch, kEmptyMatch },
1231 std::string() }, 1278 std::string() },
1232 { "[\"a\",[\"http://b.com\"],[],[]," 1279 { "[\"a\",[\"http://b.com\"],[],[],"
1233 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1280 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1234 "\"google:suggestrelevance\":[9999]," 1281 "\"google:suggestrelevance\":[9999],"
1235 "\"google:verbatimrelevance\":0}]", 1282 "\"google:verbatimrelevance\":0}]",
1236 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1283 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch,
1284 kEmptyMatch, kEmptyMatch },
1237 std::string() }, 1285 std::string() },
1238 1286
1239 // Allow low-scoring matches. 1287 // Allow low-scoring matches.
1240 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1288 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1241 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1289 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1290 kEmptyMatch },
1242 "1" }, 1291 "1" },
1243 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1292 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1244 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, 1293 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1294 kEmptyMatch },
1245 "1" }, 1295 "1" },
1246 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1296 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
1247 "\"google:verbatimrelevance\":0}]", 1297 "\"google:verbatimrelevance\":0}]",
1248 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1298 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1299 kEmptyMatch },
1249 "1" }, 1300 "1" },
1250 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," 1301 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
1251 "\"google:verbatimrelevance\":0}]", 1302 "\"google:verbatimrelevance\":0}]",
1252 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1303 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1304 kEmptyMatch },
1253 "2" }, 1305 "2" },
1254 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," 1306 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
1255 "\"google:verbatimrelevance\":2}]", 1307 "\"google:verbatimrelevance\":2}]",
1256 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1308 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1309 kEmptyMatch },
1257 "2" }, 1310 "2" },
1258 { "[\"a\",[\"http://a.com\"],[],[]," 1311 { "[\"a\",[\"http://a.com\"],[],[],"
1259 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1312 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1260 "\"google:suggestrelevance\":[1]," 1313 "\"google:suggestrelevance\":[1],"
1261 "\"google:verbatimrelevance\":0}]", 1314 "\"google:verbatimrelevance\":0}]",
1262 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1315 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1316 kEmptyMatch },
1263 ".com" }, 1317 ".com" },
1264 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1318 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1265 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1319 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1266 "\"google:suggestrelevance\":[1, 2]," 1320 "\"google:suggestrelevance\":[1, 2],"
1267 "\"google:verbatimrelevance\":0}]", 1321 "\"google:verbatimrelevance\":0}]",
1268 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1322 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1323 kEmptyMatch, kEmptyMatch },
1269 "2.com" }, 1324 "2.com" },
1270 1325
1271 // Ensure that all suggestions are considered, regardless of order. 1326 // Ensure that all suggestions are considered, regardless of order.
1272 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," 1327 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[],"
1273 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1328 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1274 { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, 1329 { { "a", true }, { "h", false }, { "g", false }, { "f", false },
1330 { "e", false }, { "d", false } },
1275 std::string() }, 1331 std::string() },
1276 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," 1332 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\","
1277 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," 1333 "\"http://e.com\", \"http://f.com\", \"http://g.com\","
1278 "\"http://h.com\"],[],[]," 1334 "\"http://h.com\"],[],[],"
1279 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," 1335 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\","
1280 "\"NAVIGATION\", \"NAVIGATION\"," 1336 "\"NAVIGATION\", \"NAVIGATION\","
1281 "\"NAVIGATION\", \"NAVIGATION\"," 1337 "\"NAVIGATION\", \"NAVIGATION\","
1282 "\"NAVIGATION\"]," 1338 "\"NAVIGATION\"],"
1283 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1339 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1284 { { "a", true }, { "h.com", false }, { "g.com", false }, 1340 { { "a", true }, { "h.com", false }, { "g.com", false },
1285 { "f.com", false } }, 1341 { "f.com", false }, { "e.com", false }, { "d.com", false } },
1286 std::string() }, 1342 std::string() },
1287 1343
1288 // Ensure that incorrectly sized suggestion relevance lists are ignored. 1344 // Ensure that incorrectly sized suggestion relevance lists are ignored.
1289 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", 1345 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]",
1290 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, 1346 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch,
1347 kEmptyMatch },
1291 std::string() }, 1348 std::string() },
1292 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", 1349 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]",
1293 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1350 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1351 kEmptyMatch },
1294 std::string() }, 1352 std::string() },
1295 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1353 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1296 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1354 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1297 "\"google:suggestrelevance\":[1]}]", 1355 "\"google:suggestrelevance\":[1]}]",
1298 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1356 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1357 kEmptyMatch, kEmptyMatch },
1299 std::string() }, 1358 std::string() },
1300 { "[\"a\",[\"http://a1.com\"],[],[]," 1359 { "[\"a\",[\"http://a1.com\"],[],[],"
1301 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1360 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1302 "\"google:suggestrelevance\":[9999, 1]}]", 1361 "\"google:suggestrelevance\":[9999, 1]}]",
1303 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, 1362 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch,
1363 kEmptyMatch, kEmptyMatch },
1304 std::string() }, 1364 std::string() },
1305 1365
1306 // Ensure that all 'verbatim' results are merged with their maximum score. 1366 // Ensure that all 'verbatim' results are merged with their maximum score.
1307 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1367 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1308 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1368 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1309 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1369 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1370 kEmptyMatch },
1310 "2" }, 1371 "2" },
1311 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1372 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1312 "{\"google:suggestrelevance\":[9998, 9997, 9999]," 1373 "{\"google:suggestrelevance\":[9998, 9997, 9999],"
1313 "\"google:verbatimrelevance\":0}]", 1374 "\"google:verbatimrelevance\":0}]",
1314 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, 1375 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch,
1376 kEmptyMatch },
1315 "2" }, 1377 "2" },
1316 1378
1317 // Ensure that verbatim is always generated without other suggestions. 1379 // Ensure that verbatim is always generated without other suggestions.
1318 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). 1380 // TODO(msw): Ensure verbatimrelevance is respected (except suppression).
1319 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1381 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1320 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1382 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1383 kEmptyMatch },
1321 std::string() }, 1384 std::string() },
1322 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1385 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1323 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1386 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch,
1387 kEmptyMatch },
1324 std::string() }, 1388 std::string() },
1325 }; 1389 };
1326 1390
1327 std::map<std::string, std::string> params; 1391 std::map<std::string, std::string> params;
1328 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) + 1392 params[std::string(OmniboxFieldTrial::kReorderForLegalDefaultMatchRule) +
1329 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled; 1393 ":*:*"] = OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled;
1330 ASSERT_TRUE(chrome_variations::AssociateVariationParams( 1394 ASSERT_TRUE(chrome_variations::AssociateVariationParams(
1331 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params)); 1395 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params));
1332 base::FieldTrialList::CreateFieldTrial( 1396 base::FieldTrialList::CreateFieldTrial(
1333 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); 1397 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 // appropriate to add to DefaultFetcherSuggestRelevance as well. 1439 // appropriate to add to DefaultFetcherSuggestRelevance as well.
1376 TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { 1440 TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) {
1377 struct KeywordFetcherMatch { 1441 struct KeywordFetcherMatch {
1378 std::string contents; 1442 std::string contents;
1379 bool from_keyword; 1443 bool from_keyword;
1380 bool allowed_to_be_default_match; 1444 bool allowed_to_be_default_match;
1381 }; 1445 };
1382 const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false }; 1446 const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false };
1383 struct { 1447 struct {
1384 const std::string json; 1448 const std::string json;
1385 const KeywordFetcherMatch matches[5]; 1449 const KeywordFetcherMatch matches[6];
1386 const std::string inline_autocompletion; 1450 const std::string inline_autocompletion;
1387 } cases[] = { 1451 } cases[] = {
1388 // Ensure that suggest relevance scores reorder matches and that 1452 // Ensure that suggest relevance scores reorder matches and that
1389 // the keyword verbatim (lacking a suggested verbatim score) beats 1453 // the keyword verbatim (lacking a suggested verbatim score) beats
1390 // the default provider verbatim. 1454 // the default provider verbatim.
1391 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 1455 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
1392 { { "a", true, true }, 1456 { { "a", true, true },
1393 { "k a", false, true }, 1457 { "k a", false, true },
1394 { "c", true, false }, 1458 { "c", true, false },
1395 { "b", true, false }, 1459 { "b", true, false },
1396 kEmptyMatch }, 1460 kEmptyMatch, kEmptyMatch },
1397 std::string() }, 1461 std::string() },
1398 // Again, check that relevance scores reorder matches, just this 1462 // Again, check that relevance scores reorder matches, just this
1399 // time with navigation matches. This also checks that with 1463 // time with navigation matches. This also checks that with
1400 // suggested relevance scores we allow multiple navsuggest results. 1464 // suggested relevance scores we allow multiple navsuggest results.
1401 // It's odd that navsuggest results that come from a keyword 1465 // It's odd that navsuggest results that come from a keyword
1402 // provider are marked as not a keyword result. I think this 1466 // provider are marked as not a keyword result. I think this
1403 // comes from them not going to a keyword search engine). 1467 // comes from them not going to a keyword search engine).
1404 // TODO(mpearson): Investigate the implications (if any) of 1468 // TODO(mpearson): Investigate the implications (if any) of
1405 // tagging these results appropriately. If so, do it because it 1469 // tagging these results appropriately. If so, do it because it
1406 // makes more sense. 1470 // makes more sense.
1407 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[]," 1471 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"d\"],[],[],"
1408 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1472 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1409 "\"google:suggestrelevance\":[1301, 1302, 1303]}]", 1473 "\"google:suggestrelevance\":[1301, 1302, 1303]}]",
1410 { { "a", true, true }, 1474 { { "a", true, true },
1411 { "d", true, false }, 1475 { "d", true, false },
1412 { "c.com", false, false }, 1476 { "c.com", false, false },
1413 { "b.com", false, false }, 1477 { "b.com", false, false },
1414 { "k a", false, true }, }, 1478 { "k a", false, true },
1479 kEmptyMatch },
1415 std::string() }, 1480 std::string() },
1416 1481
1417 // Without suggested relevance scores, we should only allow one 1482 // Without suggested relevance scores, we should only allow one
1418 // navsuggest result to be be displayed. 1483 // navsuggest result to be be displayed.
1419 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," 1484 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[],"
1420 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", 1485 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]",
1421 { { "a", true, true }, 1486 { { "a", true, true },
1422 { "b.com", false, false }, 1487 { "b.com", false, false },
1423 { "k a", false, true }, 1488 { "k a", false, true },
1424 kEmptyMatch, kEmptyMatch }, 1489 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1425 std::string() }, 1490 std::string() },
1426 1491
1427 // Ensure that verbatimrelevance scores reorder or suppress verbatim. 1492 // Ensure that verbatimrelevance scores reorder or suppress verbatim.
1428 // Negative values will have no effect; the calculated value will be used. 1493 // Negative values will have no effect; the calculated value will be used.
1429 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," 1494 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999,"
1430 "\"google:suggestrelevance\":[9998]}]", 1495 "\"google:suggestrelevance\":[9998]}]",
1431 { { "a", true, true }, 1496 { { "a", true, true },
1432 { "a1", true, true }, 1497 { "a1", true, true },
1433 { "k a", false, true }, 1498 { "k a", false, true },
1434 kEmptyMatch, kEmptyMatch }, 1499 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1435 std::string() }, 1500 std::string() },
1436 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," 1501 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998,"
1437 "\"google:suggestrelevance\":[9999]}]", 1502 "\"google:suggestrelevance\":[9999]}]",
1438 { { "a1", true, true }, 1503 { { "a1", true, true },
1439 { "a", true, true }, 1504 { "a", true, true },
1440 { "k a", false, true }, 1505 { "k a", false, true },
1441 kEmptyMatch, kEmptyMatch }, 1506 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1442 "1" }, 1507 "1" },
1443 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," 1508 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0,"
1444 "\"google:suggestrelevance\":[9999]}]", 1509 "\"google:suggestrelevance\":[9999]}]",
1445 { { "a1", true, true }, 1510 { { "a1", true, true },
1446 { "k a", false, true }, 1511 { "k a", false, true },
1447 kEmptyMatch, kEmptyMatch, kEmptyMatch }, 1512 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch },
1448 "1" }, 1513 "1" },
1449 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," 1514 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1,"
1450 "\"google:suggestrelevance\":[9999]}]", 1515 "\"google:suggestrelevance\":[9999]}]",
1451 { { "a1", true, true }, 1516 { { "a1", true, true },
1452 { "a", true, true }, 1517 { "a", true, true },
1453 { "k a", false, true }, 1518 { "k a", false, true },
1454 kEmptyMatch, kEmptyMatch }, 1519 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1455 "1" }, 1520 "1" },
1456 { "[\"a\",[\"http://a.com\"],[],[]," 1521 { "[\"a\",[\"http://a.com\"],[],[],"
1457 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1522 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1458 "\"google:verbatimrelevance\":9999," 1523 "\"google:verbatimrelevance\":9999,"
1459 "\"google:suggestrelevance\":[9998]}]", 1524 "\"google:suggestrelevance\":[9998]}]",
1460 { { "a", true, true }, 1525 { { "a", true, true },
1461 { "a.com", false, true }, 1526 { "a.com", false, true },
1462 { "k a", false, true }, 1527 { "k a", false, true },
1463 kEmptyMatch, kEmptyMatch }, 1528 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1464 std::string() }, 1529 std::string() },
1465 1530
1466 // Ensure that both types of relevance scores reorder matches together. 1531 // Ensure that both types of relevance scores reorder matches together.
1467 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," 1532 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997],"
1468 "\"google:verbatimrelevance\":9998}]", 1533 "\"google:verbatimrelevance\":9998}]",
1469 { { "a1", true, true }, 1534 { { "a1", true, true },
1470 { "a", true, true }, 1535 { "a", true, true },
1471 { "a2", true, true }, 1536 { "a2", true, true },
1472 { "k a", false, true }, 1537 { "k a", false, true },
1473 kEmptyMatch }, 1538 kEmptyMatch, kEmptyMatch },
1474 "1" }, 1539 "1" },
1475 1540
1476 // Ensure that only inlinable matches may be ranked as the highest result. 1541 // Ensure that only inlinable matches may be ranked as the highest result.
1477 // Ignore all suggested relevance scores if this constraint is violated. 1542 // Ignore all suggested relevance scores if this constraint is violated.
1478 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", 1543 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]",
1479 { { "a", true, true }, 1544 { { "a", true, true },
1480 { "b", true, false }, 1545 { "b", true, false },
1481 { "k a", false, true }, 1546 { "k a", false, true },
1482 kEmptyMatch, kEmptyMatch }, 1547 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1483 std::string() }, 1548 std::string() },
1484 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," 1549 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999],"
1485 "\"google:verbatimrelevance\":0}]", 1550 "\"google:verbatimrelevance\":0}]",
1486 { { "a", true, true }, 1551 { { "a", true, true },
1487 { "b", true, false }, 1552 { "b", true, false },
1488 { "k a", false, true }, 1553 { "k a", false, true },
1489 kEmptyMatch, kEmptyMatch }, 1554 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1490 std::string() }, 1555 std::string() },
1491 { "[\"a\",[\"http://b.com\"],[],[]," 1556 { "[\"a\",[\"http://b.com\"],[],[],"
1492 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1557 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1493 "\"google:suggestrelevance\":[9999]}]", 1558 "\"google:suggestrelevance\":[9999]}]",
1494 { { "a", true, true }, 1559 { { "a", true, true },
1495 { "b.com", false, false }, 1560 { "b.com", false, false },
1496 { "k a", false, true }, 1561 { "k a", false, true },
1497 kEmptyMatch, kEmptyMatch }, 1562 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1498 std::string() }, 1563 std::string() },
1499 { "[\"a\",[\"http://b.com\"],[],[]," 1564 { "[\"a\",[\"http://b.com\"],[],[],"
1500 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1565 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1501 "\"google:suggestrelevance\":[9999]," 1566 "\"google:suggestrelevance\":[9999],"
1502 "\"google:verbatimrelevance\":0}]", 1567 "\"google:verbatimrelevance\":0}]",
1503 { { "a", true, true }, 1568 { { "a", true, true },
1504 { "b.com", false, false }, 1569 { "b.com", false, false },
1505 { "k a", false, true }, 1570 { "k a", false, true },
1506 kEmptyMatch, kEmptyMatch }, 1571 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1507 std::string() }, 1572 std::string() },
1508 1573
1509 // Ensure that the top result is ranked as highly as calculated verbatim. 1574 // Ensure that the top result is ranked as highly as calculated verbatim.
1510 // Ignore the suggested verbatim relevance if this constraint is violated. 1575 // Ignore the suggested verbatim relevance if this constraint is violated.
1511 // Note that keyword suggestions by default (not in suggested relevance 1576 // Note that keyword suggestions by default (not in suggested relevance
1512 // mode) score more highly than the default verbatim. 1577 // mode) score more highly than the default verbatim.
1513 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1578 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1514 { { "a", true, true }, 1579 { { "a", true, true },
1515 { "a1", true, true }, 1580 { "a1", true, true },
1516 { "k a", false, true }, 1581 { "k a", false, true },
1517 kEmptyMatch, kEmptyMatch }, 1582 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1518 std::string() }, 1583 std::string() },
1519 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1584 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1520 { { "a", true, true }, 1585 { { "a", true, true },
1521 { "a1", true, true }, 1586 { "a1", true, true },
1522 { "k a", false, true }, 1587 { "k a", false, true },
1523 kEmptyMatch, kEmptyMatch}, 1588 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1524 std::string() }, 1589 std::string() },
1525 // Continuing the same category of tests, but make sure we keep the 1590 // Continuing the same category of tests, but make sure we keep the
1526 // suggested relevance scores even as we discard the verbatim relevance 1591 // suggested relevance scores even as we discard the verbatim relevance
1527 // scores. 1592 // scores.
1528 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1593 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
1529 "\"google:verbatimrelevance\":0}]", 1594 "\"google:verbatimrelevance\":0}]",
1530 { { "a", true, true }, 1595 { { "a", true, true },
1531 { "k a", false, true }, 1596 { "k a", false, true },
1532 { "a1", true, true }, 1597 { "a1", true, true },
1533 kEmptyMatch, kEmptyMatch}, 1598 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1534 std::string() }, 1599 std::string() },
1535 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," 1600 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2],"
1536 "\"google:verbatimrelevance\":0}]", 1601 "\"google:verbatimrelevance\":0}]",
1537 { { "a", true, true }, 1602 { { "a", true, true },
1538 { "k a", false, true }, 1603 { "k a", false, true },
1539 { "a2", true, true }, 1604 { "a2", true, true },
1540 { "a1", true, true }, 1605 { "a1", true, true },
1541 kEmptyMatch }, 1606 kEmptyMatch, kEmptyMatch },
1542 std::string() }, 1607 std::string() },
1543 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," 1608 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3],"
1544 "\"google:verbatimrelevance\":2}]", 1609 "\"google:verbatimrelevance\":2}]",
1545 { { "a", true, true }, 1610 { { "a", true, true },
1546 { "k a", false, true }, 1611 { "k a", false, true },
1547 { "a2", true, true }, 1612 { "a2", true, true },
1548 { "a1", true, true }, 1613 { "a1", true, true },
1549 kEmptyMatch }, 1614 kEmptyMatch, kEmptyMatch },
1550 std::string() }, 1615 std::string() },
1551 1616
1552 // Ensure that all suggestions are considered, regardless of order. 1617 // Ensure that all suggestions are considered, regardless of order.
1553 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," 1618 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[],"
1554 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1619 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1555 { { "a", true, true }, 1620 { { "a", true, true },
1556 { "k a", false, true }, 1621 { "k a", false, true },
1557 { "h", true, false }, 1622 { "h", true, false },
1558 { "g", true, false }, 1623 { "g", true, false },
1559 { "f", true, false } }, 1624 { "f", true, false },
1625 { "e", true, false } },
1560 std::string() }, 1626 std::string() },
1561 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," 1627 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\","
1562 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," 1628 "\"http://e.com\", \"http://f.com\", \"http://g.com\","
1563 "\"http://h.com\"],[],[]," 1629 "\"http://h.com\"],[],[],"
1564 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," 1630 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\","
1565 "\"NAVIGATION\", \"NAVIGATION\"," 1631 "\"NAVIGATION\", \"NAVIGATION\","
1566 "\"NAVIGATION\", \"NAVIGATION\"," 1632 "\"NAVIGATION\", \"NAVIGATION\","
1567 "\"NAVIGATION\"]," 1633 "\"NAVIGATION\"],"
1568 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", 1634 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]",
1569 { { "a", true, true }, 1635 { { "a", true, true },
1570 { "k a", false, true }, 1636 { "k a", false, true },
1571 { "h.com", false, false }, 1637 { "h.com", false, false },
1572 { "g.com", false, false }, 1638 { "g.com", false, false },
1573 { "f.com", false, false } }, 1639 { "f.com", false, false },
1640 { "e.com", false, false } },
1574 std::string() }, 1641 std::string() },
1575 1642
1576 // Ensure that incorrectly sized suggestion relevance lists are ignored. 1643 // Ensure that incorrectly sized suggestion relevance lists are ignored.
1577 // Note that keyword suggestions by default (not in suggested relevance 1644 // Note that keyword suggestions by default (not in suggested relevance
1578 // mode) score more highly than the default verbatim. 1645 // mode) score more highly than the default verbatim.
1579 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", 1646 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]",
1580 { { "a", true, true }, 1647 { { "a", true, true },
1581 { "a1", true, true }, 1648 { "a1", true, true },
1582 { "a2", true, true }, 1649 { "a2", true, true },
1583 { "k a", false, true }, 1650 { "k a", false, true },
1584 kEmptyMatch }, 1651 kEmptyMatch, kEmptyMatch },
1585 std::string() }, 1652 std::string() },
1586 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", 1653 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]",
1587 { { "a", true, true }, 1654 { { "a", true, true },
1588 { "a1", true, true }, 1655 { "a1", true, true },
1589 { "k a", false, true }, 1656 { "k a", false, true },
1590 kEmptyMatch, kEmptyMatch}, 1657 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1591 std::string() }, 1658 std::string() },
1592 // In this case, ignored the suggested relevance scores means we keep 1659 // In this case, ignored the suggested relevance scores means we keep
1593 // only one navsuggest result. 1660 // only one navsuggest result.
1594 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1661 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1595 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1662 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1596 "\"google:suggestrelevance\":[1]}]", 1663 "\"google:suggestrelevance\":[1]}]",
1597 { { "a", true, true }, 1664 { { "a", true, true },
1598 { "a1.com", false, true }, 1665 { "a1.com", false, true },
1599 { "k a", false, true }, 1666 { "k a", false, true },
1600 kEmptyMatch, kEmptyMatch}, 1667 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1601 std::string() }, 1668 std::string() },
1602 { "[\"a\",[\"http://a1.com\"],[],[]," 1669 { "[\"a\",[\"http://a1.com\"],[],[],"
1603 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1670 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1604 "\"google:suggestrelevance\":[9999, 1]}]", 1671 "\"google:suggestrelevance\":[9999, 1]}]",
1605 { { "a", true, true }, 1672 { { "a", true, true },
1606 { "a1.com", false, true }, 1673 { "a1.com", false, true },
1607 { "k a", false, true }, 1674 { "k a", false, true },
1608 kEmptyMatch, kEmptyMatch}, 1675 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1609 std::string() }, 1676 std::string() },
1610 1677
1611 // Ensure that all 'verbatim' results are merged with their maximum score. 1678 // Ensure that all 'verbatim' results are merged with their maximum score.
1612 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1679 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1613 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1680 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1614 { { "a2", true, true }, 1681 { { "a2", true, true },
1615 { "a", true, true }, 1682 { "a", true, true },
1616 { "a1", true, true }, 1683 { "a1", true, true },
1617 { "k a", false, true }, 1684 { "k a", false, true },
1618 kEmptyMatch }, 1685 kEmptyMatch, kEmptyMatch },
1619 "2" }, 1686 "2" },
1620 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," 1687 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[],"
1621 "{\"google:suggestrelevance\":[9998, 9997, 9999]," 1688 "{\"google:suggestrelevance\":[9998, 9997, 9999],"
1622 "\"google:verbatimrelevance\":0}]", 1689 "\"google:verbatimrelevance\":0}]",
1623 { { "a2", true, true }, 1690 { { "a2", true, true },
1624 { "a", true, true }, 1691 { "a", true, true },
1625 { "a1", true, true }, 1692 { "a1", true, true },
1626 { "k a", false, true }, 1693 { "k a", false, true },
1627 kEmptyMatch }, 1694 kEmptyMatch, kEmptyMatch },
1628 "2" }, 1695 "2" },
1629 1696
1630 // Ensure that verbatim is always generated without other suggestions. 1697 // Ensure that verbatim is always generated without other suggestions.
1631 // TODO(mpearson): Ensure the value of verbatimrelevance is respected 1698 // TODO(mpearson): Ensure the value of verbatimrelevance is respected
1632 // (except when suggested relevances are ignored). 1699 // (except when suggested relevances are ignored).
1633 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1700 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1634 { { "a", true, true }, 1701 { { "a", true, true },
1635 { "k a", false, true }, 1702 { "k a", false, true },
1636 kEmptyMatch, kEmptyMatch, kEmptyMatch}, 1703 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch },
1637 std::string() }, 1704 std::string() },
1638 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1705 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1639 { { "a", true, true }, 1706 { { "a", true, true },
1640 { "k a", false, true }, 1707 { "k a", false, true },
1641 kEmptyMatch, kEmptyMatch, kEmptyMatch}, 1708 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch },
1642 std::string() }, 1709 std::string() },
1643 1710
1644 // Check that navsuggestions will be demoted below queries. 1711 // Check that navsuggestions will be demoted below queries.
1645 // (Navsuggestions are not allowed to appear first.) In the process, 1712 // (Navsuggestions are not allowed to appear first.) In the process,
1646 // make sure the navsuggestions still remain in the same order. 1713 // make sure the navsuggestions still remain in the same order.
1647 // First, check the situation where navsuggest scores more than verbatim 1714 // First, check the situation where navsuggest scores more than verbatim
1648 // and there are no query suggestions. 1715 // and there are no query suggestions.
1649 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1716 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1650 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1717 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1651 "\"google:verbatimrelevance\":9990," 1718 "\"google:verbatimrelevance\":9990,"
1652 "\"google:suggestrelevance\":[9998, 9999]}]", 1719 "\"google:suggestrelevance\":[9998, 9999]}]",
1653 { { "a", true, true }, 1720 { { "a", true, true },
1654 { "a2.com", false, true }, 1721 { "a2.com", false, true },
1655 { "a1.com", false, true }, 1722 { "a1.com", false, true },
1656 { "k a", false, true }, 1723 { "k a", false, true },
1657 kEmptyMatch }, 1724 kEmptyMatch, kEmptyMatch },
1658 std::string() }, 1725 std::string() },
1659 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1726 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1660 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1727 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1661 "\"google:verbatimrelevance\":9990," 1728 "\"google:verbatimrelevance\":9990,"
1662 "\"google:suggestrelevance\":[9999, 9998]}]", 1729 "\"google:suggestrelevance\":[9999, 9998]}]",
1663 { { "a", true, true }, 1730 { { "a", true, true },
1664 { "a1.com", false, true }, 1731 { "a1.com", false, true },
1665 { "a2.com", false, true }, 1732 { "a2.com", false, true },
1666 { "k a", false, true }, 1733 { "k a", false, true },
1667 kEmptyMatch }, 1734 kEmptyMatch, kEmptyMatch },
1668 std::string() }, 1735 std::string() },
1669 { "[\"a\",[\"https://a/\"],[],[]," 1736 { "[\"a\",[\"https://a/\"],[],[],"
1670 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1737 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1671 "\"google:suggestrelevance\":[9999]}]", 1738 "\"google:suggestrelevance\":[9999]}]",
1672 { { "a", true, true }, 1739 { { "a", true, true },
1673 { "https://a", false, true }, 1740 { "https://a", false, true },
1674 { "k a", false, true }, 1741 { "k a", false, true },
1675 kEmptyMatch, 1742 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1676 kEmptyMatch },
1677 std::string() }, 1743 std::string() },
1678 // Check when navsuggest scores more than verbatim and there is query 1744 // Check when navsuggest scores more than verbatim and there is query
1679 // suggestion but it scores lower. 1745 // suggestion but it scores lower.
1680 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1746 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1681 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1747 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1682 "\"google:verbatimrelevance\":9990," 1748 "\"google:verbatimrelevance\":9990,"
1683 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", 1749 "\"google:suggestrelevance\":[9998, 9999, 1300]}]",
1684 { { "a", true, true }, 1750 { { "a", true, true },
1685 { "a2.com", false, true }, 1751 { "a2.com", false, true },
1686 { "a1.com", false, true }, 1752 { "a1.com", false, true },
1687 { "a3", true, true }, 1753 { "a3", true, true },
1688 { "k a", false, true } }, 1754 { "k a", false, true },
1755 kEmptyMatch },
1689 std::string() }, 1756 std::string() },
1690 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1757 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1691 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1758 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1692 "\"google:verbatimrelevance\":9990," 1759 "\"google:verbatimrelevance\":9990,"
1693 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", 1760 "\"google:suggestrelevance\":[9999, 9998, 1300]}]",
1694 { { "a", true, true }, 1761 { { "a", true, true },
1695 { "a1.com", false, true }, 1762 { "a1.com", false, true },
1696 { "a2.com", false, true }, 1763 { "a2.com", false, true },
1697 { "a3", true, true }, 1764 { "a3", true, true },
1698 { "k a", false, true } }, 1765 { "k a", false, true },
1766 kEmptyMatch },
1699 std::string() }, 1767 std::string() },
1700 // Check when navsuggest scores more than a query suggestion. There is 1768 // Check when navsuggest scores more than a query suggestion. There is
1701 // a verbatim but it scores lower. 1769 // a verbatim but it scores lower.
1702 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1770 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1703 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1771 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1704 "\"google:verbatimrelevance\":9990," 1772 "\"google:verbatimrelevance\":9990,"
1705 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", 1773 "\"google:suggestrelevance\":[9998, 9999, 9997]}]",
1706 { { "a3", true, true }, 1774 { { "a3", true, true },
1707 { "a2.com", false, true }, 1775 { "a2.com", false, true },
1708 { "a1.com", false, true }, 1776 { "a1.com", false, true },
1709 { "a", true, true }, 1777 { "a", true, true },
1710 { "k a", false, true } }, 1778 { "k a", false, true },
1779 kEmptyMatch },
1711 "3" }, 1780 "3" },
1712 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1781 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1713 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1782 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1714 "\"google:verbatimrelevance\":9990," 1783 "\"google:verbatimrelevance\":9990,"
1715 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", 1784 "\"google:suggestrelevance\":[9999, 9998, 9997]}]",
1716 { { "a3", true, true }, 1785 { { "a3", true, true },
1717 { "a1.com", false, true }, 1786 { "a1.com", false, true },
1718 { "a2.com", false, true }, 1787 { "a2.com", false, true },
1719 { "a", true, true }, 1788 { "a", true, true },
1720 { "k a", false, true } }, 1789 { "k a", false, true },
1790 kEmptyMatch },
1721 "3" }, 1791 "3" },
1722 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1792 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1723 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1793 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1724 "\"google:verbatimrelevance\":0," 1794 "\"google:verbatimrelevance\":0,"
1725 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", 1795 "\"google:suggestrelevance\":[9998, 9999, 9997]}]",
1726 { { "a3", true, true }, 1796 { { "a3", true, true },
1727 { "a2.com", false, true }, 1797 { "a2.com", false, true },
1728 { "a1.com", false, true }, 1798 { "a1.com", false, true },
1729 { "k a", false, true }, 1799 { "k a", false, true },
1730 kEmptyMatch }, 1800 kEmptyMatch, kEmptyMatch },
1731 "3" }, 1801 "3" },
1732 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1802 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1733 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1803 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1734 "\"google:verbatimrelevance\":0," 1804 "\"google:verbatimrelevance\":0,"
1735 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", 1805 "\"google:suggestrelevance\":[9999, 9998, 9997]}]",
1736 { { "a3", true, true }, 1806 { { "a3", true, true },
1737 { "a1.com", false, true }, 1807 { "a1.com", false, true },
1738 { "a2.com", false, true }, 1808 { "a2.com", false, true },
1739 { "k a", false, true }, 1809 { "k a", false, true },
1740 kEmptyMatch }, 1810 kEmptyMatch, kEmptyMatch },
1741 "3" }, 1811 "3" },
1742 // Check when there is neither verbatim nor a query suggestion that, 1812 // Check when there is neither verbatim nor a query suggestion that,
1743 // because we can't demote navsuggestions below a query suggestion, 1813 // because we can't demote navsuggestions below a query suggestion,
1744 // we abandon suggested relevance scores entirely. One consequence is 1814 // we abandon suggested relevance scores entirely. One consequence is
1745 // that this means we restore the keyword verbatim match. Note 1815 // that this means we restore the keyword verbatim match. Note
1746 // that in this case of abandoning suggested relevance scores, we still 1816 // that in this case of abandoning suggested relevance scores, we still
1747 // keep the navsuggestions in the same order, but we revert to only allowing 1817 // keep the navsuggestions in the same order, but we revert to only allowing
1748 // one navigation to appear because the scores are completely local. 1818 // one navigation to appear because the scores are completely local.
1749 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1819 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1750 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1820 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1751 "\"google:verbatimrelevance\":0," 1821 "\"google:verbatimrelevance\":0,"
1752 "\"google:suggestrelevance\":[9998, 9999]}]", 1822 "\"google:suggestrelevance\":[9998, 9999]}]",
1753 { { "a", true, true }, 1823 { { "a", true, true },
1754 { "a2.com", false, true }, 1824 { "a2.com", false, true },
1755 { "k a", false, true }, 1825 { "k a", false, true },
1756 kEmptyMatch, kEmptyMatch}, 1826 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1757 std::string() }, 1827 std::string() },
1758 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1828 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1759 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1829 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1760 "\"google:verbatimrelevance\":0," 1830 "\"google:verbatimrelevance\":0,"
1761 "\"google:suggestrelevance\":[9999, 9998]}]", 1831 "\"google:suggestrelevance\":[9999, 9998]}]",
1762 { { "a", true, true }, 1832 { { "a", true, true },
1763 { "a1.com", false, true }, 1833 { "a1.com", false, true },
1764 { "k a", false, true }, 1834 { "k a", false, true },
1765 kEmptyMatch, kEmptyMatch}, 1835 kEmptyMatch, kEmptyMatch, kEmptyMatch },
1766 std::string() }, 1836 std::string() },
1767 // More checks that everything works when it's not necessary to demote. 1837 // More checks that everything works when it's not necessary to demote.
1768 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1838 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1769 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1839 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1770 "\"google:verbatimrelevance\":9990," 1840 "\"google:verbatimrelevance\":9990,"
1771 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", 1841 "\"google:suggestrelevance\":[9997, 9998, 9999]}]",
1772 { { "a3", true, true }, 1842 { { "a3", true, true },
1773 { "a2.com", false, true }, 1843 { "a2.com", false, true },
1774 { "a1.com", false, true }, 1844 { "a1.com", false, true },
1775 { "a", true, true }, 1845 { "a", true, true },
1776 { "k a", false, true } }, 1846 { "k a", false, true },
1847 kEmptyMatch },
1777 "3" }, 1848 "3" },
1778 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1849 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1779 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1850 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1780 "\"google:verbatimrelevance\":9990," 1851 "\"google:verbatimrelevance\":9990,"
1781 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1852 "\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1782 { { "a3", true, true }, 1853 { { "a3", true, true },
1783 { "a1.com", false, true }, 1854 { "a1.com", false, true },
1784 { "a2.com", false, true }, 1855 { "a2.com", false, true },
1785 { "a", true, true }, 1856 { "a", true, true },
1786 { "k a", false, true } }, 1857 { "k a", false, true },
1858 kEmptyMatch },
1787 "3" }, 1859 "3" },
1788 }; 1860 };
1789 1861
1790 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { 1862 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
1791 QueryForInput(ASCIIToUTF16("k a"), false, true); 1863 QueryForInput(ASCIIToUTF16("k a"), false, true);
1792 1864
1793 // Set up a default fetcher with no results. 1865 // Set up a default fetcher with no results.
1794 net::TestURLFetcher* default_fetcher = 1866 net::TestURLFetcher* default_fetcher =
1795 test_factory_.GetFetcherByID( 1867 test_factory_.GetFetcherByID(
1796 SearchProvider::kDefaultProviderURLFetcherID); 1868 SearchProvider::kDefaultProviderURLFetcherID);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 matches[j].allowed_to_be_default_match) << description; 1901 matches[j].allowed_to_be_default_match) << description;
1830 } 1902 }
1831 // Ensure that no expected matches are missing. 1903 // Ensure that no expected matches are missing.
1832 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) 1904 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j)
1833 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << 1905 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) <<
1834 "Case # " << i << " " << description; 1906 "Case # " << i << " " << description;
1835 } 1907 }
1836 } 1908 }
1837 1909
1838 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { 1910 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) {
1839 // Enable Instant Extended in order to allow an increased number of
1840 // suggestions.
1841 chrome::EnableInstantExtendedAPIForTesting();
1842
1843 // We hardcode the string "term1" below, so ensure that the search term that 1911 // We hardcode the string "term1" below, so ensure that the search term that
1844 // got added to history already is that string. 1912 // got added to history already is that string.
1845 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); 1913 ASSERT_EQ(ASCIIToUTF16("term1"), term1_);
1846 string16 term = term1_.substr(0, term1_.length() - 1); 1914 string16 term = term1_.substr(0, term1_.length() - 1);
1847 1915
1848 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); 1916 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2);
1849 profile_.BlockUntilHistoryProcessesPendingRequests(); 1917 profile_.BlockUntilHistoryProcessesPendingRequests();
1850 1918
1851 struct { 1919 struct {
1852 const string16 input; 1920 const string16 input;
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 SCOPED_TRACE(description); 2683 SCOPED_TRACE(description);
2616 EXPECT_EQ(cases[i].matches[j].contents, UTF16ToUTF8(matches[j].contents)); 2684 EXPECT_EQ(cases[i].matches[j].contents, UTF16ToUTF8(matches[j].contents));
2617 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, 2685 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched,
2618 SearchProvider::ShouldPrefetch(matches[j])); 2686 SearchProvider::ShouldPrefetch(matches[j]));
2619 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); 2687 EXPECT_EQ(cases[i].matches[j].type, matches[j].type);
2620 EXPECT_EQ(cases[i].matches[j].from_keyword, 2688 EXPECT_EQ(cases[i].matches[j].from_keyword,
2621 matches[j].keyword == ASCIIToUTF16("k")); 2689 matches[j].keyword == ASCIIToUTF16("k"));
2622 } 2690 }
2623 } 2691 }
2624 } 2692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698