| 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 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 TemplateURL::GenerateKeyword(GURL("http://foo"))); | 1698 TemplateURL::GenerateKeyword(GURL("http://foo"))); |
| 1699 // www. should be stripped. | 1699 // www. should be stripped. |
| 1700 ASSERT_EQ(ASCIIToUTF16("foo"), | 1700 ASSERT_EQ(ASCIIToUTF16("foo"), |
| 1701 TemplateURL::GenerateKeyword(GURL("http://www.foo"))); | 1701 TemplateURL::GenerateKeyword(GURL("http://www.foo"))); |
| 1702 // Make sure we don't get a trailing '/'. | 1702 // Make sure we don't get a trailing '/'. |
| 1703 ASSERT_EQ(ASCIIToUTF16("blah"), | 1703 ASSERT_EQ(ASCIIToUTF16("blah"), |
| 1704 TemplateURL::GenerateKeyword(GURL("http://blah/"))); | 1704 TemplateURL::GenerateKeyword(GURL("http://blah/"))); |
| 1705 // Don't generate the empty string. | 1705 // Don't generate the empty string. |
| 1706 ASSERT_EQ(ASCIIToUTF16("www"), | 1706 ASSERT_EQ(ASCIIToUTF16("www"), |
| 1707 TemplateURL::GenerateKeyword(GURL("http://www."))); | 1707 TemplateURL::GenerateKeyword(GURL("http://www."))); |
| 1708 ASSERT_EQ(base::UTF8ToUTF16("\xd0\xb0\xd0\xb1\xd0\xb2"), |
| 1709 TemplateURL::GenerateKeyword(GURL("http://xn--80acd"))); |
| 1708 } | 1710 } |
| 1709 | 1711 |
| 1710 TEST_F(TemplateURLTest, GenerateSearchURL) { | 1712 TEST_F(TemplateURLTest, GenerateSearchURL) { |
| 1711 struct GenerateSearchURLCase { | 1713 struct GenerateSearchURLCase { |
| 1712 const char* test_name; | 1714 const char* test_name; |
| 1713 const char* url; | 1715 const char* url; |
| 1714 const char* expected; | 1716 const char* expected; |
| 1715 } generate_url_cases[] = { | 1717 } generate_url_cases[] = { |
| 1716 { "invalid URL", "foo{searchTerms}", "" }, | 1718 { "invalid URL", "foo{searchTerms}", "" }, |
| 1717 { "URL with no replacements", "http://foo/", "http://foo/" }, | 1719 { "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", | 1745 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t", |
| 1744 result); | 1746 result); |
| 1745 | 1747 |
| 1746 TemplateURL url2(data); | 1748 TemplateURL url2(data); |
| 1747 search_terms_args.prefetch_query.clear(); | 1749 search_terms_args.prefetch_query.clear(); |
| 1748 search_terms_args.prefetch_query_type.clear(); | 1750 search_terms_args.prefetch_query_type.clear(); |
| 1749 result = | 1751 result = |
| 1750 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); | 1752 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); |
| 1751 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result); | 1753 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result); |
| 1752 } | 1754 } |
| OLD | NEW |