| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 TEST_F(HistoryQuickProviderTest, SingleMatchWithCursor) { | 398 TEST_F(HistoryQuickProviderTest, SingleMatchWithCursor) { |
| 399 std::vector<std::string> expected_urls; | 399 std::vector<std::string> expected_urls; |
| 400 expected_urls.push_back("http://slashdot.org/favorite_page.html"); | 400 expected_urls.push_back("http://slashdot.org/favorite_page.html"); |
| 401 // With cursor after "slash", we should retrieve the desired result but it | 401 // With cursor after "slash", we should retrieve the desired result but it |
| 402 // should not be allowed to be the default match. | 402 // should not be allowed to be the default match. |
| 403 RunTestWithCursor(ASCIIToUTF16("slashfavorite_page.html"), 5, false, | 403 RunTestWithCursor(ASCIIToUTF16("slashfavorite_page.html"), 5, false, |
| 404 expected_urls, false, | 404 expected_urls, false, |
| 405 ASCIIToUTF16("slashdot.org/favorite_page.html"), | 405 ASCIIToUTF16("slashdot.org/favorite_page.html"), |
| 406 base::string16()); | 406 base::string16()); |
| 407 // If the cursor is in the middle of a valid URL suggestion, it should be | |
| 408 // allowed to be the default match. The inline completion will be empty | |
| 409 // though as no completion is necessary. | |
| 410 RunTestWithCursor(ASCIIToUTF16("slashdot.org/favorite_page.html"), 5, false, | |
| 411 expected_urls, true, | |
| 412 ASCIIToUTF16("slashdot.org/favorite_page.html"), | |
| 413 base::string16()); | |
| 414 } | 407 } |
| 415 | 408 |
| 416 TEST_F(HistoryQuickProviderTest, WordBoundariesWithPunctuationMatch) { | 409 TEST_F(HistoryQuickProviderTest, WordBoundariesWithPunctuationMatch) { |
| 417 std::vector<std::string> expected_urls; | 410 std::vector<std::string> expected_urls; |
| 418 expected_urls.push_back("http://popularsitewithpathonly.com/moo"); | 411 expected_urls.push_back("http://popularsitewithpathonly.com/moo"); |
| 419 RunTest(ASCIIToUTF16("/moo"), false, expected_urls, false, | 412 RunTest(ASCIIToUTF16("/moo"), false, expected_urls, false, |
| 420 ASCIIToUTF16("popularsitewithpathonly.com/moo"), base::string16()); | 413 ASCIIToUTF16("popularsitewithpathonly.com/moo"), base::string16()); |
| 421 } | 414 } |
| 422 | 415 |
| 423 TEST_F(HistoryQuickProviderTest, MultiTermTitleMatch) { | 416 TEST_F(HistoryQuickProviderTest, MultiTermTitleMatch) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 data.SetURL("http://testsearch.com/?q={searchTerms}"); | 735 data.SetURL("http://testsearch.com/?q={searchTerms}"); |
| 743 TemplateURLService* template_url_service = | 736 TemplateURLService* template_url_service = |
| 744 TemplateURLServiceFactory::GetForProfile(profile_.get()); | 737 TemplateURLServiceFactory::GetForProfile(profile_.get()); |
| 745 TemplateURL* template_url = new TemplateURL(data); | 738 TemplateURL* template_url = new TemplateURL(data); |
| 746 template_url_service->Add(template_url); | 739 template_url_service->Add(template_url); |
| 747 template_url_service->SetUserSelectedDefaultSearchProvider(template_url); | 740 template_url_service->SetUserSelectedDefaultSearchProvider(template_url); |
| 748 template_url_service->Load(); | 741 template_url_service->Load(); |
| 749 | 742 |
| 750 // A search results page should not be returned when typing a query. | 743 // A search results page should not be returned when typing a query. |
| 751 std::vector<std::string> expected_urls; | 744 std::vector<std::string> expected_urls; |
| 752 expected_urls.push_back("http://anotherengine.com/?q=thequery"); | |
| 753 RunTest(ASCIIToUTF16("thequery"), false, expected_urls, false, | 745 RunTest(ASCIIToUTF16("thequery"), false, expected_urls, false, |
| 754 ASCIIToUTF16("anotherengine.com/?q=thequery"), base::string16()); | 746 ASCIIToUTF16("anotherengine.com/?q=thequery"), base::string16()); |
| 755 | 747 |
| 756 // A search results page should not be returned when typing the engine URL. | 748 // A search results page should not be returned when typing the engine URL. |
| 757 expected_urls.clear(); | 749 expected_urls.clear(); |
| 758 expected_urls.push_back("http://testsearch.com/"); | 750 expected_urls.push_back("http://testsearch.com/"); |
| 759 RunTest(ASCIIToUTF16("testsearch"), false, expected_urls, true, | 751 RunTest(ASCIIToUTF16("testsearch"), false, expected_urls, true, |
| 760 ASCIIToUTF16("testsearch.com"), | 752 ASCIIToUTF16("testsearch.com"), |
| 761 ASCIIToUTF16(".com")); | 753 ASCIIToUTF16(".com")); |
| 762 } | 754 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 | 823 |
| 832 TEST_F(HQPOrderingTest, TEAMatch) { | 824 TEST_F(HQPOrderingTest, TEAMatch) { |
| 833 std::vector<std::string> expected_urls; | 825 std::vector<std::string> expected_urls; |
| 834 expected_urls.push_back("http://www.teamliquid.net/"); | 826 expected_urls.push_back("http://www.teamliquid.net/"); |
| 835 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 827 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
| 836 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 828 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
| 837 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, | 829 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, |
| 838 ASCIIToUTF16("www.teamliquid.net"), | 830 ASCIIToUTF16("www.teamliquid.net"), |
| 839 ASCIIToUTF16("mliquid.net")); | 831 ASCIIToUTF16("mliquid.net")); |
| 840 } | 832 } |
| OLD | NEW |