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

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

Issue 655413002: Convert ARRAYSIZE_UNSAFE -> arraysize in chrome/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 "components/omnibox/search_provider.h" 5 #include "components/omnibox/search_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 // With suggested relevance scores in a situation where navsuggest 790 // With suggested relevance scores in a situation where navsuggest
791 // would go first only because verbatim has been demoted. 791 // would go first only because verbatim has been demoted.
792 { "[\"a\",[\"http://a1.com\", \"a2\"],[],[]," 792 { "[\"a\",[\"http://a1.com\", \"a2\"],[],[],"
793 "{\"google:suggesttype\":[\"NAVIGATION\", \"QUERY\"]," 793 "{\"google:suggesttype\":[\"NAVIGATION\", \"QUERY\"],"
794 "\"google:suggestrelevance\":[1450, 1400]," 794 "\"google:suggestrelevance\":[1450, 1400],"
795 "\"google:verbatimrelevance\":1350}]", 795 "\"google:verbatimrelevance\":1350}]",
796 { "a1.com", "a2", "a" }, 796 { "a1.com", "a2", "a" },
797 { "a2", "a", kEmptyMatch } }, 797 { "a2", "a", kEmptyMatch } },
798 }; 798 };
799 799
800 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 800 for (size_t i = 0; i < arraysize(cases); ++i) {
801 ForcedQueryTestHelper("a", cases[i].json, cases[i].matches_in_default_mode, 801 ForcedQueryTestHelper("a", cases[i].json, cases[i].matches_in_default_mode,
802 "regular input with json=" + cases[i].json); 802 "regular input with json=" + cases[i].json);
803 ForcedQueryTestHelper("?a", cases[i].json, 803 ForcedQueryTestHelper("?a", cases[i].json,
804 cases[i].matches_in_forced_query_mode, 804 cases[i].matches_in_forced_query_mode,
805 "forced query input with json=" + cases[i].json); 805 "forced query input with json=" + cases[i].json);
806 } 806 }
807 } 807 }
808 808
809 // A multiword search with one visit should not autocomplete until multiple 809 // A multiword search with one visit should not autocomplete until multiple
810 // words are typed. 810 // words are typed.
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 { "[\"k a\",[\"k adefault-query\", \"adefault.com\"],[],[]," 1240 { "[\"k a\",[\"k adefault-query\", \"adefault.com\"],[],[],"
1241 "{\"google:verbatimrelevance\":9700," 1241 "{\"google:verbatimrelevance\":9700,"
1242 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," 1242 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"],"
1243 "\"google:suggestrelevance\":[9900, 9800]}]", 1243 "\"google:suggestrelevance\":[9900, 9800]}]",
1244 "[\"a\",[\"akeyword-query\"],[],[],{\"google:suggesttype\":[\"QUERY\"]," 1244 "[\"a\",[\"akeyword-query\"],[],[],{\"google:suggesttype\":[\"QUERY\"],"
1245 "\"google:verbatimrelevance\":9500," 1245 "\"google:verbatimrelevance\":9500,"
1246 "\"google:suggestrelevance\":[9600]}]", 1246 "\"google:suggestrelevance\":[9600]}]",
1247 { "akeyword-query", "a", "k a", "adefault.com", "k adefault-query" } } 1247 { "akeyword-query", "a", "k a", "adefault.com", "k adefault-query" } }
1248 }; 1248 };
1249 1249
1250 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 1250 for (size_t i = 0; i < arraysize(cases); ++i) {
1251 // Send the query twice in order to have a synchronous pass after the first 1251 // Send the query twice in order to have a synchronous pass after the first
1252 // response is received. This is necessary because SearchProvider doesn't 1252 // response is received. This is necessary because SearchProvider doesn't
1253 // allow an asynchronous response to change the default match. 1253 // allow an asynchronous response to change the default match.
1254 for (size_t j = 0; j < 2; ++j) { 1254 for (size_t j = 0; j < 2; ++j) {
1255 QueryForInputAndWaitForFetcherResponses( 1255 QueryForInputAndWaitForFetcherResponses(
1256 ASCIIToUTF16("k a"), true, cases[i].default_provider_json, 1256 ASCIIToUTF16("k a"), true, cases[i].default_provider_json,
1257 cases[i].keyword_provider_json); 1257 cases[i].keyword_provider_json);
1258 } 1258 }
1259 1259
1260 SCOPED_TRACE( 1260 SCOPED_TRACE(
1261 "for input with default_provider_json=" + 1261 "for input with default_provider_json=" +
1262 cases[i].default_provider_json + " and keyword_provider_json=" + 1262 cases[i].default_provider_json + " and keyword_provider_json=" +
1263 cases[i].keyword_provider_json); 1263 cases[i].keyword_provider_json);
1264 const ACMatches& matches = provider_->matches(); 1264 const ACMatches& matches = provider_->matches();
1265 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); 1265 ASSERT_LE(matches.size(), arraysize(cases[i].matches));
1266 size_t j = 0; 1266 size_t j = 0;
1267 // Ensure that the returned matches equal the expectations. 1267 // Ensure that the returned matches equal the expectations.
1268 for (; j < matches.size(); ++j) 1268 for (; j < matches.size(); ++j)
1269 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), matches[j].contents); 1269 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), matches[j].contents);
1270 // Ensure that no expected matches are missing. 1270 // Ensure that no expected matches are missing.
1271 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) 1271 for (; j < arraysize(cases[i].matches); ++j)
1272 EXPECT_EQ(std::string(), cases[i].matches[j]); 1272 EXPECT_EQ(std::string(), cases[i].matches[j]);
1273 } 1273 }
1274 } 1274 }
1275 1275
1276 // Verifies that suggest results with relevance scores are added 1276 // Verifies that suggest results with relevance scores are added
1277 // properly when using the default fetcher. When adding a new test 1277 // properly when using the default fetcher. When adding a new test
1278 // case to this test, please consider adding it to the tests in 1278 // case to this test, please consider adding it to the tests in
1279 // KeywordFetcherSuggestRelevance below. 1279 // KeywordFetcherSuggestRelevance below.
1280 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { 1280 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) {
1281 struct { 1281 struct {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", 1485 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]",
1486 { { "a", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, 1486 { { "a", true }, kEmptyExpectedMatch, kEmptyExpectedMatch,
1487 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, 1487 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch },
1488 std::string() }, 1488 std::string() },
1489 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", 1489 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]",
1490 { { "a", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, 1490 { { "a", true }, kEmptyExpectedMatch, kEmptyExpectedMatch,
1491 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, 1491 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch },
1492 std::string() }, 1492 std::string() },
1493 }; 1493 };
1494 1494
1495 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 1495 for (size_t i = 0; i < arraysize(cases); ++i) {
1496 // Send the query twice in order to have a synchronous pass after the first 1496 // Send the query twice in order to have a synchronous pass after the first
1497 // response is received. This is necessary because SearchProvider doesn't 1497 // response is received. This is necessary because SearchProvider doesn't
1498 // allow an asynchronous response to change the default match. 1498 // allow an asynchronous response to change the default match.
1499 for (size_t j = 0; j < 2; ++j) { 1499 for (size_t j = 0; j < 2; ++j) {
1500 QueryForInputAndWaitForFetcherResponses( 1500 QueryForInputAndWaitForFetcherResponses(
1501 ASCIIToUTF16("a"), false, cases[i].json, std::string()); 1501 ASCIIToUTF16("a"), false, cases[i].json, std::string());
1502 } 1502 }
1503 1503
1504 const std::string description = "for input with json=" + cases[i].json; 1504 const std::string description = "for input with json=" + cases[i].json;
1505 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].matches), 1505 CheckMatches(description, arraysize(cases[i].matches), cases[i].matches,
1506 cases[i].matches, provider_->matches()); 1506 provider_->matches());
1507 } 1507 }
1508 } 1508 }
1509 1509
1510 // Verifies that suggest results with relevance scores are added 1510 // Verifies that suggest results with relevance scores are added
1511 // properly when using the keyword fetcher. This is similar to the 1511 // properly when using the keyword fetcher. This is similar to the
1512 // test DefaultFetcherSuggestRelevance above but this uses inputs that 1512 // test DefaultFetcherSuggestRelevance above but this uses inputs that
1513 // trigger keyword suggestions (i.e., "k a" rather than "a") and has 1513 // trigger keyword suggestions (i.e., "k a" rather than "a") and has
1514 // different expectations (because now the results are a mix of 1514 // different expectations (because now the results are a mix of
1515 // keyword suggestions and default provider suggestions). When a new 1515 // keyword suggestions and default provider suggestions). When a new
1516 // test is added to this TEST_F, please consider if it would be 1516 // test is added to this TEST_F, please consider if it would be
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", 1917 "\"google:suggestrelevance\":[9998, 9997, 9999]}]",
1918 { { "a3", true, true }, 1918 { { "a3", true, true },
1919 { "a1.com", false, false }, 1919 { "a1.com", false, false },
1920 { "a2.com", false, false }, 1920 { "a2.com", false, false },
1921 { "a", true, true }, 1921 { "a", true, true },
1922 { "k a", false, false }, 1922 { "k a", false, false },
1923 kEmptyMatch }, 1923 kEmptyMatch },
1924 "3" }, 1924 "3" },
1925 }; 1925 };
1926 1926
1927 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 1927 for (size_t i = 0; i < arraysize(cases); ++i) {
1928 // Send the query twice in order to have a synchronous pass after the first 1928 // Send the query twice in order to have a synchronous pass after the first
1929 // response is received. This is necessary because SearchProvider doesn't 1929 // response is received. This is necessary because SearchProvider doesn't
1930 // allow an asynchronous response to change the default match. 1930 // allow an asynchronous response to change the default match.
1931 for (size_t j = 0; j < 2; ++j) { 1931 for (size_t j = 0; j < 2; ++j) {
1932 QueryForInput(ASCIIToUTF16("k a"), false, true); 1932 QueryForInput(ASCIIToUTF16("k a"), false, true);
1933 1933
1934 // Set up a default fetcher with no results. 1934 // Set up a default fetcher with no results.
1935 net::TestURLFetcher* default_fetcher = 1935 net::TestURLFetcher* default_fetcher =
1936 test_factory_.GetFetcherByID( 1936 test_factory_.GetFetcherByID(
1937 SearchProvider::kDefaultProviderURLFetcherID); 1937 SearchProvider::kDefaultProviderURLFetcherID);
(...skipping 17 matching lines...) Expand all
1955 SCOPED_TRACE("for input with json=" + cases[i].json); 1955 SCOPED_TRACE("for input with json=" + cases[i].json);
1956 const ACMatches& matches = provider_->matches(); 1956 const ACMatches& matches = provider_->matches();
1957 ASSERT_FALSE(matches.empty()); 1957 ASSERT_FALSE(matches.empty());
1958 // Find the first match that's allowed to be the default match and check 1958 // Find the first match that's allowed to be the default match and check
1959 // its inline_autocompletion. 1959 // its inline_autocompletion.
1960 ACMatches::const_iterator it = FindDefaultMatch(matches); 1960 ACMatches::const_iterator it = FindDefaultMatch(matches);
1961 ASSERT_NE(matches.end(), it); 1961 ASSERT_NE(matches.end(), it);
1962 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), 1962 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion),
1963 it->inline_autocompletion); 1963 it->inline_autocompletion);
1964 1964
1965 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); 1965 ASSERT_LE(matches.size(), arraysize(cases[i].matches));
1966 size_t j = 0; 1966 size_t j = 0;
1967 // Ensure that the returned matches equal the expectations. 1967 // Ensure that the returned matches equal the expectations.
1968 for (; j < matches.size(); ++j) { 1968 for (; j < matches.size(); ++j) {
1969 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), 1969 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents),
1970 matches[j].contents); 1970 matches[j].contents);
1971 EXPECT_EQ(cases[i].matches[j].from_keyword, 1971 EXPECT_EQ(cases[i].matches[j].from_keyword,
1972 matches[j].keyword == ASCIIToUTF16("k")); 1972 matches[j].keyword == ASCIIToUTF16("k"));
1973 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, 1973 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match,
1974 matches[j].allowed_to_be_default_match); 1974 matches[j].allowed_to_be_default_match);
1975 } 1975 }
1976 // Ensure that no expected matches are missing. 1976 // Ensure that no expected matches are missing.
1977 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) { 1977 for (; j < arraysize(cases[i].matches); ++j) {
1978 SCOPED_TRACE(" Case # " + base::IntToString(i)); 1978 SCOPED_TRACE(" Case # " + base::IntToString(i));
1979 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents); 1979 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents);
1980 } 1980 }
1981 } 1981 }
1982 } 1982 }
1983 1983
1984 TEST_F(SearchProviderTest, DontInlineAutocompleteAsynchronously) { 1984 TEST_F(SearchProviderTest, DontInlineAutocompleteAsynchronously) {
1985 // This test sends two separate queries, each receiving different JSON 1985 // This test sends two separate queries, each receiving different JSON
1986 // replies, and checks that at each stage of processing (receiving first 1986 // replies, and checks that at each stage of processing (receiving first
1987 // asynchronous response, handling new keystroke synchronously / sending the 1987 // asynchronous response, handling new keystroke synchronously / sending the
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 kEmptyExpectedMatch }, 2155 kEmptyExpectedMatch },
2156 { { "ab1", true }, { "ab2", true }, { "ab", true }, 2156 { { "ab1", true }, { "ab2", true }, { "ab", true },
2157 kEmptyExpectedMatch }, 2157 kEmptyExpectedMatch },
2158 "[\"ab\",[\"ab1\", \"ab3\"],[],[]," 2158 "[\"ab\",[\"ab1\", \"ab3\"],[],[],"
2159 "{\"google:verbatimrelevance\":9000," 2159 "{\"google:verbatimrelevance\":9000,"
2160 "\"google:suggestrelevance\":[8000, 9500]}]", 2160 "\"google:suggestrelevance\":[8000, 9500]}]",
2161 { { "ab", true }, { "ab3", false }, { "ab1", true }, 2161 { { "ab", true }, { "ab3", false }, { "ab1", true },
2162 kEmptyExpectedMatch } }, 2162 kEmptyExpectedMatch } },
2163 }; 2163 };
2164 2164
2165 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2165 for (size_t i = 0; i < arraysize(cases); ++i) {
2166 // First, send the query "a" and receive the JSON response |first_json|. 2166 // First, send the query "a" and receive the JSON response |first_json|.
2167 ClearAllResults(); 2167 ClearAllResults();
2168 QueryForInputAndWaitForFetcherResponses( 2168 QueryForInputAndWaitForFetcherResponses(
2169 ASCIIToUTF16("a"), false, cases[i].first_json, std::string()); 2169 ASCIIToUTF16("a"), false, cases[i].first_json, std::string());
2170 2170
2171 // Verify that the matches after the asynchronous results are as expected. 2171 // Verify that the matches after the asynchronous results are as expected.
2172 std::string description = "first asynchronous response for input with " 2172 std::string description = "first asynchronous response for input with "
2173 "first_json=" + cases[i].first_json; 2173 "first_json=" + cases[i].first_json;
2174 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].first_async_matches), 2174 CheckMatches(description, arraysize(cases[i].first_async_matches),
2175 cases[i].first_async_matches, provider_->matches()); 2175 cases[i].first_async_matches, provider_->matches());
2176 2176
2177 // Then, send the query "ab" and check the synchronous matches. 2177 // Then, send the query "ab" and check the synchronous matches.
2178 description = "synchronous response after the first keystroke after input " 2178 description = "synchronous response after the first keystroke after input "
2179 "with first_json=" + cases[i].first_json; 2179 "with first_json=" + cases[i].first_json;
2180 QueryForInput(ASCIIToUTF16("ab"), false, false); 2180 QueryForInput(ASCIIToUTF16("ab"), false, false);
2181 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].sync_matches), 2181 CheckMatches(description, arraysize(cases[i].sync_matches),
2182 cases[i].sync_matches, provider_->matches()); 2182 cases[i].sync_matches, provider_->matches());
2183 2183
2184 // Finally, get the provided JSON response, |second_json|, and verify the 2184 // Finally, get the provided JSON response, |second_json|, and verify the
2185 // matches after the second asynchronous response are as expected. 2185 // matches after the second asynchronous response are as expected.
2186 description = "second asynchronous response after input with first_json=" + 2186 description = "second asynchronous response after input with first_json=" +
2187 cases[i].first_json + " and second_json=" + cases[i].second_json; 2187 cases[i].first_json + " and second_json=" + cases[i].second_json;
2188 net::TestURLFetcher* second_fetcher = 2188 net::TestURLFetcher* second_fetcher =
2189 test_factory_.GetFetcherByID( 2189 test_factory_.GetFetcherByID(
2190 SearchProvider::kDefaultProviderURLFetcherID); 2190 SearchProvider::kDefaultProviderURLFetcherID);
2191 ASSERT_TRUE(second_fetcher); 2191 ASSERT_TRUE(second_fetcher);
2192 second_fetcher->set_response_code(200); 2192 second_fetcher->set_response_code(200);
2193 second_fetcher->SetResponseString(cases[i].second_json); 2193 second_fetcher->SetResponseString(cases[i].second_json);
2194 second_fetcher->delegate()->OnURLFetchComplete(second_fetcher); 2194 second_fetcher->delegate()->OnURLFetchComplete(second_fetcher);
2195 RunTillProviderDone(); 2195 RunTillProviderDone();
2196 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].second_async_matches), 2196 CheckMatches(description, arraysize(cases[i].second_async_matches),
2197 cases[i].second_async_matches, provider_->matches()); 2197 cases[i].second_async_matches, provider_->matches());
2198 } 2198 }
2199 } 2199 }
2200 2200
2201 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { 2201 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) {
2202 // We hardcode the string "term1" below, so ensure that the search term that 2202 // We hardcode the string "term1" below, so ensure that the search term that
2203 // got added to history already is that string. 2203 // got added to history already is that string.
2204 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); 2204 ASSERT_EQ(ASCIIToUTF16("term1"), term1_);
2205 base::string16 term = term1_.substr(0, term1_.length() - 1); 2205 base::string16 term = term1_.substr(0, term1_.length() - 1);
2206 2206
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 "\"google:suggestrelevance\":[1440, 1430, 1420, 1410, 1400, 1390]}]", 2251 "\"google:suggestrelevance\":[1440, 1430, 1420, 1410, 1400, 1390]}]",
2252 { "term", "a1", "a2", "a3", "a4", "a5" } }, 2252 { "term", "a1", "a2", "a3", "a4", "a5" } },
2253 { term, 2253 { term,
2254 "[\"term\",[\"a1\", \"a2\", \"a3\", \"a4\"],[],[]," 2254 "[\"term\",[\"a1\", \"a2\", \"a3\", \"a4\"],[],[],"
2255 "{\"google:suggesttype\":[\"QUERY\", \"QUERY\", \"QUERY\", \"QUERY\"]," 2255 "{\"google:suggesttype\":[\"QUERY\", \"QUERY\", \"QUERY\", \"QUERY\"],"
2256 "\"google:verbatimrelevance\":1450," 2256 "\"google:verbatimrelevance\":1450,"
2257 "\"google:suggestrelevance\":[1430, 1410, 1390, 1370]}]", 2257 "\"google:suggestrelevance\":[1430, 1410, 1390, 1370]}]",
2258 { "term", "a1", "a2", "term2", "a3", "a4" } } 2258 { "term", "a1", "a2", "term2", "a3", "a4" } }
2259 }; 2259 };
2260 2260
2261 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2261 for (size_t i = 0; i < arraysize(cases); ++i) {
2262 QueryForInputAndWaitForFetcherResponses( 2262 QueryForInputAndWaitForFetcherResponses(
2263 cases[i].input, false, cases[i].json, std::string()); 2263 cases[i].input, false, cases[i].json, std::string());
2264 2264
2265 const std::string description = "for input with json=" + cases[i].json; 2265 const std::string description = "for input with json=" + cases[i].json;
2266 const ACMatches& matches = provider_->matches(); 2266 const ACMatches& matches = provider_->matches();
2267 2267
2268 // Ensure no extra matches are present. 2268 // Ensure no extra matches are present.
2269 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); 2269 ASSERT_LE(matches.size(), arraysize(cases[i].matches));
2270 2270
2271 size_t j = 0; 2271 size_t j = 0;
2272 // Ensure that the returned matches equal the expectations. 2272 // Ensure that the returned matches equal the expectations.
2273 for (; j < matches.size(); ++j) 2273 for (; j < matches.size(); ++j)
2274 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), 2274 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]),
2275 matches[j].contents) << description; 2275 matches[j].contents) << description;
2276 // Ensure that no expected matches are missing. 2276 // Ensure that no expected matches are missing.
2277 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) 2277 for (; j < arraysize(cases[i].matches); ++j)
2278 EXPECT_EQ(kNotApplicable, cases[i].matches[j]) << 2278 EXPECT_EQ(kNotApplicable, cases[i].matches[j]) <<
2279 "Case # " << i << " " << description; 2279 "Case # " << i << " " << description;
2280 } 2280 }
2281 } 2281 }
2282 2282
2283 // Verifies suggest relevance behavior for URL input. 2283 // Verifies suggest relevance behavior for URL input.
2284 TEST_F(SearchProviderTest, DefaultProviderSuggestRelevanceScoringUrlInput) { 2284 TEST_F(SearchProviderTest, DefaultProviderSuggestRelevanceScoringUrlInput) {
2285 struct DefaultFetcherUrlInputMatch { 2285 struct DefaultFetcherUrlInputMatch {
2286 const std::string match_contents; 2286 const std::string match_contents;
2287 AutocompleteMatch::Type match_type; 2287 AutocompleteMatch::Type match_type;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, 2363 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true },
2364 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, 2364 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false },
2365 kEmptyMatch, kEmptyMatch } }, 2365 kEmptyMatch, kEmptyMatch } },
2366 { "a.com", "[\"a.com\",[\"info\"],[],[]," 2366 { "a.com", "[\"a.com\",[\"info\"],[],[],"
2367 "{\"google:suggestrelevance\":[9999]}]", 2367 "{\"google:suggestrelevance\":[9999]}]",
2368 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, 2368 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true },
2369 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, 2369 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false },
2370 kEmptyMatch, kEmptyMatch } }, 2370 kEmptyMatch, kEmptyMatch } },
2371 }; 2371 };
2372 2372
2373 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2373 for (size_t i = 0; i < arraysize(cases); ++i) {
2374 // Send the query twice in order to have a synchronous pass after the first 2374 // Send the query twice in order to have a synchronous pass after the first
2375 // response is received. This is necessary because SearchProvider doesn't 2375 // response is received. This is necessary because SearchProvider doesn't
2376 // allow an asynchronous response to change the default match. 2376 // allow an asynchronous response to change the default match.
2377 for (size_t j = 0; j < 2; ++j) { 2377 for (size_t j = 0; j < 2; ++j) {
2378 QueryForInputAndWaitForFetcherResponses( 2378 QueryForInputAndWaitForFetcherResponses(
2379 ASCIIToUTF16(cases[i].input), false, cases[i].json, std::string()); 2379 ASCIIToUTF16(cases[i].input), false, cases[i].json, std::string());
2380 } 2380 }
2381 2381
2382 SCOPED_TRACE("input=" + cases[i].input + " json=" + cases[i].json); 2382 SCOPED_TRACE("input=" + cases[i].input + " json=" + cases[i].json);
2383 size_t j = 0; 2383 size_t j = 0;
2384 const ACMatches& matches = provider_->matches(); 2384 const ACMatches& matches = provider_->matches();
2385 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].output)); 2385 ASSERT_LE(matches.size(), arraysize(cases[i].output));
2386 // Ensure that the returned matches equal the expectations. 2386 // Ensure that the returned matches equal the expectations.
2387 for (; j < matches.size(); ++j) { 2387 for (; j < matches.size(); ++j) {
2388 EXPECT_EQ(ASCIIToUTF16(cases[i].output[j].match_contents), 2388 EXPECT_EQ(ASCIIToUTF16(cases[i].output[j].match_contents),
2389 matches[j].contents); 2389 matches[j].contents);
2390 EXPECT_EQ(cases[i].output[j].match_type, matches[j].type); 2390 EXPECT_EQ(cases[i].output[j].match_type, matches[j].type);
2391 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, 2391 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match,
2392 matches[j].allowed_to_be_default_match); 2392 matches[j].allowed_to_be_default_match);
2393 } 2393 }
2394 // Ensure that no expected matches are missing. 2394 // Ensure that no expected matches are missing.
2395 for (; j < ARRAYSIZE_UNSAFE(cases[i].output); ++j) { 2395 for (; j < arraysize(cases[i].output); ++j) {
2396 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents); 2396 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents);
2397 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, 2397 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES,
2398 cases[i].output[j].match_type); 2398 cases[i].output[j].match_type);
2399 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match); 2399 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match);
2400 } 2400 }
2401 } 2401 }
2402 } 2402 }
2403 2403
2404 // A basic test that verifies the field trial triggered parsing logic. 2404 // A basic test that verifies the field trial triggered parsing logic.
2405 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { 2405 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 { "?http://www.ab", "http://www.abc.com", 2587 { "?http://www.ab", "http://www.abc.com",
2588 "?http://www.abc.com", "c.com", true, false }, 2588 "?http://www.abc.com", "c.com", true, false },
2589 { "?www.ab", "http://www.abc.com", 2589 { "?www.ab", "http://www.abc.com",
2590 "?www.abc.com", "c.com", true, false }, 2590 "?www.abc.com", "c.com", true, false },
2591 { "?ab", "http://www.abc.com", 2591 { "?ab", "http://www.abc.com",
2592 "?www.abc.com", "c.com", true, false }, 2592 "?www.abc.com", "c.com", true, false },
2593 { "?abc.com", "http://www.abc.com", 2593 { "?abc.com", "http://www.abc.com",
2594 "?www.abc.com", std::string(), true, true }, 2594 "?www.abc.com", std::string(), true, true },
2595 }; 2595 };
2596 2596
2597 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2597 for (size_t i = 0; i < arraysize(cases); ++i) {
2598 // First test regular mode. 2598 // First test regular mode.
2599 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); 2599 QueryForInput(ASCIIToUTF16(cases[i].input), false, false);
2600 SearchSuggestionParser::NavigationResult result( 2600 SearchSuggestionParser::NavigationResult result(
2601 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), 2601 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url),
2602 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), 2602 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(),
2603 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()); 2603 false, 0, false, ASCIIToUTF16(cases[i].input), std::string());
2604 result.set_received_after_last_keystroke(false); 2604 result.set_received_after_last_keystroke(false);
2605 AutocompleteMatch match(provider_->NavigationToMatch(result)); 2605 AutocompleteMatch match(provider_->NavigationToMatch(result));
2606 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), 2606 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion),
2607 match.inline_autocompletion); 2607 match.inline_autocompletion);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 "\"google:suggesttype\":[\"QUERY\",\"ENTITY\"]}]", 2723 "\"google:suggesttype\":[\"QUERY\",\"ENTITY\"]}]",
2724 { { "x", "", "", "x", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, 2724 { { "x", "", "", "x", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED },
2725 { "xy", "", "", "xy", AutocompleteMatchType::SEARCH_SUGGEST }, 2725 { "xy", "", "", "xy", AutocompleteMatchType::SEARCH_SUGGEST },
2726 { "xy", "A", "p=v", "xy", 2726 { "xy", "A", "p=v", "xy",
2727 AutocompleteMatchType::SEARCH_SUGGEST_ENTITY }, 2727 AutocompleteMatchType::SEARCH_SUGGEST_ENTITY },
2728 kEmptyMatch, 2728 kEmptyMatch,
2729 kEmptyMatch 2729 kEmptyMatch
2730 }, 2730 },
2731 }, 2731 },
2732 }; 2732 };
2733 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2733 for (size_t i = 0; i < arraysize(cases); ++i) {
2734 QueryForInputAndWaitForFetcherResponses( 2734 QueryForInputAndWaitForFetcherResponses(
2735 ASCIIToUTF16(cases[i].input_text), false, cases[i].response_json, 2735 ASCIIToUTF16(cases[i].input_text), false, cases[i].response_json,
2736 std::string()); 2736 std::string());
2737 2737
2738 const ACMatches& matches = provider_->matches(); 2738 const ACMatches& matches = provider_->matches();
2739 ASSERT_FALSE(matches.empty()); 2739 ASSERT_FALSE(matches.empty());
2740 2740
2741 SCOPED_TRACE("for input with json = " + cases[i].response_json); 2741 SCOPED_TRACE("for input with json = " + cases[i].response_json);
2742 2742
2743 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); 2743 ASSERT_LE(matches.size(), arraysize(cases[i].matches));
2744 size_t j = 0; 2744 size_t j = 0;
2745 // Ensure that the returned matches equal the expectations. 2745 // Ensure that the returned matches equal the expectations.
2746 for (; j < matches.size(); ++j) { 2746 for (; j < matches.size(); ++j) {
2747 const Match& match = cases[i].matches[j]; 2747 const Match& match = cases[i].matches[j];
2748 SCOPED_TRACE(" and match index: " + base::IntToString(j)); 2748 SCOPED_TRACE(" and match index: " + base::IntToString(j));
2749 EXPECT_EQ(match.contents, 2749 EXPECT_EQ(match.contents,
2750 base::UTF16ToUTF8(matches[j].contents)); 2750 base::UTF16ToUTF8(matches[j].contents));
2751 EXPECT_EQ(match.description, 2751 EXPECT_EQ(match.description,
2752 base::UTF16ToUTF8(matches[j].description)); 2752 base::UTF16ToUTF8(matches[j].description));
2753 EXPECT_EQ(match.query_params, 2753 EXPECT_EQ(match.query_params,
2754 matches[j].search_terms_args->suggest_query_params); 2754 matches[j].search_terms_args->suggest_query_params);
2755 EXPECT_EQ(match.fill_into_edit, 2755 EXPECT_EQ(match.fill_into_edit,
2756 base::UTF16ToUTF8(matches[j].fill_into_edit)); 2756 base::UTF16ToUTF8(matches[j].fill_into_edit));
2757 EXPECT_EQ(match.type, matches[j].type); 2757 EXPECT_EQ(match.type, matches[j].type);
2758 } 2758 }
2759 // Ensure that no expected matches are missing. 2759 // Ensure that no expected matches are missing.
2760 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) { 2760 for (; j < arraysize(cases[i].matches); ++j) {
2761 SCOPED_TRACE(" and match index: " + base::IntToString(j)); 2761 SCOPED_TRACE(" and match index: " + base::IntToString(j));
2762 EXPECT_EQ(cases[i].matches[j].contents, kNotApplicable); 2762 EXPECT_EQ(cases[i].matches[j].contents, kNotApplicable);
2763 EXPECT_EQ(cases[i].matches[j].description, kNotApplicable); 2763 EXPECT_EQ(cases[i].matches[j].description, kNotApplicable);
2764 EXPECT_EQ(cases[i].matches[j].query_params, kNotApplicable); 2764 EXPECT_EQ(cases[i].matches[j].query_params, kNotApplicable);
2765 EXPECT_EQ(cases[i].matches[j].fill_into_edit, kNotApplicable); 2765 EXPECT_EQ(cases[i].matches[j].fill_into_edit, kNotApplicable);
2766 EXPECT_EQ(cases[i].matches[j].type, AutocompleteMatchType::NUM_TYPES); 2766 EXPECT_EQ(cases[i].matches[j].type, AutocompleteMatchType::NUM_TYPES);
2767 } 2767 }
2768 } 2768 }
2769 } 2769 }
2770 #endif // !defined(OS_WIN) 2770 #endif // !defined(OS_WIN)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 2849 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
2850 { { "a", false, AutocompleteMatchType::SEARCH_OTHER_ENGINE, true}, 2850 { { "a", false, AutocompleteMatchType::SEARCH_OTHER_ENGINE, true},
2851 { "k a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, 2851 { "k a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false },
2852 { "ab", false, AutocompleteMatchType::SEARCH_SUGGEST, false }, 2852 { "ab", false, AutocompleteMatchType::SEARCH_SUGGEST, false },
2853 { "c", false, AutocompleteMatchType::SEARCH_SUGGEST, true }, 2853 { "c", false, AutocompleteMatchType::SEARCH_SUGGEST, true },
2854 { "b", false, AutocompleteMatchType::SEARCH_SUGGEST, true } 2854 { "b", false, AutocompleteMatchType::SEARCH_SUGGEST, true }
2855 }, 2855 },
2856 } 2856 }
2857 }; 2857 };
2858 2858
2859 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2859 for (size_t i = 0; i < arraysize(cases); ++i) {
2860 QueryForInputAndWaitForFetcherResponses( 2860 QueryForInputAndWaitForFetcherResponses(
2861 ASCIIToUTF16(cases[i].input_text), 2861 ASCIIToUTF16(cases[i].input_text),
2862 cases[i].prefer_keyword_provider_results, 2862 cases[i].prefer_keyword_provider_results,
2863 cases[i].default_provider_response_json, 2863 cases[i].default_provider_response_json,
2864 cases[i].prefer_keyword_provider_results ? 2864 cases[i].prefer_keyword_provider_results ?
2865 cases[i].keyword_provider_response_json : std::string()); 2865 cases[i].keyword_provider_response_json : std::string());
2866 2866
2867 const std::string description = 2867 const std::string description =
2868 "for input with json =" + cases[i].default_provider_response_json; 2868 "for input with json =" + cases[i].default_provider_response_json;
2869 const ACMatches& matches = provider_->matches(); 2869 const ACMatches& matches = provider_->matches();
2870 // The top match must inline and score as highly as calculated verbatim. 2870 // The top match must inline and score as highly as calculated verbatim.
2871 ASSERT_FALSE(matches.empty()); 2871 ASSERT_FALSE(matches.empty());
2872 EXPECT_GE(matches[0].relevance, 1300); 2872 EXPECT_GE(matches[0].relevance, 1300);
2873 2873
2874 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); 2874 ASSERT_LE(matches.size(), arraysize(cases[i].matches));
2875 // Ensure that the returned matches equal the expectations. 2875 // Ensure that the returned matches equal the expectations.
2876 for (size_t j = 0; j < matches.size(); ++j) { 2876 for (size_t j = 0; j < matches.size(); ++j) {
2877 SCOPED_TRACE(description); 2877 SCOPED_TRACE(description);
2878 EXPECT_EQ(cases[i].matches[j].contents, 2878 EXPECT_EQ(cases[i].matches[j].contents,
2879 base::UTF16ToUTF8(matches[j].contents)); 2879 base::UTF16ToUTF8(matches[j].contents));
2880 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, 2880 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched,
2881 SearchProvider::ShouldPrefetch(matches[j])); 2881 SearchProvider::ShouldPrefetch(matches[j]));
2882 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); 2882 EXPECT_EQ(cases[i].matches[j].type, matches[j].type);
2883 EXPECT_EQ(cases[i].matches[j].from_keyword, 2883 EXPECT_EQ(cases[i].matches[j].from_keyword,
2884 matches[j].keyword == ASCIIToUTF16("k")); 2884 matches[j].keyword == ASCIIToUTF16("k"));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 "{\"google:suggesttype\":[\"QUERY\",\"QUERY\"]," 2947 "{\"google:suggesttype\":[\"QUERY\",\"QUERY\"],"
2948 "\"google:suggestrelevance\":[1, 2]}]", 2948 "\"google:suggestrelevance\":[1, 2]}]",
2949 { { "a", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, 2949 { { "a", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED },
2950 { "c", AutocompleteMatchType::SEARCH_SUGGEST }, 2950 { "c", AutocompleteMatchType::SEARCH_SUGGEST },
2951 { "b", AutocompleteMatchType::SEARCH_SUGGEST }, 2951 { "b", AutocompleteMatchType::SEARCH_SUGGEST },
2952 kEmptyMatch, 2952 kEmptyMatch,
2953 }, 2953 },
2954 }, 2954 },
2955 }; 2955 };
2956 2956
2957 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 2957 for (size_t i = 0; i < arraysize(cases); ++i) {
2958 ClearAllResults(); 2958 ClearAllResults();
2959 QueryForInputAndWaitForFetcherResponses( 2959 QueryForInputAndWaitForFetcherResponses(
2960 ASCIIToUTF16(cases[i].input_text), false, 2960 ASCIIToUTF16(cases[i].input_text), false,
2961 cases[i].default_provider_response_json, std::string()); 2961 cases[i].default_provider_response_json, std::string());
2962 2962
2963 const ACMatches& matches = provider_->matches(); 2963 const ACMatches& matches = provider_->matches();
2964 // The top match must inline and score as highly as calculated verbatim. 2964 // The top match must inline and score as highly as calculated verbatim.
2965 ASSERT_FALSE(matches.empty()); 2965 ASSERT_FALSE(matches.empty());
2966 EXPECT_GE(matches[0].relevance, 1300); 2966 EXPECT_GE(matches[0].relevance, 1300);
2967 2967
2968 SCOPED_TRACE("for case: " + base::IntToString(i)); 2968 SCOPED_TRACE("for case: " + base::IntToString(i));
2969 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); 2969 ASSERT_LE(matches.size(), arraysize(cases[i].matches));
2970 size_t j = 0; 2970 size_t j = 0;
2971 // Ensure that the returned matches equal the expectations. 2971 // Ensure that the returned matches equal the expectations.
2972 for (; j < matches.size(); ++j) { 2972 for (; j < matches.size(); ++j) {
2973 SCOPED_TRACE("and match: " + base::IntToString(j)); 2973 SCOPED_TRACE("and match: " + base::IntToString(j));
2974 EXPECT_EQ(cases[i].matches[j].contents, 2974 EXPECT_EQ(cases[i].matches[j].contents,
2975 base::UTF16ToUTF8(matches[j].contents)); 2975 base::UTF16ToUTF8(matches[j].contents));
2976 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); 2976 EXPECT_EQ(cases[i].matches[j].type, matches[j].type);
2977 } 2977 }
2978 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) { 2978 for (; j < arraysize(cases[i].matches); ++j) {
2979 SCOPED_TRACE("and match: " + base::IntToString(j)); 2979 SCOPED_TRACE("and match: " + base::IntToString(j));
2980 EXPECT_EQ(cases[i].matches[j].contents, kNotApplicable); 2980 EXPECT_EQ(cases[i].matches[j].contents, kNotApplicable);
2981 EXPECT_EQ(cases[i].matches[j].type, AutocompleteMatchType::NUM_TYPES); 2981 EXPECT_EQ(cases[i].matches[j].type, AutocompleteMatchType::NUM_TYPES);
2982 } 2982 }
2983 } 2983 }
2984 } 2984 }
2985 2985
2986 // Test that deletion url gets set on an AutocompleteMatch when available for a 2986 // Test that deletion url gets set on an AutocompleteMatch when available for a
2987 // personalized query or a personalized URL. 2987 // personalized query or a personalized URL.
2988 TEST_F(SearchProviderTest, ParseDeletionUrl) { 2988 TEST_F(SearchProviderTest, ParseDeletionUrl) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 { { "a", "", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, 3054 { { "a", "", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED },
3055 { "ac", "", AutocompleteMatchType::SEARCH_SUGGEST }, 3055 { "ac", "", AutocompleteMatchType::SEARCH_SUGGEST },
3056 { "ab", "", AutocompleteMatchType::SEARCH_SUGGEST }, 3056 { "ab", "", AutocompleteMatchType::SEARCH_SUGGEST },
3057 { "www.amazon.com", "", 3057 { "www.amazon.com", "",
3058 AutocompleteMatchType::NAVSUGGEST_PERSONALIZED }, 3058 AutocompleteMatchType::NAVSUGGEST_PERSONALIZED },
3059 kEmptyMatch, 3059 kEmptyMatch,
3060 }, 3060 },
3061 }, 3061 },
3062 }; 3062 };
3063 3063
3064 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 3064 for (size_t i = 0; i < arraysize(cases); ++i) {
3065 QueryForInputAndWaitForFetcherResponses( 3065 QueryForInputAndWaitForFetcherResponses(
3066 ASCIIToUTF16(cases[i].input_text), false, cases[i].response_json, 3066 ASCIIToUTF16(cases[i].input_text), false, cases[i].response_json,
3067 std::string()); 3067 std::string());
3068 3068
3069 const ACMatches& matches = provider_->matches(); 3069 const ACMatches& matches = provider_->matches();
3070 ASSERT_FALSE(matches.empty()); 3070 ASSERT_FALSE(matches.empty());
3071 3071
3072 SCOPED_TRACE("for input with json = " + cases[i].response_json); 3072 SCOPED_TRACE("for input with json = " + cases[i].response_json);
3073 3073
3074 for (size_t j = 0; j < matches.size(); ++j) { 3074 for (size_t j = 0; j < matches.size(); ++j) {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type); 3448 EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type);
3449 EXPECT_TRUE(matches[1].answer_contents.empty()); 3449 EXPECT_TRUE(matches[1].answer_contents.empty());
3450 EXPECT_TRUE(matches[1].answer_type.empty()); 3450 EXPECT_TRUE(matches[1].answer_type.empty());
3451 EXPECT_TRUE(matches[2].answer_contents.empty()); 3451 EXPECT_TRUE(matches[2].answer_contents.empty());
3452 EXPECT_TRUE(matches[2].answer_type.empty()); 3452 EXPECT_TRUE(matches[2].answer_type.empty());
3453 EXPECT_TRUE(matches[3].answer_contents.empty()); 3453 EXPECT_TRUE(matches[3].answer_contents.empty());
3454 EXPECT_TRUE(matches[3].answer_type.empty()); 3454 EXPECT_TRUE(matches[3].answer_type.empty());
3455 EXPECT_TRUE(matches[4].answer_contents.empty()); 3455 EXPECT_TRUE(matches[4].answer_contents.empty());
3456 EXPECT_TRUE(matches[4].answer_type.empty()); 3456 EXPECT_TRUE(matches[4].answer_type.empty());
3457 } 3457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698