| 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 "components/omnibox/browser/history_quick_provider.h" | 5 #include "components/omnibox/browser/history_quick_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void HistoryQuickProviderTest::RunTestWithCursor( | 324 void HistoryQuickProviderTest::RunTestWithCursor( |
| 325 const base::string16 text, | 325 const base::string16 text, |
| 326 const size_t cursor_position, | 326 const size_t cursor_position, |
| 327 bool prevent_inline_autocomplete, | 327 bool prevent_inline_autocomplete, |
| 328 std::vector<std::string> expected_urls, | 328 std::vector<std::string> expected_urls, |
| 329 bool can_inline_top_result, | 329 bool can_inline_top_result, |
| 330 base::string16 expected_fill_into_edit, | 330 base::string16 expected_fill_into_edit, |
| 331 base::string16 expected_autocompletion) { | 331 base::string16 expected_autocompletion) { |
| 332 SCOPED_TRACE(text); // Minimal hint to query being run. | 332 SCOPED_TRACE(text); // Minimal hint to query being run. |
| 333 base::RunLoop().RunUntilIdle(); | 333 base::RunLoop().RunUntilIdle(); |
| 334 AutocompleteInput input(text, cursor_position, std::string(), GURL(), | 334 AutocompleteInput input( |
| 335 metrics::OmniboxEventProto::INVALID_SPEC, | 335 text, cursor_position, std::string(), GURL(), base::string16(), |
| 336 prevent_inline_autocomplete, false, true, true, false, | 336 metrics::OmniboxEventProto::INVALID_SPEC, prevent_inline_autocomplete, |
| 337 TestSchemeClassifier()); | 337 false, true, true, false, TestSchemeClassifier()); |
| 338 provider_->Start(input, false); | 338 provider_->Start(input, false); |
| 339 EXPECT_TRUE(provider_->done()); | 339 EXPECT_TRUE(provider_->done()); |
| 340 | 340 |
| 341 ac_matches_ = provider_->matches(); | 341 ac_matches_ = provider_->matches(); |
| 342 | 342 |
| 343 // We should have gotten back at most AutocompleteProvider::kMaxMatches. | 343 // We should have gotten back at most AutocompleteProvider::kMaxMatches. |
| 344 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); | 344 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); |
| 345 | 345 |
| 346 // If the number of expected and actual matches aren't equal then we need | 346 // If the number of expected and actual matches aren't equal then we need |
| 347 // test no further, but let's do anyway so that we know which URLs failed. | 347 // test no further, but let's do anyway so that we know which URLs failed. |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 RunTest(ASCIIToUTF16("popularsitewithroot.com"), true, expected_urls, true, | 739 RunTest(ASCIIToUTF16("popularsitewithroot.com"), true, expected_urls, true, |
| 740 ASCIIToUTF16("popularsitewithroot.com"), base::string16()); | 740 ASCIIToUTF16("popularsitewithroot.com"), base::string16()); |
| 741 | 741 |
| 742 // The above still holds even with an extra trailing slash. | 742 // The above still holds even with an extra trailing slash. |
| 743 RunTest(ASCIIToUTF16("popularsitewithroot.com/"), true, expected_urls, true, | 743 RunTest(ASCIIToUTF16("popularsitewithroot.com/"), true, expected_urls, true, |
| 744 ASCIIToUTF16("popularsitewithroot.com"), base::string16()); | 744 ASCIIToUTF16("popularsitewithroot.com"), base::string16()); |
| 745 } | 745 } |
| 746 | 746 |
| 747 TEST_F(HistoryQuickProviderTest, DoesNotProvideMatchesOnFocus) { | 747 TEST_F(HistoryQuickProviderTest, DoesNotProvideMatchesOnFocus) { |
| 748 AutocompleteInput input(ASCIIToUTF16("popularsite"), base::string16::npos, | 748 AutocompleteInput input(ASCIIToUTF16("popularsite"), base::string16::npos, |
| 749 std::string(), GURL(), | 749 std::string(), GURL(), base::string16(), |
| 750 metrics::OmniboxEventProto::INVALID_SPEC, false, | 750 metrics::OmniboxEventProto::INVALID_SPEC, false, |
| 751 false, true, true, true, TestSchemeClassifier()); | 751 false, true, true, true, TestSchemeClassifier()); |
| 752 provider().Start(input, false); | 752 provider().Start(input, false); |
| 753 EXPECT_TRUE(provider().matches().empty()); | 753 EXPECT_TRUE(provider().matches().empty()); |
| 754 } | 754 } |
| 755 | 755 |
| 756 // HQPOrderingTest ------------------------------------------------------------- | 756 // HQPOrderingTest ------------------------------------------------------------- |
| 757 | 757 |
| 758 class HQPOrderingTest : public HistoryQuickProviderTest { | 758 class HQPOrderingTest : public HistoryQuickProviderTest { |
| 759 public: | 759 public: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 | 821 |
| 822 TEST_F(HQPOrderingTest, TEAMatch) { | 822 TEST_F(HQPOrderingTest, TEAMatch) { |
| 823 std::vector<std::string> expected_urls; | 823 std::vector<std::string> expected_urls; |
| 824 expected_urls.push_back("http://www.teamliquid.net/"); | 824 expected_urls.push_back("http://www.teamliquid.net/"); |
| 825 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 825 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
| 826 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 826 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
| 827 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, | 827 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, |
| 828 ASCIIToUTF16("www.teamliquid.net"), | 828 ASCIIToUTF16("www.teamliquid.net"), |
| 829 ASCIIToUTF16("mliquid.net")); | 829 ASCIIToUTF16("mliquid.net")); |
| 830 } | 830 } |
| OLD | NEW |