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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/i18n/time_formatting.h" 5 #include "base/i18n/time_formatting.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 string16 fa_narrow = WideToUTF16( 258 string16 fa_narrow = WideToUTF16(
259 L"\x6f1\x6f5\x20\x633\x627\x639\x62a\x20\x6f4\x6f2\x20\x62f\x642\x6cc" 259 L"\x6f1\x6f5\x20\x633\x627\x639\x62a\x20\x6f4\x6f2\x20\x62f\x642\x6cc"
260 L"\x642\x647"); 260 L"\x642\x647");
261 string16 fa_numeric = WideToUTF16(L"\x6f1\x6f5\x3a\x6f4\x6f2"); 261 string16 fa_numeric = WideToUTF16(L"\x6f1\x6f5\x3a\x6f4\x6f2");
262 EXPECT_EQ(fa_wide, TimeDurationFormat(delta, DURATION_WIDTH_WIDE)); 262 EXPECT_EQ(fa_wide, TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
263 EXPECT_EQ(fa_short, TimeDurationFormat(delta, DURATION_WIDTH_SHORT)); 263 EXPECT_EQ(fa_short, TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
264 EXPECT_EQ(fa_narrow, TimeDurationFormat(delta, DURATION_WIDTH_NARROW)); 264 EXPECT_EQ(fa_narrow, TimeDurationFormat(delta, DURATION_WIDTH_NARROW));
265 EXPECT_EQ(fa_numeric, TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC)); 265 EXPECT_EQ(fa_numeric, TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC));
266 } 266 }
267 267
268 TEST(TimeFormattingTest, TimeDurationFormatWithSeconds) {
269 test::ScopedRestoreICUDefaultLocale restore_locale;
270
271 // US English.
272 i18n::SetICUDefaultLocale("en_US");
273
274 // Test different formats.
275 TimeDelta delta = TimeDelta::FromSeconds(15 * 3600 + 42 * 60 + 30);
276 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes, 30 seconds"),
277 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
278 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min, 30 sec"),
279 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
280 EXPECT_EQ(ASCIIToUTF16("15h 42m 30s"),
281 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
282 EXPECT_EQ(ASCIIToUTF16("15:42:30"),
283 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NUMERIC));
284
285 // Test edge case when hour >= 100.
286 delta = TimeDelta::FromSeconds(125 * 3600 + 42 * 60 + 30);
287 EXPECT_EQ(ASCIIToUTF16("125 hours, 42 minutes, 30 seconds"),
288 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
289 EXPECT_EQ(ASCIIToUTF16("125 hr, 42 min, 30 sec"),
290 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
291 EXPECT_EQ(ASCIIToUTF16("125h 42m 30s"),
292 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
293
294 // Test edge case when minute = 0.
295 delta = TimeDelta::FromSeconds(15 * 3600 + 0 * 60 + 30);
296 EXPECT_EQ(ASCIIToUTF16("15 hours, 0 minutes, 30 seconds"),
297 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
298 EXPECT_EQ(ASCIIToUTF16("15 hr, 0 min, 30 sec"),
299 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
300 EXPECT_EQ(ASCIIToUTF16("15h 0m 30s"),
301 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
302 EXPECT_EQ(ASCIIToUTF16("15:00:30"),
303 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NUMERIC));
304
305 // Test edge case when second = 0.
306 delta = TimeDelta::FromSeconds(15 * 3600 + 42 * 60 + 0);
307 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes, 0 seconds"),
308 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_WIDE));
309 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min, 0 sec"),
310 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_SHORT));
311 EXPECT_EQ(ASCIIToUTF16("15h 42m 0s"),
312 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NARROW));
313 EXPECT_EQ(ASCIIToUTF16("15:42:00"),
314 TimeDurationFormatWithSeconds(delta, DURATION_WIDTH_NUMERIC));
315 }
316
268 } // namespace 317 } // namespace
269 } // namespace base 318 } // namespace base
OLDNEW
« 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