Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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, TimeDurationWFormatWithSecondPrecison) { | |
| 269 test::ScopedRestoreICUDefaultLocale restore_locale; | |
| 270 TimeDelta delta = TimeDelta::FromSeconds(15 * 3600 + 42 * 60 + 30); | |
| 271 | |
| 272 // US English. | |
| 273 i18n::SetICUDefaultLocale("en_US"); | |
| 274 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes, 30 seconds"), | |
|
brucedawson
2016/12/19 21:51:05
Should add some tests for times like 15 hours, 0 m
chengx
2016/12/20 00:51:12
Done.
| |
| 275 TimeDurationWFormatWithSecondPrecison(delta, DURATION_WIDTH_WIDE)); | |
| 276 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min, 30 sec"), | |
| 277 TimeDurationWFormatWithSecondPrecison(delta, DURATION_WIDTH_SHORT)); | |
| 278 EXPECT_EQ(ASCIIToUTF16("15h 42m 30s"), TimeDurationWFormatWithSecondPrecison( | |
| 279 delta, DURATION_WIDTH_NARROW)); | |
| 280 EXPECT_EQ(ASCIIToUTF16("15:42:30"), TimeDurationWFormatWithSecondPrecison( | |
|
stanisc
2016/12/19 22:44:10
Should add tests for times with greater than 24 or
chengx
2016/12/20 00:51:12
Actually we have a bug in //base that when the hou
| |
| 281 delta, DURATION_WIDTH_NUMERIC)); | |
| 282 } | |
| 283 | |
| 268 } // namespace | 284 } // namespace |
| 269 } // namespace base | 285 } // namespace base |
| OLD | NEW |