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

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

Issue 23619016: Switch the offset conversion routines from... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 3 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"
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 "{\"google:suggesttype\":[\"NAVIGATION\"]," 996 "{\"google:suggesttype\":[\"NAVIGATION\"],"
997 "\"google:suggestrelevance\":[9999]}]", 997 "\"google:suggestrelevance\":[9999]}]",
998 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 998 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch },
999 std::string() }, 999 std::string() },
1000 { "[\"a\",[\"http://b.com\"],[],[]," 1000 { "[\"a\",[\"http://b.com\"],[],[],"
1001 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1001 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1002 "\"google:suggestrelevance\":[9999]," 1002 "\"google:suggestrelevance\":[9999],"
1003 "\"google:verbatimrelevance\":0}]", 1003 "\"google:verbatimrelevance\":0}]",
1004 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, 1004 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch },
1005 std::string() }, 1005 std::string() },
1006 { "[\"a\",[\"https://a/\"],[],[],"
1007 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1008 "\"google:suggestrelevance\":[9999]}]",
1009 { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch },
1010 std::string() },
1006 1011
1007 // Ensure that the top result is ranked as highly as calculated verbatim. 1012 // Ensure that the top result is ranked as highly as calculated verbatim.
1008 // Ignore the suggested verbatim relevance if this constraint is violated. 1013 // Ignore the suggested verbatim relevance if this constraint is violated.
1009 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", 1014 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]",
1010 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1015 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch },
1011 std::string() }, 1016 std::string() },
1012 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", 1017 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]",
1013 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, 1018 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch },
1014 std::string() }, 1019 std::string() },
1015 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," 1020 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1],"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," 1659 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[],"
1655 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," 1660 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"],"
1656 "\"google:verbatimrelevance\":9990," 1661 "\"google:verbatimrelevance\":9990,"
1657 "\"google:suggestrelevance\":[9999, 9998]}]", 1662 "\"google:suggestrelevance\":[9999, 9998]}]",
1658 { { "a", true, true }, 1663 { { "a", true, true },
1659 { "a1.com", false, true }, 1664 { "a1.com", false, true },
1660 { "a2.com", false, true }, 1665 { "a2.com", false, true },
1661 { "k a", false, true }, 1666 { "k a", false, true },
1662 kEmptyMatch }, 1667 kEmptyMatch },
1663 std::string() }, 1668 std::string() },
1669 { "[\"a\",[\"https://a/\"],[],[],"
1670 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1671 "\"google:suggestrelevance\":[9999]}]",
1672 { { "a", true, true },
1673 { "https://a", false, true },
1674 { "k a", false, true },
1675 kEmptyMatch,
1676 kEmptyMatch },
1677 std::string() },
1664 // Check when navsuggest scores more than verbatim and there is query 1678 // Check when navsuggest scores more than verbatim and there is query
1665 // suggestion but it scores lower. 1679 // suggestion but it scores lower.
1666 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," 1680 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[],"
1667 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," 1681 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"],"
1668 "\"google:verbatimrelevance\":9990," 1682 "\"google:verbatimrelevance\":9990,"
1669 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", 1683 "\"google:suggestrelevance\":[9998, 9999, 1300]}]",
1670 { { "a", true, true }, 1684 { { "a", true, true },
1671 { "a2.com", false, true }, 1685 { "a2.com", false, true },
1672 { "a1.com", false, true }, 1686 { "a1.com", false, true },
1673 { "a3", true, true }, 1687 { "a3", true, true },
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 const std::string json; 1956 const std::string json;
1943 const DefaultFetcherUrlInputMatch output[4]; 1957 const DefaultFetcherUrlInputMatch output[4];
1944 } cases[] = { 1958 } cases[] = {
1945 // Ensure topmost NAVIGATION matches are allowed for URL input. 1959 // Ensure topmost NAVIGATION matches are allowed for URL input.
1946 { "a.com", "[\"a.com\",[\"http://a.com/a\"],[],[]," 1960 { "a.com", "[\"a.com\",[\"http://a.com/a\"],[],[],"
1947 "{\"google:suggesttype\":[\"NAVIGATION\"]," 1961 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1948 "\"google:suggestrelevance\":[9999]}]", 1962 "\"google:suggestrelevance\":[9999]}]",
1949 { { "a.com/a", AutocompleteMatchType::NAVSUGGEST, true }, 1963 { { "a.com/a", AutocompleteMatchType::NAVSUGGEST, true },
1950 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, 1964 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true },
1951 kEmptyMatch, kEmptyMatch } }, 1965 kEmptyMatch, kEmptyMatch } },
1966 { "a.com", "[\"a.com\",[\"https://a.com\"],[],[],"
1967 "{\"google:suggesttype\":[\"NAVIGATION\"],"
1968 "\"google:suggestrelevance\":[9999]}]",
1969 { { "https://a.com", AutocompleteMatchType::NAVSUGGEST, true },
1970 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true },
1971 kEmptyMatch, kEmptyMatch } },
1952 1972
1953 // Ensure topmost SUGGEST matches are not allowed for URL input. 1973 // Ensure topmost SUGGEST matches are not allowed for URL input.
1954 // SearchProvider disregards search and verbatim suggested relevances. 1974 // SearchProvider disregards search and verbatim suggested relevances.
1955 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," 1975 { "a.com", "[\"a.com\",[\"a.com info\"],[],[],"
1956 "{\"google:suggestrelevance\":[9999]}]", 1976 "{\"google:suggestrelevance\":[9999]}]",
1957 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, 1977 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true },
1958 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, 1978 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true },
1959 kEmptyMatch, kEmptyMatch } }, 1979 kEmptyMatch, kEmptyMatch } },
1960 { "a.com", "[\"a.com\",[\"a.com/a\"],[],[]," 1980 { "a.com", "[\"a.com\",[\"a.com/a\"],[],[],"
1961 "{\"google:suggestrelevance\":[9999]}]", 1981 "{\"google:suggestrelevance\":[9999]}]",
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 // Do not inline matches that omit input domain labels; trim http as needed. 2137 // Do not inline matches that omit input domain labels; trim http as needed.
2118 { "www.a", "http://a.com", 2138 { "www.a", "http://a.com",
2119 "a.com", std::string(), false }, 2139 "a.com", std::string(), false },
2120 { "http://www.a", "http://a.com", 2140 { "http://www.a", "http://a.com",
2121 "http://a.com", std::string(), false }, 2141 "http://a.com", std::string(), false },
2122 { "www.a", "ftp://a.com", 2142 { "www.a", "ftp://a.com",
2123 "ftp://a.com", std::string(), false }, 2143 "ftp://a.com", std::string(), false },
2124 { "ftp://www.a", "ftp://a.com", 2144 { "ftp://www.a", "ftp://a.com",
2125 "ftp://a.com", std::string(), false }, 2145 "ftp://a.com", std::string(), false },
2126 2146
2127 // Input matching but with nothing to inline will not yield an offset. 2147 // Input matching but with nothing to inline will not yield an offset, but
2148 // will be allowed to be default.
2128 { "abc.com", "http://www.abc.com", 2149 { "abc.com", "http://www.abc.com",
2129 "www.abc.com", std::string(), false }, 2150 "www.abc.com", std::string(), true },
2130 { "http://www.abc.com", "http://www.abc.com", 2151 { "http://www.abc.com", "http://www.abc.com",
2131 "http://www.abc.com", std::string(), false }, 2152 "http://www.abc.com", std::string(), true },
2132 2153
2133 // Inline matches when the input is a leading substring of the scheme. 2154 // Inline matches when the input is a leading substring of the scheme.
2134 { "h", "http://www.abc.com", 2155 { "h", "http://www.abc.com",
2135 "http://www.abc.com", "ttp://www.abc.com", true }, 2156 "http://www.abc.com", "ttp://www.abc.com", true },
2136 { "http", "http://www.abc.com", 2157 { "http", "http://www.abc.com",
2137 "http://www.abc.com", "://www.abc.com", true }, 2158 "http://www.abc.com", "://www.abc.com", true },
2138 2159
2139 // Inline matches when the input is a leading substring of the full URL. 2160 // Inline matches when the input is a leading substring of the full URL.
2140 { "http:", "http://www.abc.com", 2161 { "http:", "http://www.abc.com",
2141 "http://www.abc.com", "//www.abc.com", true }, 2162 "http://www.abc.com", "//www.abc.com", true },
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 SCOPED_TRACE(description); 2615 SCOPED_TRACE(description);
2595 EXPECT_EQ(cases[i].matches[j].contents, UTF16ToUTF8(matches[j].contents)); 2616 EXPECT_EQ(cases[i].matches[j].contents, UTF16ToUTF8(matches[j].contents));
2596 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, 2617 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched,
2597 SearchProvider::ShouldPrefetch(matches[j])); 2618 SearchProvider::ShouldPrefetch(matches[j]));
2598 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); 2619 EXPECT_EQ(cases[i].matches[j].type, matches[j].type);
2599 EXPECT_EQ(cases[i].matches[j].from_keyword, 2620 EXPECT_EQ(cases[i].matches[j].from_keyword,
2600 matches[j].keyword == ASCIIToUTF16("k")); 2621 matches[j].keyword == ASCIIToUTF16("k"));
2601 } 2622 }
2602 } 2623 }
2603 } 2624 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698