Chromium Code Reviews| 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/search_engines/template_url_service.h" | 5 #include "components/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1786 // Existing conflicting engine user3 will get keyword generated by appending | 1786 // Existing conflicting engine user3 will get keyword generated by appending |
| 1787 // '_' to its keyword because it can not get keyword autogenerated from search | 1787 // '_' to its keyword because it can not get keyword autogenerated from search |
| 1788 // url - "test2" keyword is already in use by user2 engine. Both engines must | 1788 // url - "test2" keyword is already in use by user2 engine. Both engines must |
| 1789 // be acessible. | 1789 // be acessible. |
| 1790 EXPECT_EQ(ASCIIToUTF16("common_keyword_"), user3->keyword()); | 1790 EXPECT_EQ(ASCIIToUTF16("common_keyword_"), user3->keyword()); |
| 1791 EXPECT_EQ(user3, | 1791 EXPECT_EQ(user3, |
| 1792 model()->GetTemplateURLForKeyword(ASCIIToUTF16("common_keyword_"))); | 1792 model()->GetTemplateURLForKeyword(ASCIIToUTF16("common_keyword_"))); |
| 1793 EXPECT_EQ(kCommonKeyword, user4->keyword()); | 1793 EXPECT_EQ(kCommonKeyword, user4->keyword()); |
| 1794 EXPECT_EQ(user4, model()->GetTemplateURLForKeyword(kCommonKeyword)); | 1794 EXPECT_EQ(user4, model()->GetTemplateURLForKeyword(kCommonKeyword)); |
| 1795 EXPECT_EQ(user4, model()->GetTemplateURLForHost("test3")); | 1795 EXPECT_EQ(user4, model()->GetTemplateURLForHost("test3")); |
| 1796 | |
| 1797 // Check conflict between search engines with html tags embedded in URL host. | |
| 1798 // Where was problem with UniquifyKeyword incorrectly handling them because | |
| 1799 // generated keyword for such URL contained upper case characters. | |
|
Peter Kasting
2017/04/18 18:46:19
Nit: Avoid describing past problems (because it's
Alexander Yashkin
2017/04/20 07:05:53
Thanks, done.
| |
| 1800 const TemplateURL* user5 = | |
| 1801 AddKeywordWithDate("nonreplaceable5", "embedded.%3chtml%3eweb", | |
| 1802 "http://embedded.<html>web/?q={searchTerms}", | |
| 1803 std::string(), std::string(), std::string(), false); | |
| 1804 EXPECT_EQ(ASCIIToUTF16("embedded.%3chtml%3eweb"), user5->keyword()); | |
| 1805 EXPECT_EQ(user5, model()->GetTemplateURLForKeyword( | |
| 1806 ASCIIToUTF16("embedded.%3chtml%3eweb"))); | |
| 1807 const TemplateURL* user6 = | |
| 1808 AddKeywordWithDate("nonreplaceable6", "embedded.%3chtml%3eweb", | |
| 1809 "http://embedded.<html>web/?q={searchTerms}", | |
| 1810 std::string(), std::string(), std::string(), false); | |
| 1811 EXPECT_EQ(ASCIIToUTF16("embedded.%3chtml%3eweb"), user6->keyword()); | |
| 1812 EXPECT_EQ(user6, model()->GetTemplateURLForKeyword( | |
| 1813 ASCIIToUTF16("embedded.%3chtml%3eweb"))); | |
| 1814 // Expect existing engine changed its keyword. | |
| 1815 EXPECT_EQ(ASCIIToUTF16("embedded.%3chtml%3eweb_"), user5->keyword()); | |
| 1816 EXPECT_EQ(user5, model()->GetTemplateURLForKeyword( | |
| 1817 ASCIIToUTF16("embedded.%3chtml%3eweb_"))); | |
|
Peter Kasting
2017/04/18 18:46:20
Would this test have failed without this patch? W
Alexander Yashkin
2017/04/20 07:05:53
This tests fails without my patch - first at diffe
| |
| 1796 } | 1818 } |
| 1797 | 1819 |
| 1798 TEST_F(TemplateURLServiceTest, CheckReplaceableEnginesKeywordsConflicts) { | 1820 TEST_F(TemplateURLServiceTest, CheckReplaceableEnginesKeywordsConflicts) { |
| 1799 test_util()->VerifyLoad(); | 1821 test_util()->VerifyLoad(); |
| 1800 | 1822 |
| 1801 const base::string16 kCommonKeyword = ASCIIToUTF16("common_keyword"); | 1823 const base::string16 kCommonKeyword = ASCIIToUTF16("common_keyword"); |
| 1802 // 1. Add non replaceable user engine with common keyword. | 1824 // 1. Add non replaceable user engine with common keyword. |
| 1803 const TemplateURL* user1 = | 1825 const TemplateURL* user1 = |
| 1804 AddKeywordWithDate("nonreplaceable", "common_keyword", "http://test1", | 1826 AddKeywordWithDate("nonreplaceable", "common_keyword", "http://test1", |
| 1805 std::string(), std::string(), std::string(), false); | 1827 std::string(), std::string(), std::string(), false); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1937 TemplateURL* update_url = | 1959 TemplateURL* update_url = |
| 1938 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); | 1960 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); |
| 1939 const Time update_last_modified = update_url->last_modified(); | 1961 const Time update_last_modified = update_url->last_modified(); |
| 1940 model()->SetUserSelectedDefaultSearchProvider(update_url); | 1962 model()->SetUserSelectedDefaultSearchProvider(update_url); |
| 1941 TemplateURL* reloaded_url = | 1963 TemplateURL* reloaded_url = |
| 1942 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); | 1964 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); |
| 1943 const Time reloaded_last_modified = reloaded_url->last_modified(); | 1965 const Time reloaded_last_modified = reloaded_url->last_modified(); |
| 1944 EXPECT_NE(original_last_modified, reloaded_last_modified); | 1966 EXPECT_NE(original_last_modified, reloaded_last_modified); |
| 1945 EXPECT_EQ(update_last_modified, reloaded_last_modified); | 1967 EXPECT_EQ(update_last_modified, reloaded_last_modified); |
| 1946 } | 1968 } |
| OLD | NEW |