OLD | NEW |
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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 RunTest(ASCIIToUTF16("winky"), ASCIIToUTF16("com"), false, winky_com_results, | 478 RunTest(ASCIIToUTF16("winky"), ASCIIToUTF16("com"), false, winky_com_results, |
479 arraysize(winky_com_results)); | 479 arraysize(winky_com_results)); |
480 } | 480 } |
481 | 481 |
482 TEST_F(HistoryURLProviderTest, Fixup) { | 482 TEST_F(HistoryURLProviderTest, Fixup) { |
483 // Test for various past crashes we've had. | 483 // Test for various past crashes we've had. |
484 RunTest(ASCIIToUTF16("\\"), string16(), false, NULL, 0); | 484 RunTest(ASCIIToUTF16("\\"), string16(), false, NULL, 0); |
485 RunTest(ASCIIToUTF16("#"), string16(), false, NULL, 0); | 485 RunTest(ASCIIToUTF16("#"), string16(), false, NULL, 0); |
486 RunTest(ASCIIToUTF16("%20"), string16(), false, NULL, 0); | 486 RunTest(ASCIIToUTF16("%20"), string16(), false, NULL, 0); |
487 const std::string fixup_crash[] = {"http://%EF%BD%A5@s/"}; | 487 const std::string fixup_crash[] = {"http://%EF%BD%A5@s/"}; |
488 RunTest(base::WideToUTF16(L"\uff65@s"), string16(), false, fixup_crash, | 488 RunTest(WideToUTF16(L"\uff65@s"), string16(), false, fixup_crash, |
489 arraysize(fixup_crash)); | 489 arraysize(fixup_crash)); |
490 RunTest(base::WideToUTF16(L"\u2015\u2015@ \uff7c"), string16(), false, | 490 RunTest(WideToUTF16(L"\u2015\u2015@ \uff7c"), string16(), false, NULL, 0); |
491 NULL, 0); | |
492 | 491 |
493 // Fixing up "file:" should result in an inline autocomplete offset of just | 492 // Fixing up "file:" should result in an inline autocomplete offset of just |
494 // after "file:", not just after "file://". | 493 // after "file:", not just after "file://". |
495 const string16 input_1(ASCIIToUTF16("file:")); | 494 const string16 input_1(ASCIIToUTF16("file:")); |
496 const std::string fixup_1[] = {"file:///C:/foo.txt"}; | 495 const std::string fixup_1[] = {"file:///C:/foo.txt"}; |
497 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, string16(), false, fixup_1, | 496 ASSERT_NO_FATAL_FAILURE(RunTest(input_1, string16(), false, fixup_1, |
498 arraysize(fixup_1))); | 497 arraysize(fixup_1))); |
499 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); | 498 EXPECT_EQ(input_1.length(), matches_.front().inline_autocomplete_offset); |
500 | 499 |
501 // Fixing up "http:/" should result in an inline autocomplete offset of just | 500 // Fixing up "http:/" should result in an inline autocomplete offset of just |
(...skipping 20 matching lines...) Expand all Loading... |
522 RunTest(ASCIIToUTF16("127.0.0.1"), string16(), false, fixup_4, | 521 RunTest(ASCIIToUTF16("127.0.0.1"), string16(), false, fixup_4, |
523 arraysize(fixup_4)); | 522 arraysize(fixup_4)); |
524 | 523 |
525 // An number "17173" should result in "http://www.17173.com/" in db. | 524 // An number "17173" should result in "http://www.17173.com/" in db. |
526 const std::string fixup_5[] = {"http://www.17173.com/"}; | 525 const std::string fixup_5[] = {"http://www.17173.com/"}; |
527 RunTest(ASCIIToUTF16("17173"), string16(), false, fixup_5, | 526 RunTest(ASCIIToUTF16("17173"), string16(), false, fixup_5, |
528 arraysize(fixup_5)); | 527 arraysize(fixup_5)); |
529 } | 528 } |
530 | 529 |
531 TEST_F(HistoryURLProviderTest, AdjustOffset) { | 530 TEST_F(HistoryURLProviderTest, AdjustOffset) { |
532 RunAdjustOffsetTest(base::WideToUTF16(L"http://www.\uAD50\uC721"), 13); | 531 RunAdjustOffsetTest(WideToUTF16(L"http://www.\uAD50\uC721"), 13); |
533 RunAdjustOffsetTest(ASCIIToUTF16("http://spaces.com/path%20with%20spa"), 31); | 532 RunAdjustOffsetTest(ASCIIToUTF16("http://spaces.com/path%20with%20spa"), 31); |
534 RunAdjustOffsetTest(ASCIIToUTF16("http://ms/c++ s"), 15); | 533 RunAdjustOffsetTest(ASCIIToUTF16("http://ms/c++ s"), 15); |
535 } | 534 } |
536 | 535 |
537 // Make sure the results for the input 'p' don't change between the first and | 536 // Make sure the results for the input 'p' don't change between the first and |
538 // second passes. | 537 // second passes. |
539 TEST_F(HistoryURLProviderTest, EmptyVisits) { | 538 TEST_F(HistoryURLProviderTest, EmptyVisits) { |
540 // Wait for history to create the in memory DB. | 539 // Wait for history to create the in memory DB. |
541 profile_->BlockUntilHistoryProcessesPendingRequests(); | 540 profile_->BlockUntilHistoryProcessesPendingRequests(); |
542 | 541 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 }; | 705 }; |
707 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 706 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
708 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16::npos, | 707 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16::npos, |
709 string16(), false, false, true, | 708 string16(), false, false, true, |
710 AutocompleteInput::ALL_MATCHES); | 709 AutocompleteInput::ALL_MATCHES); |
711 autocomplete_->Start(input, false); | 710 autocomplete_->Start(input, false); |
712 if (!autocomplete_->done()) | 711 if (!autocomplete_->done()) |
713 MessageLoop::current()->Run(); | 712 MessageLoop::current()->Run(); |
714 } | 713 } |
715 } | 714 } |
OLD | NEW |