Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 2806593006: Changed GenerateKeyword to always return keyword in lowercase (Closed)
Patch Set: Fixed after review, round 1 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/search_engines/template_url.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // URLs with embedded HTML canonicalize to contain uppercase characters in the
1799 // hostname. Ensure these URLs are still handled correctly for conflict
1800 // resolution.
1801 const TemplateURL* user5 =
1802 AddKeywordWithDate("nonreplaceable5", "embedded.%3chtml%3eweb",
1803 "http://embedded.<html>web/?q={searchTerms}",
1804 std::string(), std::string(), std::string(), false);
1805 EXPECT_EQ(ASCIIToUTF16("embedded.%3chtml%3eweb"), user5->keyword());
1806 EXPECT_EQ(user5, model()->GetTemplateURLForKeyword(
1807 ASCIIToUTF16("embedded.%3chtml%3eweb")));
1808 const TemplateURL* user6 =
1809 AddKeywordWithDate("nonreplaceable6", "embedded.%3chtml%3eweb",
1810 "http://embedded.<html>web/?q={searchTerms}",
1811 std::string(), std::string(), std::string(), false);
1812 EXPECT_EQ(ASCIIToUTF16("embedded.%3chtml%3eweb"), user6->keyword());
1813 EXPECT_EQ(user6, model()->GetTemplateURLForKeyword(
1814 ASCIIToUTF16("embedded.%3chtml%3eweb")));
1815 // Expect existing engine changed its keyword.
1816 EXPECT_EQ(ASCIIToUTF16("embedded.%3chtml%3eweb_"), user5->keyword());
1817 EXPECT_EQ(user5, model()->GetTemplateURLForKeyword(
1818 ASCIIToUTF16("embedded.%3chtml%3eweb_")));
1796 } 1819 }
1797 1820
1798 TEST_F(TemplateURLServiceTest, CheckReplaceableEnginesKeywordsConflicts) { 1821 TEST_F(TemplateURLServiceTest, CheckReplaceableEnginesKeywordsConflicts) {
1799 test_util()->VerifyLoad(); 1822 test_util()->VerifyLoad();
1800 1823
1801 const base::string16 kCommonKeyword = ASCIIToUTF16("common_keyword"); 1824 const base::string16 kCommonKeyword = ASCIIToUTF16("common_keyword");
1802 // 1. Add non replaceable user engine with common keyword. 1825 // 1. Add non replaceable user engine with common keyword.
1803 const TemplateURL* user1 = 1826 const TemplateURL* user1 =
1804 AddKeywordWithDate("nonreplaceable", "common_keyword", "http://test1", 1827 AddKeywordWithDate("nonreplaceable", "common_keyword", "http://test1",
1805 std::string(), std::string(), std::string(), false); 1828 std::string(), std::string(), std::string(), false);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 DCHECK(search_engine2); 1973 DCHECK(search_engine2);
1951 1974
1952 base::HistogramTester histogram_tester; 1975 base::HistogramTester histogram_tester;
1953 model()->SetUserSelectedDefaultSearchProvider(search_engine1); 1976 model()->SetUserSelectedDefaultSearchProvider(search_engine1);
1954 histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 1); 1977 histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 1);
1955 model()->SetUserSelectedDefaultSearchProvider(search_engine1); 1978 model()->SetUserSelectedDefaultSearchProvider(search_engine1);
1956 histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 1); 1979 histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 1);
1957 model()->SetUserSelectedDefaultSearchProvider(search_engine2); 1980 model()->SetUserSelectedDefaultSearchProvider(search_engine2);
1958 histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 2); 1981 histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 2);
1959 } 1982 }
OLDNEW
« no previous file with comments | « no previous file | components/search_engines/template_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698