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

Unified Diff: base/i18n/time_formatting_unittest.cc

Issue 2607043002: [Autofill] Credit Card Autofill Last Used Date Experiment (Closed)
Patch Set: Enable unittest on android for time_formatting Created 3 years, 11 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: base/i18n/time_formatting_unittest.cc
diff --git a/base/i18n/time_formatting_unittest.cc b/base/i18n/time_formatting_unittest.cc
index 06cd77284a61b388e0f12f13778dda8da3f4862b..a211cbd2c804bbc230a263f7deb514fcfd0dee7f 100644
--- a/base/i18n/time_formatting_unittest.cc
+++ b/base/i18n/time_formatting_unittest.cc
@@ -224,6 +224,43 @@ TEST(TimeFormattingTest, MAYBE_TimeFormatDateGB) {
TimeFormatFriendlyDate(time));
}
+TEST(TimeFormattingTest, TimeFormatWithPatternUS) {
+ test::ScopedRestoreICUDefaultLocale restore_locale;
jungshik at Google 2017/01/27 21:51:35 Thank you for finding this :-). With this(ScopedR
jiahuiguo 2017/02/03 07:11:17 Cool, grouped them into one test.
+
+ Time time;
+ EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time));
+
+ i18n::SetICUDefaultLocale("en_US");
+ EXPECT_EQ(ASCIIToUTF16("Apr 30, 2011"), TimeFormatWithPattern(time, "yMMMd"));
+ EXPECT_EQ(ASCIIToUTF16("April 30, 3:42:07 PM"),
+ TimeFormatWithPattern(time, "MMMMdjmmss"));
+}
+
+TEST(TimeFormattingTest, TimeFormatWithPatternGB) {
+ test::ScopedRestoreICUDefaultLocale restore_locale;
+
+ Time time;
+ EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time));
+
+ i18n::SetICUDefaultLocale("en_GB");
+ EXPECT_EQ(ASCIIToUTF16("30 Apr 2011"), TimeFormatWithPattern(time, "yMMMd"));
+ EXPECT_EQ(ASCIIToUTF16("30 April, 15:42:07"),
+ TimeFormatWithPattern(time, "MMMMdjmmss"));
+}
+
+TEST(TimeFormattingTest, TimeFormatWithPatternJP) {
+ test::ScopedRestoreICUDefaultLocale restore_locale;
+
+ Time time;
+ EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time));
+
+ i18n::SetICUDefaultLocale("ja_JP");
+ EXPECT_EQ(WideToUTF16(L"2011年4月30日"),
+ TimeFormatWithPattern(time, "yMMMd"));
jungshik at Google 2017/01/27 21:43:30 An alternative would be EXPET_EQ(u8"2011年4月30日",
jiahuiguo 2017/02/03 07:11:17 Done.
+ EXPECT_EQ(WideToUTF16(L"4月30日") + ASCIIToUTF16(" 15:42:07"),
+ TimeFormatWithPattern(time, "MMMMdjmmss"));
+}
+
TEST(TimeFormattingTest, TimeDurationFormat) {
test::ScopedRestoreICUDefaultLocale restore_locale;
TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42);

Powered by Google App Engine
This is Rietveld 408576698