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

Unified Diff: components/search_engines/template_url_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31774626760dfa0692567e2ec047b43b52d8d801..2b83148518a09c8a654ad7bae0ee9b7fb5f21707 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(const base::string16& str) {
+ return str == base::i18n::ToLower(str);
+}
+}
+
class TemplateURLTest : public testing::Test {
public:
TemplateURLTest() : search_terms_data_("http://www.google.com/") {}
@@ -1742,6 +1749,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.
+ EXPECT_TRUE(IsLowerCase(TemplateURL::GenerateKeyword(GURL("http://BLAH/"))));
+ EXPECT_TRUE(IsLowerCase(
+ TemplateURL::GenerateKeyword(GURL("http://embeddedhtml.<head>/"))));
}
TEST_F(TemplateURLTest, GenerateSearchURL) {
« no previous file with comments | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698