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

Side by Side Diff: base/i18n/time_formatting_unittest.cc

Issue 2607043002: [Autofill] Credit Card Autofill Last Used Date Experiment (Closed)
Patch Set: Fixed conflicts Created 3 years, 10 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
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 TimeFormatShortDateAndTime(time)); 217 TimeFormatShortDateAndTime(time));
218 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07 ") + GetShortTimeZone(time), 218 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07 ") + GetShortTimeZone(time),
219 TimeFormatShortDateAndTimeWithTimeZone(time)); 219 TimeFormatShortDateAndTimeWithTimeZone(time));
220 EXPECT_EQ(ASCIIToUTF16("April 2011"), TimeFormatMonthAndYear(time)); 220 EXPECT_EQ(ASCIIToUTF16("April 2011"), TimeFormatMonthAndYear(time));
221 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"), 221 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"),
222 TimeFormatFriendlyDateAndTime(time)); 222 TimeFormatFriendlyDateAndTime(time));
223 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"), 223 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"),
224 TimeFormatFriendlyDate(time)); 224 TimeFormatFriendlyDate(time));
225 } 225 }
226 226
227 TEST(TimeFormattingTest, TimeFormatWithPattern) {
228 test::ScopedRestoreICUDefaultLocale restore_locale;
229
230 Time time;
231 EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time));
232
233 i18n::SetICUDefaultLocale("en_US");
jungshik at Google 2017/01/26 19:29:14 Thank for adding tests. I'm sorry that I forgot
jiahuiguo 2017/01/27 09:31:05 Thanks for the comments, separate to different uni
234 EXPECT_EQ(ASCIIToUTF16("Apr 30, 2011"), TimeFormatWithPattern(time, "yMMMd"));
235 EXPECT_EQ(ASCIIToUTF16("April 30, 3:42:07 PM"),
236 TimeFormatWithPattern(time, "MMMMdjmmss"));
237
238 i18n::SetICUDefaultLocale("en_GB");
239 EXPECT_EQ(ASCIIToUTF16("30 Apr 2011"), TimeFormatWithPattern(time, "yMMMd"));
240 EXPECT_EQ(ASCIIToUTF16("30 April, 15:42:07"),
241 TimeFormatWithPattern(time, "MMMMdjmmss"));
242
243 i18n::SetICUDefaultLocale("ja_JP");
244 EXPECT_EQ(WideToUTF16(L"2011\x5e74"
245 L"4\x6708"
246 L"30\x65e5"),
jungshik at Google 2017/01/26 19:29:14 Now that every compiler we use support UTF-16 stri
jiahuiguo 2017/01/27 09:31:05 Actually if we use u"2011年4月30日" as the first para
247 TimeFormatWithPattern(time, "yMMMd"));
248 EXPECT_EQ(WideToUTF16(L"4\x6708"
249 L"30\x65e5") +
250 ASCIIToUTF16(" 15:42:07"),
251 TimeFormatWithPattern(time, "MMMMdjmmss"));
252 }
253
227 TEST(TimeFormattingTest, TimeDurationFormat) { 254 TEST(TimeFormattingTest, TimeDurationFormat) {
228 test::ScopedRestoreICUDefaultLocale restore_locale; 255 test::ScopedRestoreICUDefaultLocale restore_locale;
229 TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42); 256 TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42);
230 257
231 // US English. 258 // US English.
232 i18n::SetICUDefaultLocale("en_US"); 259 i18n::SetICUDefaultLocale("en_US");
233 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes"), 260 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes"),
234 TimeDurationFormat(delta, DURATION_WIDTH_WIDE)); 261 TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
235 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min"), 262 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min"),
236 TimeDurationFormat(delta, DURATION_WIDTH_SHORT)); 263 TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 Time end_time; 358 Time end_time;
332 EXPECT_TRUE(Time::FromLocalExploded(kTestIntervalEndTimeExploded, &end_time)); 359 EXPECT_TRUE(Time::FromLocalExploded(kTestIntervalEndTimeExploded, &end_time));
333 360
334 EXPECT_EQ( 361 EXPECT_EQ(
335 WideToUTF16(L"Saturday, April 30 – Saturday, May 28"), 362 WideToUTF16(L"Saturday, April 30 – Saturday, May 28"),
336 DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY)); 363 DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY));
337 } 364 }
338 365
339 } // namespace 366 } // namespace
340 } // namespace base 367 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698