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

Unified Diff: components/search_engines/template_url_unittest.cc

Issue 2806593006: Changed GenerateKeyword to always return keyword in lowercase (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/search_engines/template_url_unittest.cc
diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc
index 170807f17f36a74c46898a97e6b742699efa7c60..745d83391fe0ec1a0e5a08104c9afbfba9de34c2 100644
--- a/components/search_engines/template_url_unittest.cc
+++ b/components/search_engines/template_url_unittest.cc
@@ -6,6 +6,7 @@
#include "base/base_paths.h"
#include "base/command_line.h"
+#include "base/i18n/case_conversion.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -22,6 +23,12 @@
using base::ASCIIToUTF16;
+namespace {
+bool IsLowerCase(base::string16 str) {
Peter Kasting 2017/04/18 18:46:20 Nit: const &
Alexander Yashkin 2017/04/20 07:05:53 Done.
+ return str == base::i18n::ToLower(str);
+}
+}
+
class TemplateURLTest : public testing::Test {
public:
TemplateURLTest() : search_terms_data_("http://www.google.com/") {}
@@ -1734,6 +1741,13 @@ TEST_F(TemplateURLTest, GenerateKeyword) {
ASSERT_EQ(
base::UTF8ToUTF16("\xd0\xb0\xd0\xb1\xd0\xb2"),
TemplateURL::GenerateKeyword(GURL("http://xn--80acd")));
+
+ // Generated keywords must always be in lowercase, because TemplateURLs always
+ // converts keywords to lowercase in its constructor and TemplateURLService
+ // stores TemplateURLs in maps using keyword as key.
+ ASSERT_TRUE(IsLowerCase(TemplateURL::GenerateKeyword(GURL("http://BLAH/"))));
+ ASSERT_TRUE(IsLowerCase(
Peter Kasting 2017/04/18 18:46:20 Nit: I think every ASSERT in this test could be EX
Alexander Yashkin 2017/04/20 07:05:53 Done
+ TemplateURL::GenerateKeyword(GURL("http://embeddedhtml.<head>/"))));
}
TEST_F(TemplateURLTest, GenerateSearchURL) {

Powered by Google App Engine
This is Rietveld 408576698