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

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

Issue 18878007: Omnibox: Make the Controller Reorder Matches for Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/history_url_provider.h" 5 #include "chrome/browser/autocomplete/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 {"http://typedhost/untypedpath", "Intranet untyped", 1, 0}, 125 {"http://typedhost/untypedpath", "Intranet untyped", 1, 0},
126 126
127 {"http://x.com/one", "Internet", 2, 2}, 127 {"http://x.com/one", "Internet", 2, 2},
128 {"http://x.com/two", "Internet two", 1, 1}, 128 {"http://x.com/two", "Internet two", 1, 1},
129 {"http://x.com/three", "Internet three", 2, 2}, 129 {"http://x.com/three", "Internet three", 2, 2},
130 }; 130 };
131 131
132 class HistoryURLProviderTest : public testing::Test, 132 class HistoryURLProviderTest : public testing::Test,
133 public AutocompleteProviderListener { 133 public AutocompleteProviderListener {
134 public: 134 public:
135 struct UrlAndLegalDefault {
136 std::string url;
137 bool allowed_to_be_default_match;
138 };
139
135 HistoryURLProviderTest() 140 HistoryURLProviderTest()
136 : sort_matches_(false) { 141 : sort_matches_(false) {
137 HistoryQuickProvider::set_disabled(true); 142 HistoryQuickProvider::set_disabled(true);
138 } 143 }
139 144
140 virtual ~HistoryURLProviderTest() { 145 virtual ~HistoryURLProviderTest() {
141 HistoryQuickProvider::set_disabled(false); 146 HistoryQuickProvider::set_disabled(false);
142 } 147 }
143 148
144 // AutocompleteProviderListener: 149 // AutocompleteProviderListener:
(...skipping 16 matching lines...) Expand all
161 166
162 // Fills test data into the history system. 167 // Fills test data into the history system.
163 void FillData(); 168 void FillData();
164 169
165 // Runs an autocomplete query on |text| and checks to see that the returned 170 // Runs an autocomplete query on |text| and checks to see that the returned
166 // results' destination URLs match those provided. Also allows checking 171 // results' destination URLs match those provided. Also allows checking
167 // that the input type was identified correctly. 172 // that the input type was identified correctly.
168 void RunTest(const string16 text, 173 void RunTest(const string16 text,
169 const string16& desired_tld, 174 const string16& desired_tld,
170 bool prevent_inline_autocomplete, 175 bool prevent_inline_autocomplete,
171 const std::string* expected_urls, 176 const UrlAndLegalDefault* expected_urls,
172 size_t num_results, 177 size_t num_results,
173 AutocompleteInput::Type* identified_input_type); 178 AutocompleteInput::Type* identified_input_type);
174 179
175 // A version of the above without the final |type| output parameter. 180 // A version of the above without the final |type| output parameter.
176 void RunTest(const string16 text, 181 void RunTest(const string16 text,
177 const string16& desired_tld, 182 const string16& desired_tld,
178 bool prevent_inline_autocomplete, 183 bool prevent_inline_autocomplete,
179 const std::string* expected_urls, 184 const UrlAndLegalDefault* expected_urls,
180 size_t num_results) { 185 size_t num_results) {
181 AutocompleteInput::Type type; 186 AutocompleteInput::Type type;
182 return RunTest(text, desired_tld, prevent_inline_autocomplete, 187 return RunTest(text, desired_tld, prevent_inline_autocomplete,
183 expected_urls, num_results, &type); 188 expected_urls, num_results, &type);
184 } 189 }
185 190
186 content::TestBrowserThreadBundle thread_bundle_; 191 content::TestBrowserThreadBundle thread_bundle_;
187 ACMatches matches_; 192 ACMatches matches_;
188 scoped_ptr<TestingProfile> profile_; 193 scoped_ptr<TestingProfile> profile_;
189 HistoryService* history_service_; 194 HistoryService* history_service_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 GURL("http://p/"), UTF8ToUTF16("p"), 0, 0, 255 GURL("http://p/"), UTF8ToUTF16("p"), 0, 0,
251 Time::Now() - 256 Time::Now() -
252 TimeDelta::FromDays(history::kLowQualityMatchAgeLimitInDays - 1), 257 TimeDelta::FromDays(history::kLowQualityMatchAgeLimitInDays - 1),
253 false, history::SOURCE_BROWSED); 258 false, history::SOURCE_BROWSED);
254 } 259 }
255 260
256 void HistoryURLProviderTest::RunTest( 261 void HistoryURLProviderTest::RunTest(
257 const string16 text, 262 const string16 text,
258 const string16& desired_tld, 263 const string16& desired_tld,
259 bool prevent_inline_autocomplete, 264 bool prevent_inline_autocomplete,
260 const std::string* expected_urls, 265 const UrlAndLegalDefault* expected_urls,
261 size_t num_results, 266 size_t num_results,
262 AutocompleteInput::Type* identified_input_type) { 267 AutocompleteInput::Type* identified_input_type) {
263 AutocompleteInput input(text, string16::npos, desired_tld, GURL(), 268 AutocompleteInput input(text, string16::npos, desired_tld, GURL(),
264 AutocompleteInput::INVALID_SPEC, 269 AutocompleteInput::INVALID_SPEC,
265 prevent_inline_autocomplete, false, true, 270 prevent_inline_autocomplete, false, true,
266 AutocompleteInput::ALL_MATCHES); 271 AutocompleteInput::ALL_MATCHES);
267 *identified_input_type = input.type(); 272 *identified_input_type = input.type();
268 autocomplete_->Start(input, false); 273 autocomplete_->Start(input, false);
269 if (!autocomplete_->done()) 274 if (!autocomplete_->done())
270 base::MessageLoop::current()->Run(); 275 base::MessageLoop::current()->Run();
271 276
272 matches_ = autocomplete_->matches(); 277 matches_ = autocomplete_->matches();
273 if (sort_matches_) { 278 if (sort_matches_) {
274 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) 279 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i)
275 i->ComputeStrippedDestinationURL(profile_.get()); 280 i->ComputeStrippedDestinationURL(profile_.get());
276 std::sort(matches_.begin(), matches_.end(), 281 std::sort(matches_.begin(), matches_.end(),
277 &AutocompleteMatch::DestinationSortFunc); 282 &AutocompleteMatch::DestinationSortFunc);
278 matches_.erase(std::unique(matches_.begin(), matches_.end(), 283 matches_.erase(std::unique(matches_.begin(), matches_.end(),
279 &AutocompleteMatch::DestinationsEqual), 284 &AutocompleteMatch::DestinationsEqual),
280 matches_.end()); 285 matches_.end());
281 std::sort(matches_.begin(), matches_.end(), 286 std::sort(matches_.begin(), matches_.end(),
282 &AutocompleteMatch::MoreRelevant); 287 &AutocompleteMatch::MoreRelevant);
283 } 288 }
284 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text 289 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text
285 << "\nTLD: \"" << desired_tld << "\""; 290 << "\nTLD: \"" << desired_tld << "\"";
286 for (size_t i = 0; i < num_results; ++i) 291 for (size_t i = 0; i < num_results; ++i) {
287 EXPECT_EQ(expected_urls[i], matches_[i].destination_url.spec()); 292 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec());
293 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match,
294 matches_[i].allowed_to_be_default_match);
295 }
288 } 296 }
289 297
290 TEST_F(HistoryURLProviderTest, PromoteShorterURLs) { 298 TEST_F(HistoryURLProviderTest, PromoteShorterURLs) {
291 // Test that hosts get synthesized below popular pages. 299 // Test that hosts get synthesized below popular pages.
292 const std::string expected_nonsynth[] = { 300 const UrlAndLegalDefault expected_nonsynth[] = {
293 "http://slashdot.org/favorite_page.html", 301 { "http://slashdot.org/favorite_page.html", false },
294 "http://slashdot.org/", 302 { "http://slashdot.org/", false }
295 }; 303 };
296 RunTest(ASCIIToUTF16("slash"), string16(), true, expected_nonsynth, 304 RunTest(ASCIIToUTF16("slash"), string16(), true, expected_nonsynth,
297 arraysize(expected_nonsynth)); 305 arraysize(expected_nonsynth));
298 306
299 // Test that hosts get synthesized above less popular pages. 307 // Test that hosts get synthesized above less popular pages.
300 const std::string expected_synth[] = { 308 const UrlAndLegalDefault expected_synth[] = {
301 "http://kerneltrap.org/", 309 { "http://kerneltrap.org/", false },
302 "http://kerneltrap.org/not_very_popular.html", 310 { "http://kerneltrap.org/not_very_popular.html", false }
303 }; 311 };
304 RunTest(ASCIIToUTF16("kernel"), string16(), true, expected_synth, 312 RunTest(ASCIIToUTF16("kernel"), string16(), true, expected_synth,
305 arraysize(expected_synth)); 313 arraysize(expected_synth));
306 314
307 // Test that unpopular pages are ignored completely. 315 // Test that unpopular pages are ignored completely.
308 RunTest(ASCIIToUTF16("fresh"), string16(), true, NULL, 0); 316 RunTest(ASCIIToUTF16("fresh"), string16(), true, NULL, 0);
309 317
310 // Test that if we create or promote shorter suggestions that would not 318 // Test that if we create or promote shorter suggestions that would not
311 // normally be inline autocompletable, we make them inline autocompletable if 319 // normally be inline autocompletable, we make them inline autocompletable if
312 // the original suggestion (that we replaced as "top") was inline 320 // the original suggestion (that we replaced as "top") was inline
313 // autocompletable. 321 // autocompletable.
314 const std::string expected_synthesisa[] = { 322 const UrlAndLegalDefault expected_synthesisa[] = {
315 "http://synthesisatest.com/", 323 { "http://synthesisatest.com/", true },
316 "http://synthesisatest.com/foo/", 324 { "http://synthesisatest.com/foo/", true }
317 }; 325 };
318 RunTest(ASCIIToUTF16("synthesisa"), string16(), false, expected_synthesisa, 326 RunTest(ASCIIToUTF16("synthesisa"), string16(), false, expected_synthesisa,
319 arraysize(expected_synthesisa)); 327 arraysize(expected_synthesisa));
320 EXPECT_LT(matches_.front().relevance, 1200); 328 EXPECT_LT(matches_.front().relevance, 1200);
321 const std::string expected_synthesisb[] = { 329 const UrlAndLegalDefault expected_synthesisb[] = {
322 "http://synthesisbtest.com/foo/", 330 { "http://synthesisbtest.com/foo/", true },
323 "http://synthesisbtest.com/foo/bar.html", 331 { "http://synthesisbtest.com/foo/bar.html", true }
324 }; 332 };
325 RunTest(ASCIIToUTF16("synthesisb"), string16(), false, expected_synthesisb, 333 RunTest(ASCIIToUTF16("synthesisb"), string16(), false, expected_synthesisb,
326 arraysize(expected_synthesisb)); 334 arraysize(expected_synthesisb));
327 EXPECT_GE(matches_.front().relevance, 1410); 335 EXPECT_GE(matches_.front().relevance, 1410);
328 336
329 // Test that if we have a synthesized host that matches a suggestion, they 337 // Test that if we have a synthesized host that matches a suggestion, they
330 // get combined into one. 338 // get combined into one.
331 const std::string expected_combine[] = { 339 const UrlAndLegalDefault expected_combine[] = {
332 "http://news.google.com/", 340 { "http://news.google.com/", false },
333 "http://news.google.com/?ned=us&topic=n", 341 { "http://news.google.com/?ned=us&topic=n", false },
334 }; 342 };
335 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("news"), string16(), true, 343 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("news"), string16(), true,
336 expected_combine, arraysize(expected_combine))); 344 expected_combine, arraysize(expected_combine)));
337 // The title should also have gotten set properly on the host for the 345 // The title should also have gotten set properly on the host for the
338 // synthesized one, since it was also in the results. 346 // synthesized one, since it was also in the results.
339 EXPECT_EQ(ASCIIToUTF16("Google News"), matches_.front().description); 347 EXPECT_EQ(ASCIIToUTF16("Google News"), matches_.front().description);
340 348
341 // Test that short URL matching works correctly as the user types more 349 // Test that short URL matching works correctly as the user types more
342 // (several tests): 350 // (several tests):
343 // The entry for foo.com is the best of all five foo.com* entries. 351 // The entry for foo.com is the best of all five foo.com* entries.
344 const std::string short_1[] = { 352 const UrlAndLegalDefault short_1[] = {
345 "http://foo.com/", 353 { "http://foo.com/", false },
346 "http://foo.com/dir/another/again/myfile.html", 354 { "http://foo.com/dir/another/again/myfile.html", false },
347 "http://foo.com/dir/", 355 { "http://foo.com/dir/", false }
348 }; 356 };
349 RunTest(ASCIIToUTF16("foo"), string16(), true, short_1, arraysize(short_1)); 357 RunTest(ASCIIToUTF16("foo"), string16(), true, short_1, arraysize(short_1));
350 358
351 // When the user types the whole host, make sure we don't get two results for 359 // When the user types the whole host, make sure we don't get two results for
352 // it. 360 // it.
353 const std::string short_2[] = { 361 const UrlAndLegalDefault short_2[] = {
354 "http://foo.com/", 362 { "http://foo.com/", true },
355 "http://foo.com/dir/another/again/myfile.html", 363 { "http://foo.com/dir/another/again/myfile.html", false },
356 "http://foo.com/dir/", 364 { "http://foo.com/dir/", false },
357 "http://foo.com/dir/another/", 365 { "http://foo.com/dir/another/", false }
358 }; 366 };
359 RunTest(ASCIIToUTF16("foo.com"), string16(), true, short_2, 367 RunTest(ASCIIToUTF16("foo.com"), string16(), true, short_2,
360 arraysize(short_2)); 368 arraysize(short_2));
361 RunTest(ASCIIToUTF16("foo.com/"), string16(), true, short_2, 369 RunTest(ASCIIToUTF16("foo.com/"), string16(), true, short_2,
362 arraysize(short_2)); 370 arraysize(short_2));
363 371
364 // The filename is the second best of the foo.com* entries, but there is a 372 // The filename is the second best of the foo.com* entries, but there is a
365 // shorter URL that's "good enough". The host doesn't match the user input 373 // shorter URL that's "good enough". The host doesn't match the user input
366 // and so should not appear. 374 // and so should not appear.
367 const std::string short_3[] = { 375 const UrlAndLegalDefault short_3[] = {
368 "http://foo.com/d", 376 { "http://foo.com/d", true },
369 "http://foo.com/dir/another/", 377 { "http://foo.com/dir/another/", false },
370 "http://foo.com/dir/another/again/myfile.html", 378 { "http://foo.com/dir/another/again/myfile.html", false },
371 "http://foo.com/dir/", 379 { "http://foo.com/dir/", false }
372 }; 380 };
373 RunTest(ASCIIToUTF16("foo.com/d"), string16(), true, short_3, 381 RunTest(ASCIIToUTF16("foo.com/d"), string16(), true, short_3,
374 arraysize(short_3)); 382 arraysize(short_3));
375 383
376 // We shouldn't promote shorter URLs than the best if they're not good 384 // We shouldn't promote shorter URLs than the best if they're not good
377 // enough. 385 // enough.
378 const std::string short_4[] = { 386 const UrlAndLegalDefault short_4[] = {
379 "http://foo.com/dir/another/a", 387 { "http://foo.com/dir/another/a", true },
380 "http://foo.com/dir/another/again/myfile.html", 388 { "http://foo.com/dir/another/again/myfile.html", false },
381 "http://foo.com/dir/another/again/", 389 { "http://foo.com/dir/another/again/", false }
382 }; 390 };
383 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4, 391 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4,
384 arraysize(short_4)); 392 arraysize(short_4));
385 393
386 // Exact matches should always be best no matter how much more another match 394 // Exact matches should always be best no matter how much more another match
387 // has been typed. 395 // has been typed.
388 const std::string short_5a[] = { 396 const UrlAndLegalDefault short_5a[] = {
389 "http://gooey/", 397 { "http://gooey/", true },
390 "http://www.google.com/", 398 { "http://www.google.com/", true },
391 "http://go/", 399 { "http://go/", true }
392 }; 400 };
393 const std::string short_5b[] = { 401 const UrlAndLegalDefault short_5b[] = {
394 "http://go/", 402 { "http://go/", true },
395 "http://gooey/", 403 { "http://gooey/", true },
396 "http://www.google.com/", 404 { "http://www.google.com/", true }
397 }; 405 };
398 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a)); 406 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a));
399 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b)); 407 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b));
400 } 408 }
401 409
402 TEST_F(HistoryURLProviderTest, CullRedirects) { 410 TEST_F(HistoryURLProviderTest, CullRedirects) {
403 // URLs we will be using, plus the visit counts they will initially get 411 // URLs we will be using, plus the visit counts they will initially get
404 // (the redirect set below will also increment the visit counts). We want 412 // (the redirect set below will also increment the visit counts). We want
405 // the results to be in A,B,C order. Note also that our visit counts are 413 // the results to be in A,B,C order. Note also that our visit counts are
406 // all high enough so that domain synthesizing won't get triggered. 414 // all high enough so that domain synthesizing won't get triggered.
(...skipping 20 matching lines...) Expand all
427 redirects_to_a.push_back(GURL(test_cases[2].url)); 435 redirects_to_a.push_back(GURL(test_cases[2].url));
428 redirects_to_a.push_back(GURL(test_cases[0].url)); 436 redirects_to_a.push_back(GURL(test_cases[0].url));
429 history_service_->AddPage(GURL(test_cases[0].url), base::Time::Now(), 437 history_service_->AddPage(GURL(test_cases[0].url), base::Time::Now(),
430 NULL, 0, GURL(), redirects_to_a, content::PAGE_TRANSITION_TYPED, 438 NULL, 0, GURL(), redirects_to_a, content::PAGE_TRANSITION_TYPED,
431 history::SOURCE_BROWSED, true); 439 history::SOURCE_BROWSED, true);
432 440
433 // Because all the results are part of a redirect chain with other results, 441 // Because all the results are part of a redirect chain with other results,
434 // all but the first one (A) should be culled. We should get the default 442 // all but the first one (A) should be culled. We should get the default
435 // "what you typed" result, plus this one. 443 // "what you typed" result, plus this one.
436 const string16 typing(ASCIIToUTF16("http://redirects/")); 444 const string16 typing(ASCIIToUTF16("http://redirects/"));
437 const std::string expected_results[] = { 445 const UrlAndLegalDefault expected_results[] = {
438 UTF16ToUTF8(typing), 446 { UTF16ToUTF8(typing), true },
439 test_cases[0].url, 447 { test_cases[0].url, false }
440 }; 448 };
441 RunTest(typing, string16(), true, expected_results, 449 RunTest(typing, string16(), true, expected_results,
442 arraysize(expected_results)); 450 arraysize(expected_results));
443 } 451 }
444 452
445 TEST_F(HistoryURLProviderTest, WhatYouTyped) { 453 TEST_F(HistoryURLProviderTest, WhatYouTyped) {
446 // Make sure we suggest a What You Typed match at the right times. 454 // Make sure we suggest a What You Typed match at the right times.
447 RunTest(ASCIIToUTF16("wytmatch"), string16(), false, NULL, 0); 455 RunTest(ASCIIToUTF16("wytmatch"), string16(), false, NULL, 0);
448 RunTest(ASCIIToUTF16("wytmatch foo bar"), string16(), false, NULL, 0); 456 RunTest(ASCIIToUTF16("wytmatch foo bar"), string16(), false, NULL, 0);
449 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), string16(), false, NULL, 0); 457 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), string16(), false, NULL, 0);
450 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), string16(), false, NULL, 0); 458 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), string16(), false, NULL, 0);
451 459
452 const std::string results_1[] = {"http://www.wytmatch.com/"}; 460 const UrlAndLegalDefault results_1[] = {
461 { "http://www.wytmatch.com/", true }
462 };
453 RunTest(ASCIIToUTF16("wytmatch"), ASCIIToUTF16("com"), false, results_1, 463 RunTest(ASCIIToUTF16("wytmatch"), ASCIIToUTF16("com"), false, results_1,
454 arraysize(results_1)); 464 arraysize(results_1));
455 465
456 const std::string results_2[] = {"http://wytmatch%20foo%20bar/"}; 466 const UrlAndLegalDefault results_2[] = {
467 { "http://wytmatch%20foo%20bar/", true }
468 };
457 RunTest(ASCIIToUTF16("http://wytmatch foo bar"), string16(), false, results_2, 469 RunTest(ASCIIToUTF16("http://wytmatch foo bar"), string16(), false, results_2,
458 arraysize(results_2)); 470 arraysize(results_2));
459 471
460 const std::string results_3[] = {"https://wytmatch%20foo%20bar/"}; 472 const UrlAndLegalDefault results_3[] = {
473 { "https://wytmatch%20foo%20bar/", true }
474 };
461 RunTest(ASCIIToUTF16("https://wytmatch foo bar"), string16(), false, 475 RunTest(ASCIIToUTF16("https://wytmatch foo bar"), string16(), false,
462 results_3, arraysize(results_3)); 476 results_3, arraysize(results_3));
463 } 477 }
464 478
465 TEST_F(HistoryURLProviderTest, Fixup) { 479 TEST_F(HistoryURLProviderTest, Fixup) {
466 // Test for various past crashes we've had. 480 // Test for various past crashes we've had.
467 RunTest(ASCIIToUTF16("\\"), string16(), false, NULL, 0); 481 RunTest(ASCIIToUTF16("\\"), string16(), false, NULL, 0);
468 RunTest(ASCIIToUTF16("#"), string16(), false, NULL, 0); 482 RunTest(ASCIIToUTF16("#"), string16(), false, NULL, 0);
469 RunTest(ASCIIToUTF16("%20"), string16(), false, NULL, 0); 483 RunTest(ASCIIToUTF16("%20"), string16(), false, NULL, 0);
470 const std::string fixup_crash[] = {"http://%EF%BD%A5@s/"}; 484 const UrlAndLegalDefault fixup_crash[] = {
485 { "http://%EF%BD%A5@s/", true }
486 };
471 RunTest(WideToUTF16(L"\uff65@s"), string16(), false, fixup_crash, 487 RunTest(WideToUTF16(L"\uff65@s"), string16(), false, fixup_crash,
472 arraysize(fixup_crash)); 488 arraysize(fixup_crash));
473 RunTest(WideToUTF16(L"\u2015\u2015@ \uff7c"), string16(), false, NULL, 0); 489 RunTest(WideToUTF16(L"\u2015\u2015@ \uff7c"), string16(), false, NULL, 0);
474 490
475 // Fixing up "file:" should result in an inline autocomplete offset of just 491 // Fixing up "file:" should result in an inline autocomplete offset of just
476 // after "file:", not just after "file://". 492 // after "file:", not just after "file://".
477 const string16 input_1(ASCIIToUTF16("file:")); 493 const string16 input_1(ASCIIToUTF16("file:"));
478 const std::string fixup_1[] = {"file:///C:/foo.txt"}; 494 const UrlAndLegalDefault fixup_1[] = {
495 { "file:///C:/foo.txt", true }
496 };
479 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, string16(), false, fixup_1, 497 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, string16(), false, fixup_1,
480 arraysize(fixup_1))); 498 arraysize(fixup_1)));
481 EXPECT_EQ(ASCIIToUTF16("///C:/foo.txt"), 499 EXPECT_EQ(ASCIIToUTF16("///C:/foo.txt"),
482 matches_.front().inline_autocompletion); 500 matches_.front().inline_autocompletion);
483 501
484 // Fixing up "http:/" should result in an inline autocomplete offset of just 502 // Fixing up "http:/" should result in an inline autocomplete offset of just
485 // after "http:/", not just after "http:". 503 // after "http:/", not just after "http:".
486 const string16 input_2(ASCIIToUTF16("http:/")); 504 const string16 input_2(ASCIIToUTF16("http:/"));
487 const std::string fixup_2[] = { 505 const UrlAndLegalDefault fixup_2[] = {
488 "http://bogussite.com/a", 506 { "http://bogussite.com/a", true },
489 "http://bogussite.com/b", 507 { "http://bogussite.com/b", true },
490 "http://bogussite.com/c", 508 { "http://bogussite.com/c", true }
491 }; 509 };
492 ASSERT_NO_FATAL_FAILURE(RunTest(input_2, string16(), false, fixup_2, 510 ASSERT_NO_FATAL_FAILURE(RunTest(input_2, string16(), false, fixup_2,
493 arraysize(fixup_2))); 511 arraysize(fixup_2)));
494 EXPECT_EQ(ASCIIToUTF16("/bogussite.com/a"), 512 EXPECT_EQ(ASCIIToUTF16("/bogussite.com/a"),
495 matches_.front().inline_autocompletion); 513 matches_.front().inline_autocompletion);
496 514
497 // Adding a TLD to a small number like "56" should result in "www.56.com" 515 // Adding a TLD to a small number like "56" should result in "www.56.com"
498 // rather than "0.0.0.56.com". 516 // rather than "0.0.0.56.com".
499 const std::string fixup_3[] = {"http://www.56.com/"}; 517 const UrlAndLegalDefault fixup_3[] = {
518 { "http://www.56.com/", true }
519 };
500 RunTest(ASCIIToUTF16("56"), ASCIIToUTF16("com"), true, fixup_3, 520 RunTest(ASCIIToUTF16("56"), ASCIIToUTF16("com"), true, fixup_3,
501 arraysize(fixup_3)); 521 arraysize(fixup_3));
502 522
503 // An input looks like a IP address like "127.0.0.1" should result in 523 // An input looks like a IP address like "127.0.0.1" should result in
504 // "http://127.0.0.1/". 524 // "http://127.0.0.1/".
505 const std::string fixup_4[] = {"http://127.0.0.1/"}; 525 const UrlAndLegalDefault fixup_4[] = {
526 { "http://127.0.0.1/", true }
527 };
506 RunTest(ASCIIToUTF16("127.0.0.1"), string16(), false, fixup_4, 528 RunTest(ASCIIToUTF16("127.0.0.1"), string16(), false, fixup_4,
507 arraysize(fixup_4)); 529 arraysize(fixup_4));
508 530
509 // An number "17173" should result in "http://www.17173.com/" in db. 531 // An number "17173" should result in "http://www.17173.com/" in db.
510 const std::string fixup_5[] = {"http://www.17173.com/"}; 532 const UrlAndLegalDefault fixup_5[] = {
533 { "http://www.17173.com/", true }
534 };
511 RunTest(ASCIIToUTF16("17173"), string16(), false, fixup_5, 535 RunTest(ASCIIToUTF16("17173"), string16(), false, fixup_5,
512 arraysize(fixup_5)); 536 arraysize(fixup_5));
513 } 537 }
514 538
515 // Make sure the results for the input 'p' don't change between the first and 539 // Make sure the results for the input 'p' don't change between the first and
516 // second passes. 540 // second passes.
517 TEST_F(HistoryURLProviderTest, EmptyVisits) { 541 TEST_F(HistoryURLProviderTest, EmptyVisits) {
518 // Wait for history to create the in memory DB. 542 // Wait for history to create the in memory DB.
519 profile_->BlockUntilHistoryProcessesPendingRequests(); 543 profile_->BlockUntilHistoryProcessesPendingRequests();
520 544
(...skipping 15 matching lines...) Expand all
536 EXPECT_TRUE(autocomplete_->done()); 560 EXPECT_TRUE(autocomplete_->done());
537 matches_ = autocomplete_->matches(); 561 matches_ = autocomplete_->matches();
538 ASSERT_GT(matches_.size(), 0u); 562 ASSERT_GT(matches_.size(), 0u);
539 EXPECT_EQ(GURL("http://pandora.com/"), matches_[0].destination_url); 563 EXPECT_EQ(GURL("http://pandora.com/"), matches_[0].destination_url);
540 EXPECT_EQ(pandora_relevance, matches_[0].relevance); 564 EXPECT_EQ(pandora_relevance, matches_[0].relevance);
541 } 565 }
542 566
543 TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { 567 TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) {
544 // Ensure that we will still produce matches for navigation when there is no 568 // Ensure that we will still produce matches for navigation when there is no
545 // database. 569 // database.
546 std::string navigation_1[] = {"http://test.com/"}; 570 UrlAndLegalDefault navigation_1[] = {
571 { "http://test.com/", true }
572 };
547 RunTest(ASCIIToUTF16("test.com"), string16(), false, navigation_1, 573 RunTest(ASCIIToUTF16("test.com"), string16(), false, navigation_1,
548 arraysize(navigation_1)); 574 arraysize(navigation_1));
549 575
550 std::string navigation_2[] = {"http://slash/"}; 576 UrlAndLegalDefault navigation_2[] = {
577 { "http://slash/", true }
578 };
551 RunTest(ASCIIToUTF16("slash"), string16(), false, navigation_2, 579 RunTest(ASCIIToUTF16("slash"), string16(), false, navigation_2,
552 arraysize(navigation_2)); 580 arraysize(navigation_2));
553 581
554 RunTest(ASCIIToUTF16("this is a query"), string16(), false, NULL, 0); 582 RunTest(ASCIIToUTF16("this is a query"), string16(), false, NULL, 0);
555 } 583 }
556 584
557 TEST_F(HistoryURLProviderTest, DontAutocompleteOnTrailingWhitespace) { 585 TEST_F(HistoryURLProviderTest, DontAutocompleteOnTrailingWhitespace) {
558 AutocompleteInput input(ASCIIToUTF16("slash "), string16::npos, string16(), 586 AutocompleteInput input(ASCIIToUTF16("slash "), string16::npos, string16(),
559 GURL(), AutocompleteInput::INVALID_SPEC, false, false, 587 GURL(), AutocompleteInput::INVALID_SPEC, false, false,
560 true, AutocompleteInput::ALL_MATCHES); 588 true, AutocompleteInput::ALL_MATCHES);
561 autocomplete_->Start(input, false); 589 autocomplete_->Start(input, false);
562 if (!autocomplete_->done()) 590 if (!autocomplete_->done())
563 base::MessageLoop::current()->Run(); 591 base::MessageLoop::current()->Run();
564 592
565 // None of the matches should attempt to autocomplete. 593 // None of the matches should attempt to autocomplete.
566 matches_ = autocomplete_->matches(); 594 matches_ = autocomplete_->matches();
567 for (size_t i = 0; i < matches_.size(); ++i) 595 for (size_t i = 0; i < matches_.size(); ++i) {
568 EXPECT_TRUE(matches_[i].inline_autocompletion.empty()); 596 EXPECT_TRUE(matches_[i].inline_autocompletion.empty());
597 EXPECT_FALSE(matches_[i].allowed_to_be_default_match);
598 }
569 } 599 }
570 600
571 TEST_F(HistoryURLProviderTest, TreatEmailsAsSearches) { 601 TEST_F(HistoryURLProviderTest, TreatEmailsAsSearches) {
572 // Visiting foo.com should not make this string be treated as a navigation. 602 // Visiting foo.com should not make this string be treated as a navigation.
573 // That means the result should be scored around 1200 ("what you typed") 603 // That means the result should be scored around 1200 ("what you typed")
574 // and not 1400+. 604 // and not 1400+.
575 const std::string expected[] = {"http://user@foo.com/"}; 605 const UrlAndLegalDefault expected[] = {
606 { "http://user@foo.com/", true }
607 };
576 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("user@foo.com"), string16(), 608 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("user@foo.com"), string16(),
577 false, expected, arraysize(expected))); 609 false, expected, arraysize(expected)));
578 EXPECT_LE(1200, matches_[0].relevance); 610 EXPECT_LE(1200, matches_[0].relevance);
579 EXPECT_LT(matches_[0].relevance, 1210); 611 EXPECT_LT(matches_[0].relevance, 1210);
580 } 612 }
581 613
582 TEST_F(HistoryURLProviderTest, IntranetURLsWithPaths) { 614 TEST_F(HistoryURLProviderTest, IntranetURLsWithPaths) {
583 struct TestCase { 615 struct TestCase {
584 const char* input; 616 const char* input;
585 int relevance; 617 int relevance;
586 } test_cases[] = { 618 } test_cases[] = {
587 { "fooey", 0 }, 619 { "fooey", 0 },
588 { "fooey/", 1200 }, // 1200 for URL would still navigate by default. 620 { "fooey/", 1200 }, // 1200 for URL would still navigate by default.
589 { "fooey/a", 1200 }, // 1200 for UNKNOWN would not. 621 { "fooey/a", 1200 }, // 1200 for UNKNOWN would not.
590 { "fooey/a b", 1200 }, // Also UNKNOWN. 622 { "fooey/a b", 1200 }, // Also UNKNOWN.
591 { "gooey", 1410 }, 623 { "gooey", 1410 },
592 { "gooey/", 1410 }, 624 { "gooey/", 1410 },
593 { "gooey/a", 1400 }, 625 { "gooey/a", 1400 },
594 { "gooey/a b", 1400 }, 626 { "gooey/a b", 1400 },
595 }; 627 };
596 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 628 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
597 SCOPED_TRACE(test_cases[i].input); 629 SCOPED_TRACE(test_cases[i].input);
598 if (test_cases[i].relevance == 0) { 630 if (test_cases[i].relevance == 0) {
599 RunTest(ASCIIToUTF16(test_cases[i].input), string16(), false, NULL, 0); 631 RunTest(ASCIIToUTF16(test_cases[i].input), string16(), false, NULL, 0);
600 } else { 632 } else {
601 const std::string output[] = { 633 const UrlAndLegalDefault output[] = {
602 URLFixerUpper::FixupURL(test_cases[i].input, std::string()).spec() 634 { URLFixerUpper::FixupURL(test_cases[i].input, std::string()).spec(),
635 true }
603 }; 636 };
604 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), 637 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input),
605 string16(), false, output, arraysize(output))); 638 string16(), false, output, arraysize(output)));
606 // Actual relevance should be at least what test_cases expects and 639 // Actual relevance should be at least what test_cases expects and
607 // and no more than 10 more. 640 // and no more than 10 more.
608 EXPECT_LE(test_cases[i].relevance, matches_[0].relevance); 641 EXPECT_LE(test_cases[i].relevance, matches_[0].relevance);
609 EXPECT_LT(matches_[0].relevance, test_cases[i].relevance + 10); 642 EXPECT_LT(matches_[0].relevance, test_cases[i].relevance + 10);
610 } 643 }
611 } 644 }
612 } 645 }
613 646
614 TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) { 647 TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) {
615 struct TestCase { 648 struct TestCase {
616 const char* input; 649 const char* input;
617 int relevance; 650 int relevance;
618 AutocompleteInput::Type type; 651 AutocompleteInput::Type type;
619 } test_cases[] = { 652 } test_cases[] = {
620 { "gooey", 1410, AutocompleteInput::UNKNOWN }, 653 { "gooey", 1410, AutocompleteInput::UNKNOWN },
621 { "gooey/", 1410, AutocompleteInput::URL }, 654 { "gooey/", 1410, AutocompleteInput::URL },
622 { "gooey#", 1200, AutocompleteInput::UNKNOWN }, 655 { "gooey#", 1200, AutocompleteInput::UNKNOWN },
623 { "gooey/#", 1200, AutocompleteInput::URL }, 656 { "gooey/#", 1200, AutocompleteInput::URL },
624 { "gooey#foo", 1200, AutocompleteInput::UNKNOWN }, 657 { "gooey#foo", 1200, AutocompleteInput::UNKNOWN },
625 { "gooey/#foo", 1200, AutocompleteInput::URL }, 658 { "gooey/#foo", 1200, AutocompleteInput::URL },
626 { "gooey# foo", 1200, AutocompleteInput::UNKNOWN }, 659 { "gooey# foo", 1200, AutocompleteInput::UNKNOWN },
627 { "gooey/# foo", 1200, AutocompleteInput::URL }, 660 { "gooey/# foo", 1200, AutocompleteInput::URL },
628 }; 661 };
629 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 662 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
630 SCOPED_TRACE(test_cases[i].input); 663 SCOPED_TRACE(test_cases[i].input);
631 const std::string output[] = { 664 const UrlAndLegalDefault output[] = {
632 URLFixerUpper::FixupURL(test_cases[i].input, std::string()).spec() 665 { URLFixerUpper::FixupURL(test_cases[i].input, std::string()).spec(),
666 true }
633 }; 667 };
634 AutocompleteInput::Type type; 668 AutocompleteInput::Type type;
635 ASSERT_NO_FATAL_FAILURE( 669 ASSERT_NO_FATAL_FAILURE(
636 RunTest(ASCIIToUTF16(test_cases[i].input), 670 RunTest(ASCIIToUTF16(test_cases[i].input),
637 string16(), false, output, arraysize(output), &type)); 671 string16(), false, output, arraysize(output), &type));
638 // Actual relevance should be at least what test_cases expects and 672 // Actual relevance should be at least what test_cases expects and
639 // and no more than 10 more. 673 // and no more than 10 more.
640 EXPECT_LE(test_cases[i].relevance, matches_[0].relevance); 674 EXPECT_LE(test_cases[i].relevance, matches_[0].relevance);
641 EXPECT_LT(matches_[0].relevance, test_cases[i].relevance + 10); 675 EXPECT_LT(matches_[0].relevance, test_cases[i].relevance + 10);
642 // Input type should be what we expect. This is important because 676 // Input type should be what we expect. This is important because
643 // this provider counts on SearchProvider to give queries a relevance 677 // this provider counts on SearchProvider to give queries a relevance
644 // score >1200 for UNKNOWN inputs and <1200 for URL inputs. (That's 678 // score >1200 for UNKNOWN inputs and <1200 for URL inputs. (That's
645 // already tested in search_provider_unittest.cc.) For this test 679 // already tested in search_provider_unittest.cc.) For this test
646 // here to test that the user sees the correct behavior, it needs 680 // here to test that the user sees the correct behavior, it needs
647 // to check that the input type was identified correctly. 681 // to check that the input type was identified correctly.
648 EXPECT_EQ(test_cases[i].type, type); 682 EXPECT_EQ(test_cases[i].type, type);
649 } 683 }
650 } 684 }
651 685
652 // Makes sure autocompletion happens for intranet sites that have been 686 // Makes sure autocompletion happens for intranet sites that have been
653 // previoulsy visited. 687 // previoulsy visited.
654 TEST_F(HistoryURLProviderTest, IntranetURLCompletion) { 688 TEST_F(HistoryURLProviderTest, IntranetURLCompletion) {
655 sort_matches_ = true; 689 sort_matches_ = true;
656 690
657 const std::string expected1[] = { 691 const UrlAndLegalDefault expected1[] = {
658 "http://intra/three", 692 { "http://intra/three", true },
659 "http://intra/two", 693 { "http://intra/two", true }
660 }; 694 };
661 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/t"), string16(), false, 695 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/t"), string16(), false,
662 expected1, arraysize(expected1))); 696 expected1, arraysize(expected1)));
663 EXPECT_LE(1410, matches_[0].relevance); 697 EXPECT_LE(1410, matches_[0].relevance);
664 EXPECT_LT(matches_[0].relevance, 1420); 698 EXPECT_LT(matches_[0].relevance, 1420);
665 EXPECT_EQ(matches_[0].relevance - 1, matches_[1].relevance); 699 EXPECT_EQ(matches_[0].relevance - 1, matches_[1].relevance);
666 700
667 const std::string expected2[] = { 701 const UrlAndLegalDefault expected2[] = {
668 "http://moo/b", 702 { "http://moo/b", true },
669 "http://moo/bar", 703 { "http://moo/bar", true }
670 }; 704 };
671 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("moo/b"), string16(), false, 705 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("moo/b"), string16(), false,
672 expected2, arraysize(expected2))); 706 expected2, arraysize(expected2)));
673 // The url what you typed match should be around 1400, otherwise the 707 // The url what you typed match should be around 1400, otherwise the
674 // search what you typed match is going to be first. 708 // search what you typed match is going to be first.
675 EXPECT_LE(1400, matches_[0].relevance); 709 EXPECT_LE(1400, matches_[0].relevance);
676 EXPECT_LT(matches_[0].relevance, 1410); 710 EXPECT_LT(matches_[0].relevance, 1410);
677 711
678 const std::string expected3[] = { 712 const UrlAndLegalDefault expected3[] = {
679 "http://intra/one", 713 { "http://intra/one", true },
680 "http://intra/three", 714 { "http://intra/three", true },
681 "http://intra/two", 715 { "http://intra/two", true }
682 }; 716 };
683 RunTest(ASCIIToUTF16("intra"), string16(), false, expected3, 717 RunTest(ASCIIToUTF16("intra"), string16(), false, expected3,
684 arraysize(expected3)); 718 arraysize(expected3));
685 719
686 const std::string expected4[] = { 720 const UrlAndLegalDefault expected4[] = {
687 "http://intra/one", 721 { "http://intra/one", true },
688 "http://intra/three", 722 { "http://intra/three", true },
689 "http://intra/two", 723 { "http://intra/two", true }
690 }; 724 };
691 RunTest(ASCIIToUTF16("intra/"), string16(), false, expected4, 725 RunTest(ASCIIToUTF16("intra/"), string16(), false, expected4,
692 arraysize(expected4)); 726 arraysize(expected4));
693 727
694 const std::string expected5[] = { 728 const UrlAndLegalDefault expected5[] = {
695 "http://intra/one", 729 { "http://intra/one", true }
696 }; 730 };
697 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/o"), string16(), false, 731 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/o"), string16(), false,
698 expected5, arraysize(expected5))); 732 expected5, arraysize(expected5)));
699 EXPECT_LE(1410, matches_[0].relevance); 733 EXPECT_LE(1410, matches_[0].relevance);
700 EXPECT_LT(matches_[0].relevance, 1420); 734 EXPECT_LT(matches_[0].relevance, 1420);
701 735
702 const std::string expected6[] = { 736 const UrlAndLegalDefault expected6[] = {
703 "http://intra/x", 737 { "http://intra/x", true }
704 }; 738 };
705 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/x"), string16(), false, 739 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/x"), string16(), false,
706 expected6, arraysize(expected6))); 740 expected6, arraysize(expected6)));
707 EXPECT_LE(1400, matches_[0].relevance); 741 EXPECT_LE(1400, matches_[0].relevance);
708 EXPECT_LT(matches_[0].relevance, 1410); 742 EXPECT_LT(matches_[0].relevance, 1410);
709 743
710 const std::string expected7[] = { 744 const UrlAndLegalDefault expected7[] = {
711 "http://typedhost/untypedpath", 745 { "http://typedhost/untypedpath", true }
712 }; 746 };
713 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"), 747 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"),
714 string16(), false, expected7, arraysize(expected7))); 748 string16(), false, expected7, arraysize(expected7)));
715 EXPECT_LE(1400, matches_[0].relevance); 749 EXPECT_LE(1400, matches_[0].relevance);
716 EXPECT_LT(matches_[0].relevance, 1410); 750 EXPECT_LT(matches_[0].relevance, 1410);
717 } 751 }
718 752
719 TEST_F(HistoryURLProviderTest, CrashDueToFixup) { 753 TEST_F(HistoryURLProviderTest, CrashDueToFixup) {
720 // This test passes if we don't crash. The results don't matter. 754 // This test passes if we don't crash. The results don't matter.
721 const char* const test_cases[] = { 755 const char* const test_cases[] = {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 {"https://testsearch.com/?q=foobar", 20}, 790 {"https://testsearch.com/?q=foobar", 20},
757 {"http://foobar.com/", 10} 791 {"http://foobar.com/", 10}
758 }; 792 };
759 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 793 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
760 history_service_->AddPageWithDetails(GURL(test_cases[i].url), 794 history_service_->AddPageWithDetails(GURL(test_cases[i].url),
761 UTF8ToUTF16("Title"), test_cases[i].count, test_cases[i].count, 795 UTF8ToUTF16("Title"), test_cases[i].count, test_cases[i].count,
762 Time::Now(), false, history::SOURCE_BROWSED); 796 Time::Now(), false, history::SOURCE_BROWSED);
763 } 797 }
764 798
765 // We should not see search URLs when typing a previously used query. 799 // We should not see search URLs when typing a previously used query.
766 const std::string expected_when_searching_query[] = { 800 const UrlAndLegalDefault expected_when_searching_query[] = {
767 test_cases[2].url 801 { test_cases[2].url, false }
768 }; 802 };
769 RunTest(ASCIIToUTF16("foobar"), string16(), true, 803 RunTest(ASCIIToUTF16("foobar"), string16(), true,
770 expected_when_searching_query, arraysize(expected_when_searching_query)); 804 expected_when_searching_query, arraysize(expected_when_searching_query));
771 805
772 // We should not see search URLs when typing the search engine name. 806 // We should not see search URLs when typing the search engine name.
773 const std::string expected_when_searching_site[] = { 807 const UrlAndLegalDefault expected_when_searching_site[] = {
774 test_cases[0].url 808 { test_cases[0].url, false }
775 }; 809 };
776 RunTest(ASCIIToUTF16("testsearch"), string16(), true, 810 RunTest(ASCIIToUTF16("testsearch"), string16(), true,
777 expected_when_searching_site, arraysize(expected_when_searching_site)); 811 expected_when_searching_site, arraysize(expected_when_searching_site));
778 } 812 }
779 813
780 TEST_F(HistoryURLProviderTest, SuggestExactInput) { 814 TEST_F(HistoryURLProviderTest, SuggestExactInput) {
781 const size_t npos = std::string::npos; 815 const size_t npos = std::string::npos;
782 struct TestCase { 816 struct TestCase {
783 // Inputs: 817 // Inputs:
784 const char* input; 818 const char* input;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 EXPECT_EQ(test_cases[i].offsets[match_index], 883 EXPECT_EQ(test_cases[i].offsets[match_index],
850 match.contents_class[match_index].offset); 884 match.contents_class[match_index].offset);
851 EXPECT_EQ(ACMatchClassification::URL | 885 EXPECT_EQ(ACMatchClassification::URL |
852 (match_index == test_cases[i].match_classification_index ? 886 (match_index == test_cases[i].match_classification_index ?
853 ACMatchClassification::MATCH : 0), 887 ACMatchClassification::MATCH : 0),
854 match.contents_class[match_index].style); 888 match.contents_class[match_index].style);
855 } 889 }
856 EXPECT_EQ(npos, test_cases[i].offsets[match.contents_class.size()]); 890 EXPECT_EQ(npos, test_cases[i].offsets[match.contents_class.size()]);
857 } 891 }
858 } 892 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.cc ('k') | chrome/browser/autocomplete/keyword_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698