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

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

Issue 2607043002: [Autofill] Credit Card Autofill Last Used Date Experiment (Closed)
Patch Set: Addressed comments 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
« 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 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");
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年4月30日"),
245 TimeFormatWithPattern(time, "yMMMd"));
246 EXPECT_EQ(WideToUTF16(L"4月30日") + ASCIIToUTF16(" 15:42:07"),
247 TimeFormatWithPattern(time, "MMMMdjmmss"));
248 }
249
227 TEST(TimeFormattingTest, TimeDurationFormat) { 250 TEST(TimeFormattingTest, TimeDurationFormat) {
228 test::ScopedRestoreICUDefaultLocale restore_locale; 251 test::ScopedRestoreICUDefaultLocale restore_locale;
229 TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42); 252 TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42);
230 253
231 // US English. 254 // US English.
232 i18n::SetICUDefaultLocale("en_US"); 255 i18n::SetICUDefaultLocale("en_US");
233 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes"), 256 EXPECT_EQ(ASCIIToUTF16("15 hours, 42 minutes"),
234 TimeDurationFormat(delta, DURATION_WIDTH_WIDE)); 257 TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
235 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min"), 258 EXPECT_EQ(ASCIIToUTF16("15 hr, 42 min"),
236 TimeDurationFormat(delta, DURATION_WIDTH_SHORT)); 259 TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 Time end_time; 354 Time end_time;
332 EXPECT_TRUE(Time::FromLocalExploded(kTestIntervalEndTimeExploded, &end_time)); 355 EXPECT_TRUE(Time::FromLocalExploded(kTestIntervalEndTimeExploded, &end_time));
333 356
334 EXPECT_EQ( 357 EXPECT_EQ(
335 WideToUTF16(L"Saturday, April 30 – Saturday, May 28"), 358 WideToUTF16(L"Saturday, April 30 – Saturday, May 28"),
336 DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY)); 359 DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY));
337 } 360 }
338 361
339 } // namespace 362 } // namespace
340 } // namespace base 363 } // 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