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