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

Unified Diff: chrome/renderer/translate_helper_unittest.cc

Issue 12221085: Translate: split language code typo correction to apply unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 | « chrome/renderer/translate_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/translate_helper_unittest.cc
diff --git a/chrome/renderer/translate_helper_unittest.cc b/chrome/renderer/translate_helper_unittest.cc
index 108462501c2a6cf4d4052a747847c48521c1fe55..6cfe8e2516431610c70d534f26cebe5624a71af6 100644
--- a/chrome/renderer/translate_helper_unittest.cc
+++ b/chrome/renderer/translate_helper_unittest.cc
@@ -8,6 +8,26 @@
typedef testing::Test TranslateHelperTest;
+// Tests that well-known language code typos are fixed.
+TEST_F(TranslateHelperTest, LanguageCodeTypoCorrection) {
+ std::string language;
+
+ // Strip the second and later codes.
+ language = std::string("ja,en");
+ TranslateHelper::CorrectLanguageCodeTypo(&language);
+ EXPECT_EQ("ja", language);
+
+ // Replace dash with hyphen.
+ language = std::string("ja_JP");
+ TranslateHelper::CorrectLanguageCodeTypo(&language);
+ EXPECT_EQ("ja-JP", language);
+
+ // Correct wrong cases.
+ language = std::string("JA-jp");
+ TranslateHelper::CorrectLanguageCodeTypo(&language);
+ EXPECT_EQ("ja-JP", language);
+}
+
// Tests that synonym language code is converted to one used in supporting list.
TEST_F(TranslateHelperTest, LanguageCodeSynonyms) {
std::string language;
« no previous file with comments | « chrome/renderer/translate_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698