| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 "ctxs_end=11&" | 1628 "ctxs_end=11&" |
| 1629 "q=allen&" | 1629 "q=allen&" |
| 1630 "ctxs_content=woody+allen+movies&" | 1630 "ctxs_content=woody+allen+movies&" |
| 1631 "ctxsl_url=www.wikipedia.org&" | 1631 "ctxsl_url=www.wikipedia.org&" |
| 1632 "ctxs_encoding=utf-8&" | 1632 "ctxs_encoding=utf-8&" |
| 1633 "ctxsl_resolve=1", | 1633 "ctxsl_resolve=1", |
| 1634 result); | 1634 result); |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 TEST_F(TemplateURLTest, GenerateKeyword) { | 1637 TEST_F(TemplateURLTest, GenerateKeyword) { |
| 1638 std::string accept_languages = "en,ru"; | |
| 1639 ASSERT_EQ(ASCIIToUTF16("foo"), | 1638 ASSERT_EQ(ASCIIToUTF16("foo"), |
| 1640 TemplateURL::GenerateKeyword(GURL("http://foo"), accept_languages)); | 1639 TemplateURL::GenerateKeyword(GURL("http://foo"))); |
| 1641 // www. should be stripped. | 1640 // www. should be stripped. |
| 1642 ASSERT_EQ(ASCIIToUTF16("foo"), TemplateURL::GenerateKeyword( | 1641 ASSERT_EQ(ASCIIToUTF16("foo"), |
| 1643 GURL("http://www.foo"), accept_languages)); | 1642 TemplateURL::GenerateKeyword(GURL("http://www.foo"))); |
| 1644 // Make sure we don't get a trailing '/'. | 1643 // Make sure we don't get a trailing '/'. |
| 1645 ASSERT_EQ(ASCIIToUTF16("blah"), TemplateURL::GenerateKeyword( | 1644 ASSERT_EQ(ASCIIToUTF16("blah"), |
| 1646 GURL("http://blah/"), accept_languages)); | 1645 TemplateURL::GenerateKeyword(GURL("http://blah/"))); |
| 1647 // Don't generate the empty string. | 1646 // Don't generate the empty string. |
| 1648 ASSERT_EQ(ASCIIToUTF16("www"), TemplateURL::GenerateKeyword( | 1647 ASSERT_EQ(ASCIIToUTF16("www"), |
| 1649 GURL("http://www."), accept_languages)); | 1648 TemplateURL::GenerateKeyword(GURL("http://www."))); |
| 1650 ASSERT_EQ( | 1649 ASSERT_EQ( |
| 1651 base::UTF8ToUTF16("\xd0\xb0\xd0\xb1\xd0\xb2"), | 1650 base::UTF8ToUTF16("\xd0\xb0\xd0\xb1\xd0\xb2"), |
| 1652 TemplateURL::GenerateKeyword(GURL("http://xn--80acd"), accept_languages)); | 1651 TemplateURL::GenerateKeyword(GURL("http://xn--80acd"))); |
| 1653 } | 1652 } |
| 1654 | 1653 |
| 1655 TEST_F(TemplateURLTest, GenerateSearchURL) { | 1654 TEST_F(TemplateURLTest, GenerateSearchURL) { |
| 1656 struct GenerateSearchURLCase { | 1655 struct GenerateSearchURLCase { |
| 1657 const char* test_name; | 1656 const char* test_name; |
| 1658 const char* url; | 1657 const char* url; |
| 1659 const char* expected; | 1658 const char* expected; |
| 1660 } generate_url_cases[] = { | 1659 } generate_url_cases[] = { |
| 1661 { "invalid URL", "foo{searchTerms}", "" }, | 1660 { "invalid URL", "foo{searchTerms}", "" }, |
| 1662 { "URL with no replacements", "http://foo/", "http://foo/" }, | 1661 { "URL with no replacements", "http://foo/", "http://foo/" }, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 GURL("https://www.foo.org/search?q=Y+Z"), | 1778 GURL("https://www.foo.org/search?q=Y+Z"), |
| 1780 search_terms_data_, &search_terms)); | 1779 search_terms_data_, &search_terms)); |
| 1781 EXPECT_EQ(base::ASCIIToUTF16("Y Z"), search_terms); | 1780 EXPECT_EQ(base::ASCIIToUTF16("Y Z"), search_terms); |
| 1782 EXPECT_TRUE(url.ExtractSearchTermsFromURL( | 1781 EXPECT_TRUE(url.ExtractSearchTermsFromURL( |
| 1783 GURL("https://www.foo.org/s#q=123"), | 1782 GURL("https://www.foo.org/s#q=123"), |
| 1784 search_terms_data_, &search_terms)); | 1783 search_terms_data_, &search_terms)); |
| 1785 EXPECT_EQ(base::ASCIIToUTF16("123"), search_terms); | 1784 EXPECT_EQ(base::ASCIIToUTF16("123"), search_terms); |
| 1786 | 1785 |
| 1787 search_terms_data_.set_google_base_url("http://www.google.com/"); | 1786 search_terms_data_.set_google_base_url("http://www.google.com/"); |
| 1788 } | 1787 } |
| OLD | NEW |