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

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

Issue 2570253002: [MD History] Fix toolbar dates in grouped mode. (Closed)
Patch Set: Created 4 years 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time)); 181 EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time));
182 182
183 EXPECT_EQ(ASCIIToUTF16("Apr 30, 2011"), TimeFormatShortDate(time)); 183 EXPECT_EQ(ASCIIToUTF16("Apr 30, 2011"), TimeFormatShortDate(time));
184 EXPECT_EQ(ASCIIToUTF16("4/30/11"), TimeFormatShortDateNumeric(time)); 184 EXPECT_EQ(ASCIIToUTF16("4/30/11"), TimeFormatShortDateNumeric(time));
185 185
186 EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM"), 186 EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM"),
187 TimeFormatShortDateAndTime(time)); 187 TimeFormatShortDateAndTime(time));
188 EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM ") + GetShortTimeZone(time), 188 EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM ") + GetShortTimeZone(time),
189 TimeFormatShortDateAndTimeWithTimeZone(time)); 189 TimeFormatShortDateAndTimeWithTimeZone(time));
190 190
191 EXPECT_EQ(ASCIIToUTF16("April 2011"), TimeFormatMonthAndYear(time));
192 EXPECT_EQ(ASCIIToUTF16("Saturday, April 30"),
193 TimeFormatWeekdayMonthAndDay(time));
194
191 EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011 at 3:42:07 PM"), 195 EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011 at 3:42:07 PM"),
192 TimeFormatFriendlyDateAndTime(time)); 196 TimeFormatFriendlyDateAndTime(time));
193 197
194 EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011"), 198 EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011"),
195 TimeFormatFriendlyDate(time)); 199 TimeFormatFriendlyDate(time));
196 } 200 }
197 201
198 #if defined(OS_ANDROID) 202 #if defined(OS_ANDROID)
199 #define MAYBE_TimeFormatDateGB DISABLED_TimeFormatDateGB 203 #define MAYBE_TimeFormatDateGB DISABLED_TimeFormatDateGB
200 #else 204 #else
201 #define MAYBE_TimeFormatDateGB TimeFormatDateGB 205 #define MAYBE_TimeFormatDateGB TimeFormatDateGB
202 #endif 206 #endif
203 TEST(TimeFormattingTest, MAYBE_TimeFormatDateGB) { 207 TEST(TimeFormattingTest, MAYBE_TimeFormatDateGB) {
204 // See third_party/icu/source/data/locales/en_GB.txt. 208 // See third_party/icu/source/data/locales/en_GB.txt.
205 // The date patterns are "EEEE, d MMMM y", "d MMM y", and "dd/MM/yyyy". 209 // The date patterns are "EEEE, d MMMM y", "d MMM y", and "dd/MM/yyyy".
206 test::ScopedRestoreICUDefaultLocale restore_locale; 210 test::ScopedRestoreICUDefaultLocale restore_locale;
207 i18n::SetICUDefaultLocale("en_GB"); 211 i18n::SetICUDefaultLocale("en_GB");
208 212
209 Time time; 213 Time time;
210 EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time)); 214 EXPECT_TRUE(Time::FromLocalExploded(kTestDateTimeExploded, &time));
211 215
212 EXPECT_EQ(ASCIIToUTF16("30 Apr 2011"), TimeFormatShortDate(time)); 216 EXPECT_EQ(ASCIIToUTF16("30 Apr 2011"), TimeFormatShortDate(time));
213 EXPECT_EQ(ASCIIToUTF16("30/04/2011"), TimeFormatShortDateNumeric(time)); 217 EXPECT_EQ(ASCIIToUTF16("30/04/2011"), TimeFormatShortDateNumeric(time));
214 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07"), 218 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07"),
215 TimeFormatShortDateAndTime(time)); 219 TimeFormatShortDateAndTime(time));
216 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07 ") + GetShortTimeZone(time), 220 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07 ") + GetShortTimeZone(time),
217 TimeFormatShortDateAndTimeWithTimeZone(time)); 221 TimeFormatShortDateAndTimeWithTimeZone(time));
222 EXPECT_EQ(ASCIIToUTF16("April 2011"), TimeFormatMonthAndYear(time));
223 EXPECT_EQ(ASCIIToUTF16("Saturday 30 April"),
224 TimeFormatWeekdayMonthAndDay(time));
218 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"), 225 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"),
219 TimeFormatFriendlyDateAndTime(time)); 226 TimeFormatFriendlyDateAndTime(time));
220 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"), 227 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"),
221 TimeFormatFriendlyDate(time)); 228 TimeFormatFriendlyDate(time));
222 } 229 }
223 230
224 TEST(TimeFormattingTest, TimeDurationFormat) { 231 TEST(TimeFormattingTest, TimeDurationFormat) {
225 test::ScopedRestoreICUDefaultLocale restore_locale; 232 test::ScopedRestoreICUDefaultLocale restore_locale;
226 TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42); 233 TimeDelta delta = TimeDelta::FromMinutes(15 * 60 + 42);
227 234
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 L"\x642\x647"); 267 L"\x642\x647");
261 string16 fa_numeric = WideToUTF16(L"\x6f1\x6f5\x3a\x6f4\x6f2"); 268 string16 fa_numeric = WideToUTF16(L"\x6f1\x6f5\x3a\x6f4\x6f2");
262 EXPECT_EQ(fa_wide, TimeDurationFormat(delta, DURATION_WIDTH_WIDE)); 269 EXPECT_EQ(fa_wide, TimeDurationFormat(delta, DURATION_WIDTH_WIDE));
263 EXPECT_EQ(fa_short, TimeDurationFormat(delta, DURATION_WIDTH_SHORT)); 270 EXPECT_EQ(fa_short, TimeDurationFormat(delta, DURATION_WIDTH_SHORT));
264 EXPECT_EQ(fa_narrow, TimeDurationFormat(delta, DURATION_WIDTH_NARROW)); 271 EXPECT_EQ(fa_narrow, TimeDurationFormat(delta, DURATION_WIDTH_NARROW));
265 EXPECT_EQ(fa_numeric, TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC)); 272 EXPECT_EQ(fa_numeric, TimeDurationFormat(delta, DURATION_WIDTH_NUMERIC));
266 } 273 }
267 274
268 } // namespace 275 } // namespace
269 } // namespace base 276 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698