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

Unified Diff: base/i18n/time_formatting_unittest.cc

Issue 1951493002: Fix i18n number formats in tray power displays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch unit test from Bengali to Persian for Android (and merge) Created 4 years, 7 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 | « base/i18n/time_formatting.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/time_formatting_unittest.cc
diff --git a/base/i18n/time_formatting_unittest.cc b/base/i18n/time_formatting_unittest.cc
index b07eb47ac92d67aaa510ed623b37e0544a24222e..51eebc26cf698c600531d358fa64eec725241f0d 100644
--- a/base/i18n/time_formatting_unittest.cc
+++ b/base/i18n/time_formatting_unittest.cc
@@ -216,5 +216,49 @@ TEST(TimeFormattingTest, MAYBE_TimeFormatDateGB) {
TimeFormatFriendlyDate(time));
}
+TEST(TimeFormattingTest, TimeDurationFormat) {
+ test::ScopedRestoreICUDefaultLocale restore_locale;
+ TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42);
+
+ // US English.
+ i18n::SetICUDefaultLocale("en_US");
+ EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes"),
+ TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min"),
+ TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(ASCIIToUTF16("15h 42m"),
+ TimeDurationFormat(delta, DURATION_WIDTH_NARROW));
+ EXPECT_EQ(ASCIIToUTF16("15:42"),
+ TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC));
+
+ // Danish, with Latin alphabet but different abbreviations and punctuation.
+ i18n::SetICUDefaultLocale("da");
+ EXPECT_EQ(ASCIIToUTF16("15 timer og 42 minutter"),
+ TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(ASCIIToUTF16("15 t og 42 min."),
+ TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(ASCIIToUTF16("15 t og 42 min"),
+ TimeDurationFormat(delta, DURATION_WIDTH_NARROW));
+ EXPECT_EQ(ASCIIToUTF16("15.42"),
+ TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC));
+
+ // Persian, with non-Arabic numbers.
+ i18n::SetICUDefaultLocale("fa");
+ string16 fa_wide = WideToUTF16(
+ L"\x6f1\x6f5\x20\x633\x627\x639\x62a\x20\x648\x20\x6f4\x6f2\x20\x62f\x642"
+ L"\x6cc\x642\x647");
+ string16 fa_short = WideToUTF16(
+ L"\x6f1\x6f5\x20\x633\x627\x639\x62a\x60c\x200f\x20\x6f4\x6f2\x20\x62f"
+ L"\x642\x6cc\x642\x647");
+ string16 fa_narrow = WideToUTF16(
+ L"\x6f1\x6f5\x20\x633\x627\x639\x62a\x20\x6f4\x6f2\x20\x62f\x642\x6cc"
+ L"\x642\x647");
+ string16 fa_numeric = WideToUTF16(L"\x6f1\x6f5\x3a\x6f4\x6f2");
+ EXPECT_EQ(fa_wide, TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(fa_short, TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(fa_narrow, TimeDurationFormat(delta, DURATION_WIDTH_NARROW));
+ EXPECT_EQ(fa_numeric, TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC));
+}
+
} // namespace
} // namespace base
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698