OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 {"http://pandora.com/", "Pandora", 2, 2}, | 101 {"http://pandora.com/", "Pandora", 2, 2}, |
102 // This entry is explicitly added more recently than | 102 // This entry is explicitly added more recently than |
103 // history::kLowQualityMatchAgeLimitInDays. | 103 // history::kLowQualityMatchAgeLimitInDays. |
104 // {"http://p/", "p", 0, 0}, | 104 // {"http://p/", "p", 0, 0}, |
105 | 105 |
106 // For intranet based tests. | 106 // For intranet based tests. |
107 {"http://intra/one", "Intranet", 2, 2}, | 107 {"http://intra/one", "Intranet", 2, 2}, |
108 {"http://intra/two", "Intranet two", 1, 1}, | 108 {"http://intra/two", "Intranet two", 1, 1}, |
109 {"http://intra/three", "Intranet three", 2, 2}, | 109 {"http://intra/three", "Intranet three", 2, 2}, |
110 {"http://moo/bar", "Intranet moo", 1, 1}, | 110 {"http://moo/bar", "Intranet moo", 1, 1}, |
| 111 {"http://typedhost/typedpath", "Intranet typed", 1, 1}, |
| 112 {"http://typedhost/untypedpath", "Intranet untyped", 1, 0}, |
111 | 113 |
112 {"http://x.com/one", "Intranet", 2, 2}, | 114 {"http://x.com/one", "Internet", 2, 2}, |
113 {"http://x.com/two", "Intranet two", 1, 1}, | 115 {"http://x.com/two", "Internet two", 1, 1}, |
114 {"http://x.com/three", "Intranet three", 2, 2}, | 116 {"http://x.com/three", "Internet three", 2, 2}, |
115 }; | 117 }; |
116 | 118 |
117 class HistoryURLProviderTest : public testing::Test, | 119 class HistoryURLProviderTest : public testing::Test, |
118 public ACProviderListener { | 120 public ACProviderListener { |
119 public: | 121 public: |
120 HistoryURLProviderTest() | 122 HistoryURLProviderTest() |
121 : ui_thread_(BrowserThread::UI, &message_loop_), | 123 : ui_thread_(BrowserThread::UI, &message_loop_), |
122 file_thread_(BrowserThread::FILE, &message_loop_), | 124 file_thread_(BrowserThread::FILE, &message_loop_), |
123 sort_matches_(false) { | 125 sort_matches_(false) { |
124 HistoryQuickProvider::set_disabled(true); | 126 HistoryQuickProvider::set_disabled(true); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/o"), string16(), false, | 637 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/o"), string16(), false, |
636 expected5, arraysize(expected5))); | 638 expected5, arraysize(expected5))); |
637 EXPECT_EQ(1410, matches_[0].relevance); | 639 EXPECT_EQ(1410, matches_[0].relevance); |
638 | 640 |
639 const std::string expected6[] = { | 641 const std::string expected6[] = { |
640 "http://intra/x", | 642 "http://intra/x", |
641 }; | 643 }; |
642 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/x"), string16(), false, | 644 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/x"), string16(), false, |
643 expected6, arraysize(expected6))); | 645 expected6, arraysize(expected6))); |
644 EXPECT_EQ(1400, matches_[0].relevance); | 646 EXPECT_EQ(1400, matches_[0].relevance); |
| 647 |
| 648 const std::string expected7[] = { |
| 649 "http://typedhost/untypedpath", |
| 650 }; |
| 651 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"), |
| 652 string16(), false, expected7, arraysize(expected7))); |
| 653 EXPECT_EQ(1400, matches_[0].relevance); |
645 } | 654 } |
646 | 655 |
647 TEST_F(HistoryURLProviderTest, CrashDueToFixup) { | 656 TEST_F(HistoryURLProviderTest, CrashDueToFixup) { |
648 // This test passes if we don't crash. The results don't matter. | 657 // This test passes if we don't crash. The results don't matter. |
649 const char* const test_cases[] = { | 658 const char* const test_cases[] = { |
650 "//c", | 659 "//c", |
651 "\\@st" | 660 "\\@st" |
652 }; | 661 }; |
653 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 662 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
654 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, | 663 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, |
655 false, true, AutocompleteInput::ALL_MATCHES); | 664 false, true, AutocompleteInput::ALL_MATCHES); |
656 autocomplete_->Start(input, false); | 665 autocomplete_->Start(input, false); |
657 if (!autocomplete_->done()) | 666 if (!autocomplete_->done()) |
658 MessageLoop::current()->Run(); | 667 MessageLoop::current()->Run(); |
659 } | 668 } |
660 } | 669 } |
OLD | NEW |