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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/metrics/proto/omnibox_event.pb.h" | 10 #include "components/metrics/proto/omnibox_event.pb.h" |
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 "ctxs_end=11&" | 1687 "ctxs_end=11&" |
1688 "q=allen&" | 1688 "q=allen&" |
1689 "ctxs_content=woody+allen+movies&" | 1689 "ctxs_content=woody+allen+movies&" |
1690 "ctxsl_url=www.wikipedia.org&" | 1690 "ctxsl_url=www.wikipedia.org&" |
1691 "ctxs_encoding=utf-8&" | 1691 "ctxs_encoding=utf-8&" |
1692 "ctxsl_resolve=1", | 1692 "ctxsl_resolve=1", |
1693 result); | 1693 result); |
1694 } | 1694 } |
1695 | 1695 |
1696 TEST_F(TemplateURLTest, GenerateKeyword) { | 1696 TEST_F(TemplateURLTest, GenerateKeyword) { |
| 1697 std::string accept_languages = "en,ru"; |
1697 ASSERT_EQ(ASCIIToUTF16("foo"), | 1698 ASSERT_EQ(ASCIIToUTF16("foo"), |
1698 TemplateURL::GenerateKeyword(GURL("http://foo"))); | 1699 TemplateURL::GenerateKeyword(GURL("http://foo"), accept_languages)); |
1699 // www. should be stripped. | 1700 // www. should be stripped. |
1700 ASSERT_EQ(ASCIIToUTF16("foo"), | 1701 ASSERT_EQ(ASCIIToUTF16("foo"), TemplateURL::GenerateKeyword( |
1701 TemplateURL::GenerateKeyword(GURL("http://www.foo"))); | 1702 GURL("http://www.foo"), accept_languages)); |
1702 // Make sure we don't get a trailing '/'. | 1703 // Make sure we don't get a trailing '/'. |
1703 ASSERT_EQ(ASCIIToUTF16("blah"), | 1704 ASSERT_EQ(ASCIIToUTF16("blah"), TemplateURL::GenerateKeyword( |
1704 TemplateURL::GenerateKeyword(GURL("http://blah/"))); | 1705 GURL("http://blah/"), accept_languages)); |
1705 // Don't generate the empty string. | 1706 // Don't generate the empty string. |
1706 ASSERT_EQ(ASCIIToUTF16("www"), | 1707 ASSERT_EQ(ASCIIToUTF16("www"), TemplateURL::GenerateKeyword( |
1707 TemplateURL::GenerateKeyword(GURL("http://www."))); | 1708 GURL("http://www."), accept_languages)); |
| 1709 ASSERT_EQ( |
| 1710 base::UTF8ToUTF16("\xd0\xb0\xd0\xb1\xd0\xb2"), |
| 1711 TemplateURL::GenerateKeyword(GURL("http://xn--80acd"), accept_languages)); |
1708 } | 1712 } |
1709 | 1713 |
1710 TEST_F(TemplateURLTest, GenerateSearchURL) { | 1714 TEST_F(TemplateURLTest, GenerateSearchURL) { |
1711 struct GenerateSearchURLCase { | 1715 struct GenerateSearchURLCase { |
1712 const char* test_name; | 1716 const char* test_name; |
1713 const char* url; | 1717 const char* url; |
1714 const char* expected; | 1718 const char* expected; |
1715 } generate_url_cases[] = { | 1719 } generate_url_cases[] = { |
1716 { "invalid URL", "foo{searchTerms}", "" }, | 1720 { "invalid URL", "foo{searchTerms}", "" }, |
1717 { "URL with no replacements", "http://foo/", "http://foo/" }, | 1721 { "URL with no replacements", "http://foo/", "http://foo/" }, |
(...skipping 25 matching lines...) Expand all Loading... |
1743 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t", | 1747 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t", |
1744 result); | 1748 result); |
1745 | 1749 |
1746 TemplateURL url2(data); | 1750 TemplateURL url2(data); |
1747 search_terms_args.prefetch_query.clear(); | 1751 search_terms_args.prefetch_query.clear(); |
1748 search_terms_args.prefetch_query_type.clear(); | 1752 search_terms_args.prefetch_query_type.clear(); |
1749 result = | 1753 result = |
1750 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); | 1754 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); |
1751 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result); | 1755 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result); |
1752 } | 1756 } |
OLD | NEW |