| 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/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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"), | 747 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"), |
| 748 string16(), false, expected7, arraysize(expected7))); | 748 string16(), false, expected7, arraysize(expected7))); |
| 749 EXPECT_LE(1400, matches_[0].relevance); | 749 EXPECT_LE(1400, matches_[0].relevance); |
| 750 EXPECT_LT(matches_[0].relevance, 1410); | 750 EXPECT_LT(matches_[0].relevance, 1410); |
| 751 } | 751 } |
| 752 | 752 |
| 753 TEST_F(HistoryURLProviderTest, CrashDueToFixup) { | 753 TEST_F(HistoryURLProviderTest, CrashDueToFixup) { |
| 754 // 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. |
| 755 const char* const test_cases[] = { | 755 const char* const test_cases[] = { |
| 756 "//c", | 756 "//c", |
| 757 "\\@st" | 757 "\\@st", |
| 758 "view-source:x", |
| 758 }; | 759 }; |
| 759 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 760 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 760 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16::npos, | 761 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16::npos, |
| 761 string16(), GURL(), AutocompleteInput::INVALID_SPEC, | 762 string16(), GURL(), AutocompleteInput::INVALID_SPEC, |
| 762 false, false, true, AutocompleteInput::ALL_MATCHES); | 763 false, false, true, AutocompleteInput::ALL_MATCHES); |
| 763 autocomplete_->Start(input, false); | 764 autocomplete_->Start(input, false); |
| 764 if (!autocomplete_->done()) | 765 if (!autocomplete_->done()) |
| 765 base::MessageLoop::current()->Run(); | 766 base::MessageLoop::current()->Run(); |
| 766 } | 767 } |
| 767 } | 768 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 { "w", false, | 841 { "w", false, |
| 841 "http://w", {0, 7, npos}, 1 }, | 842 "http://w", {0, 7, npos}, 1 }, |
| 842 { "w.com", true, | 843 { "w.com", true, |
| 843 "w.com", {0, npos, npos}, 0 }, | 844 "w.com", {0, npos, npos}, 0 }, |
| 844 { "w.com", false, | 845 { "w.com", false, |
| 845 "http://w.com", {0, 7, npos}, 1 }, | 846 "http://w.com", {0, 7, npos}, 1 }, |
| 846 { "www.w.com", true, | 847 { "www.w.com", true, |
| 847 "www.w.com", {0, npos, npos}, 0 }, | 848 "www.w.com", {0, npos, npos}, 0 }, |
| 848 { "www.w.com", false, | 849 { "www.w.com", false, |
| 849 "http://www.w.com", {0, 7, npos}, 1 }, | 850 "http://www.w.com", {0, 7, npos}, 1 }, |
| 851 { "view-source:w", true, |
| 852 "view-source:w", {0, npos, npos}, 0 }, |
| 850 { "view-source:www.w.com/", true, | 853 { "view-source:www.w.com/", true, |
| 851 "view-source:www.w.com", {0, npos, npos}, npos }, | 854 "view-source:www.w.com", {0, npos, npos}, npos }, |
| 852 { "view-source:www.w.com/", false, | 855 { "view-source:www.w.com/", false, |
| 853 "view-source:http://www.w.com", {0, npos, npos}, npos }, | 856 "view-source:http://www.w.com", {0, npos, npos}, npos }, |
| 854 { "view-source:http://www.w.com/", false, | 857 { "view-source:http://www.w.com/", false, |
| 855 "view-source:http://www.w.com", {0, npos, npos}, 0 }, | 858 "view-source:http://www.w.com", {0, npos, npos}, 0 }, |
| 856 { " view-source:", true, | 859 { " view-source:", true, |
| 857 "view-source:", {0, npos, npos}, 0 }, | 860 "view-source:", {0, npos, npos}, 0 }, |
| 858 { "http:////////w.com", false, | 861 { "http:////////w.com", false, |
| 859 "http://w.com", {0, npos, npos}, npos }, | 862 "http://w.com", {0, npos, npos}, npos }, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 883 EXPECT_EQ(test_cases[i].offsets[match_index], | 886 EXPECT_EQ(test_cases[i].offsets[match_index], |
| 884 match.contents_class[match_index].offset); | 887 match.contents_class[match_index].offset); |
| 885 EXPECT_EQ(ACMatchClassification::URL | | 888 EXPECT_EQ(ACMatchClassification::URL | |
| 886 (match_index == test_cases[i].match_classification_index ? | 889 (match_index == test_cases[i].match_classification_index ? |
| 887 ACMatchClassification::MATCH : 0), | 890 ACMatchClassification::MATCH : 0), |
| 888 match.contents_class[match_index].style); | 891 match.contents_class[match_index].style); |
| 889 } | 892 } |
| 890 EXPECT_EQ(npos, test_cases[i].offsets[match.contents_class.size()]); | 893 EXPECT_EQ(npos, test_cases[i].offsets[match.contents_class.size()]); |
| 891 } | 894 } |
| 892 } | 895 } |
| OLD | NEW |