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

Unified Diff: base/i18n/time_formatting_unittest.cc

Issue 2573183002: Add process start time and CPU time columns to task manager (Closed)
Patch Set: Fix nits and conflicts. 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
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | chrome/app/generated_resources.grd » ('j') | 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 51a48513aca6c10d4610501f4f29a861dc0a1fb9..e57ac3b5fc302af0c237458eb1d86800688ff1d0 100644
--- a/base/i18n/time_formatting_unittest.cc
+++ b/base/i18n/time_formatting_unittest.cc
@@ -265,5 +265,54 @@ TEST(TimeFormattingTest, TimeDurationFormat) {
EXPECT_EQ(fa_numeric, TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC));
}
+TEST(TimeFormattingTest, TimeDurationFormatWithSeconds) {
+ test::ScopedRestoreICUDefaultLocale restore_locale;
+
+ // US English.
+ i18n::SetICUDefaultLocale("en_US");
+
+ // Test different formats.
+ TimeDelta delta = TimeDelta::FromSeconds(15 * 3600 + 42 * 60 + 30);
+ EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes, 30 seconds"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min, 30 sec"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(ASCIIToUTF16("15h 42m 30s"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
+ EXPECT_EQ(ASCIIToUTF16("15:42:30"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NUMERIC));
+
+ // Test edge case when hour >= 100.
+ delta = TimeDelta::FromSeconds(125 * 3600 + 42 * 60 + 30);
+ EXPECT_EQ(ASCIIToUTF16("125 hours, 42 minutes, 30 seconds"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(ASCIIToUTF16("125 hr, 42 min, 30 sec"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(ASCIIToUTF16("125h 42m 30s"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
+
+ // Test edge case when minute = 0.
+ delta = TimeDelta::FromSeconds(15 * 3600 + 0 * 60 + 30);
+ EXPECT_EQ(ASCIIToUTF16("15 hours, 0 minutes, 30 seconds"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(ASCIIToUTF16("15 hr, 0 min, 30 sec"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(ASCIIToUTF16("15h 0m 30s"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
+ EXPECT_EQ(ASCIIToUTF16("15:00:30"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NUMERIC));
+
+ // Test edge case when second = 0.
+ delta = TimeDelta::FromSeconds(15 * 3600 + 42 * 60 + 0);
+ EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes, 0 seconds"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
+ EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min, 0 sec"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
+ EXPECT_EQ(ASCIIToUTF16("15h 42m 0s"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
+ EXPECT_EQ(ASCIIToUTF16("15:42:00"),
+ TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NUMERIC));
+}
+
} // namespace
} // namespace base
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698