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

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: unit test version 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 16bb9154de06d77a3a314b0e13b36d1d042b19b7..e03c454e5d223effec4241526f815a1e2de52d78 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(0, language.compare("ja"));
sky 2013/02/12 17:30:07 EXPECT_EQ("ja", language) same pattern for other t
Takashi Toyoshima 2013/02/14 08:00:18 Done.
+
+ // Replace dash with hyphen.
+ language = std::string("ja_JP");
+ TranslateHelper::CorrectLanguageCodeTypo(&language);
+ EXPECT_EQ(0, language.compare("ja-JP"));
+
+ // Correct wrong cases.
+ language = std::string("JA-jp");
+ TranslateHelper::CorrectLanguageCodeTypo(&language);
+ EXPECT_EQ(0, language.compare("ja-JP"));
+}
+
// 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