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
3 // found in the LICENSE file.
5 #include "ui/base/l10n/time_format.h"
7 #include "base/files/file_path.h"
8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/base/l10n/formatter.h"
13 #include "ui/base/resource/resource_bundle.h"
15 using base::ASCIIToUTF16
;
20 using base::TimeDelta
;
22 class TimeFormatTest
: public ::testing::Test
{
25 delta_0s_(TimeDelta::FromSeconds(0)),
26 delta_1ms_(TimeDelta::FromMilliseconds(1)),
27 delta_499ms_(TimeDelta::FromMilliseconds(499)),
28 delta_500ms_(TimeDelta::FromMilliseconds(500)),
29 delta_999ms_(TimeDelta::FromMilliseconds(999)),
30 delta_1s_(TimeDelta::FromSeconds(1)),
31 delta_1s499ms_(delta_1s_
+ delta_499ms_
),
32 delta_1s500ms_(delta_1s_
+ delta_500ms_
),
33 delta_2s_(TimeDelta::FromSeconds(2)),
34 delta_29s_(TimeDelta::FromSeconds(29)),
35 delta_30s_(TimeDelta::FromSeconds(30)),
36 delta_59s_(TimeDelta::FromSeconds(59)),
37 delta_59s499ms_(delta_59s_
+ delta_499ms_
),
38 delta_59s500ms_(delta_59s_
+ delta_500ms_
),
39 delta_1m_(TimeDelta::FromMinutes(1)),
40 delta_1m2s_(delta_1m_
+ delta_2s_
),
41 delta_1m29s999ms_(delta_1m_
+ delta_29s_
+ delta_999ms_
),
42 delta_1m30s_(delta_1m_
+ delta_30s_
),
43 delta_2m_(TimeDelta::FromMinutes(2)),
44 delta_2m1s_(delta_2m_
+ delta_1s_
),
45 delta_29m_(TimeDelta::FromMinutes(29)),
46 delta_30m_(TimeDelta::FromMinutes(30)),
47 delta_59m_(TimeDelta::FromMinutes(59)),
48 delta_59m29s999ms_(delta_59m_
+ delta_29s_
+ delta_999ms_
),
49 delta_59m30s_(delta_59m_
+ delta_30s_
),
50 delta_59m59s499ms_(delta_59m_
+ delta_59s_
+ delta_499ms_
),
51 delta_59m59s500ms_(delta_59m_
+ delta_59s_
+ delta_500ms_
),
52 delta_1h_(TimeDelta::FromHours(1)),
53 delta_1h2m_(delta_1h_
+ delta_2m_
),
54 delta_1h29m59s999ms_(delta_1h_
+ delta_29m_
+ delta_59s_
+ delta_999ms_
),
55 delta_1h30m_(delta_1h_
+ delta_30m_
),
56 delta_2h_(TimeDelta::FromHours(2)),
57 delta_2h1m_(delta_2h_
+ delta_1m_
),
58 delta_11h_(TimeDelta::FromHours(11)),
59 delta_12h_(TimeDelta::FromHours(12)),
60 delta_23h_(TimeDelta::FromHours(23)),
61 delta_23h29m59s999ms_(delta_23h_
+ delta_29m_
+ delta_59s_
+
63 delta_23h30m_(delta_23h_
+ delta_30m_
),
64 delta_23h59m29s999ms_(delta_23h_
+ delta_59m_
+ delta_29s_
+
66 delta_23h59m30s_(delta_23h_
+ delta_59m_
+ delta_30s_
),
67 delta_1d_(TimeDelta::FromDays(1)),
68 delta_1d2h_(delta_1d_
+ delta_2h_
),
69 delta_1d11h59m59s999ms_(delta_1d_
+ delta_11h_
+ delta_59m_
+ delta_29s_
+
71 delta_1d12h_(delta_1d_
+ delta_12h_
),
72 delta_2d_(TimeDelta::FromDays(2)),
73 delta_2d1h_(delta_2d_
+ delta_1h_
)
78 // Test English strings (simple, singular).
79 EXPECT_EQ(ASCIIToUTF16("1 sec"), TimeFormat::Simple(
80 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1s_
));
81 EXPECT_EQ(ASCIIToUTF16("1 min"), TimeFormat::Simple(
82 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1m_
));
83 EXPECT_EQ(ASCIIToUTF16("1 hour"), TimeFormat::Simple(
84 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1h_
));
85 EXPECT_EQ(ASCIIToUTF16("1 day"), TimeFormat::Simple(
86 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1d_
));
87 EXPECT_EQ(ASCIIToUTF16("1 second"), TimeFormat::Simple(
88 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_1s_
));
89 EXPECT_EQ(ASCIIToUTF16("1 minute"), TimeFormat::Simple(
90 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_1m_
));
91 EXPECT_EQ(ASCIIToUTF16("1 hour"), TimeFormat::Simple(
92 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_1h_
));
93 EXPECT_EQ(ASCIIToUTF16("1 day"), TimeFormat::Simple(
94 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_1d_
));
95 EXPECT_EQ(ASCIIToUTF16("1 sec left"), TimeFormat::Simple(
96 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_1s_
));
97 EXPECT_EQ(ASCIIToUTF16("1 min left"), TimeFormat::Simple(
98 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_1m_
));
99 EXPECT_EQ(ASCIIToUTF16("1 hour left"), TimeFormat::Simple(
100 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_1h_
));
101 EXPECT_EQ(ASCIIToUTF16("1 day left"), TimeFormat::Simple(
102 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_1d_
));
103 EXPECT_EQ(ASCIIToUTF16("1 second left"), TimeFormat::Simple(
104 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_1s_
));
105 EXPECT_EQ(ASCIIToUTF16("1 minute left"), TimeFormat::Simple(
106 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_1m_
));
107 EXPECT_EQ(ASCIIToUTF16("1 hour left"), TimeFormat::Simple(
108 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_1h_
));
109 EXPECT_EQ(ASCIIToUTF16("1 day left"), TimeFormat::Simple(
110 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_1d_
));
111 EXPECT_EQ(ASCIIToUTF16("1 sec ago"), TimeFormat::Simple(
112 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_1s_
));
113 EXPECT_EQ(ASCIIToUTF16("1 min ago"), TimeFormat::Simple(
114 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_1m_
));
115 EXPECT_EQ(ASCIIToUTF16("1 hour ago"), TimeFormat::Simple(
116 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_1h_
));
117 EXPECT_EQ(ASCIIToUTF16("1 day ago"), TimeFormat::Simple(
118 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_1d_
));
120 // Test English strings (simple, plural).
121 EXPECT_EQ(ASCIIToUTF16("2 secs"), TimeFormat::Simple(
122 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_2s_
));
123 EXPECT_EQ(ASCIIToUTF16("2 mins"), TimeFormat::Simple(
124 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_2m_
));
125 EXPECT_EQ(ASCIIToUTF16("2 hours"), TimeFormat::Simple(
126 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_2h_
));
127 EXPECT_EQ(ASCIIToUTF16("2 days"), TimeFormat::Simple(
128 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_2d_
));
129 EXPECT_EQ(ASCIIToUTF16("2 seconds"), TimeFormat::Simple(
130 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_2s_
));
131 EXPECT_EQ(ASCIIToUTF16("2 minutes"), TimeFormat::Simple(
132 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_2m_
));
133 EXPECT_EQ(ASCIIToUTF16("2 hours"), TimeFormat::Simple(
134 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_2h_
));
135 EXPECT_EQ(ASCIIToUTF16("2 days"), TimeFormat::Simple(
136 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, delta_2d_
));
137 EXPECT_EQ(ASCIIToUTF16("2 secs left"), TimeFormat::Simple(
138 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_2s_
));
139 EXPECT_EQ(ASCIIToUTF16("2 mins left"), TimeFormat::Simple(
140 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_2m_
));
141 EXPECT_EQ(ASCIIToUTF16("2 hours left"), TimeFormat::Simple(
142 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_2h_
));
143 EXPECT_EQ(ASCIIToUTF16("2 days left"), TimeFormat::Simple(
144 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_SHORT
, delta_2d_
));
145 EXPECT_EQ(ASCIIToUTF16("2 seconds left"), TimeFormat::Simple(
146 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_2s_
));
147 EXPECT_EQ(ASCIIToUTF16("2 minutes left"), TimeFormat::Simple(
148 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_2m_
));
149 EXPECT_EQ(ASCIIToUTF16("2 hours left"), TimeFormat::Simple(
150 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_2h_
));
151 EXPECT_EQ(ASCIIToUTF16("2 days left"), TimeFormat::Simple(
152 TimeFormat::FORMAT_REMAINING
, TimeFormat::LENGTH_LONG
, delta_2d_
));
153 EXPECT_EQ(ASCIIToUTF16("2 secs ago"), TimeFormat::Simple(
154 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_2s_
));
155 EXPECT_EQ(ASCIIToUTF16("2 mins ago"), TimeFormat::Simple(
156 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_2m_
));
157 EXPECT_EQ(ASCIIToUTF16("2 hours ago"), TimeFormat::Simple(
158 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_2h_
));
159 EXPECT_EQ(ASCIIToUTF16("2 days ago"), TimeFormat::Simple(
160 TimeFormat::FORMAT_ELAPSED
, TimeFormat::LENGTH_SHORT
, delta_2d_
));
162 // Test English strings (detailed, singular and plural).
163 EXPECT_EQ(ASCIIToUTF16("1 minute 2 seconds"), TimeFormat::Detailed(
164 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 3, delta_1m2s_
));
165 EXPECT_EQ(ASCIIToUTF16("2 minutes 1 second"), TimeFormat::Detailed(
166 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 3, delta_2m1s_
));
167 EXPECT_EQ(ASCIIToUTF16("1 hour 2 minutes"), TimeFormat::Detailed(
168 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 3, delta_1h2m_
));
169 EXPECT_EQ(ASCIIToUTF16("2 hours 1 minute"), TimeFormat::Detailed(
170 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 3, delta_2h1m_
));
171 EXPECT_EQ(ASCIIToUTF16("1 day 2 hours"), TimeFormat::Detailed(
172 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 3, delta_1d2h_
));
173 EXPECT_EQ(ASCIIToUTF16("2 days 1 hour"), TimeFormat::Detailed(
174 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 3, delta_2d1h_
));
178 TimeDelta delta_1ms_
;
179 TimeDelta delta_499ms_
;
180 TimeDelta delta_500ms_
;
181 TimeDelta delta_999ms_
;
183 TimeDelta delta_1s499ms_
;
184 TimeDelta delta_1s500ms_
;
186 TimeDelta delta_29s_
;
187 TimeDelta delta_30s_
;
188 TimeDelta delta_59s_
;
189 TimeDelta delta_59s499ms_
;
190 TimeDelta delta_59s500ms_
;
192 TimeDelta delta_1m2s_
;
193 TimeDelta delta_1m29s999ms_
;
194 TimeDelta delta_1m30s_
;
196 TimeDelta delta_2m1s_
;
197 TimeDelta delta_29m_
;
198 TimeDelta delta_30m_
;
199 TimeDelta delta_59m_
;
200 TimeDelta delta_59m29s999ms_
;
201 TimeDelta delta_59m30s_
;
202 TimeDelta delta_59m59s499ms_
;
203 TimeDelta delta_59m59s500ms_
;
205 TimeDelta delta_1h2m_
;
206 TimeDelta delta_1h29m59s999ms_
;
207 TimeDelta delta_1h30m_
;
209 TimeDelta delta_2h1m_
;
210 TimeDelta delta_11h_
;
211 TimeDelta delta_12h_
;
212 TimeDelta delta_23h_
;
213 TimeDelta delta_23h29m59s999ms_
;
214 TimeDelta delta_23h30m_
;
215 TimeDelta delta_23h59m29s999ms_
;
216 TimeDelta delta_23h59m30s_
;
218 TimeDelta delta_1d2h_
;
219 TimeDelta delta_1d11h59m59s999ms_
;
220 TimeDelta delta_1d12h_
;
222 TimeDelta delta_2d1h_
;
225 TEST_F(TimeFormatTest
, SimpleAndDetailedRounding
) {
226 // Test rounding behavior (simple).
227 EXPECT_EQ(ASCIIToUTF16("0 secs"), TimeFormat::Simple(
228 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_0s_
));
229 EXPECT_EQ(ASCIIToUTF16("0 secs"), TimeFormat::Simple(
230 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_499ms_
));
231 EXPECT_EQ(ASCIIToUTF16("1 sec"), TimeFormat::Simple(
232 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_500ms_
));
233 EXPECT_EQ(ASCIIToUTF16("1 sec"), TimeFormat::Simple(
234 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1s499ms_
));
235 EXPECT_EQ(ASCIIToUTF16("2 secs"), TimeFormat::Simple(
236 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1s500ms_
));
237 EXPECT_EQ(ASCIIToUTF16("59 secs"), TimeFormat::Simple(
238 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_59s499ms_
));
239 EXPECT_EQ(ASCIIToUTF16("1 min"), TimeFormat::Simple(
240 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_59s500ms_
));
241 EXPECT_EQ(ASCIIToUTF16("1 min"), TimeFormat::Simple(
242 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
,
244 EXPECT_EQ(ASCIIToUTF16("2 mins"), TimeFormat::Simple(
245 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1m30s_
));
246 EXPECT_EQ(ASCIIToUTF16("59 mins"), TimeFormat::Simple(
247 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
,
248 delta_59m29s999ms_
));
249 EXPECT_EQ(ASCIIToUTF16("1 hour"), TimeFormat::Simple(
250 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_59m30s_
));
251 EXPECT_EQ(ASCIIToUTF16("1 hour"), TimeFormat::Simple(
252 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
,
253 delta_1h29m59s999ms_
));
254 EXPECT_EQ(ASCIIToUTF16("2 hours"), TimeFormat::Simple(
255 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1h30m_
));
256 EXPECT_EQ(ASCIIToUTF16("23 hours"), TimeFormat::Simple(
257 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
,
258 delta_23h29m59s999ms_
));
259 EXPECT_EQ(ASCIIToUTF16("1 day"), TimeFormat::Simple(
260 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_23h30m_
));
261 EXPECT_EQ(ASCIIToUTF16("1 day"), TimeFormat::Simple(
262 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
,
263 delta_1d11h59m59s999ms_
));
264 EXPECT_EQ(ASCIIToUTF16("2 days"), TimeFormat::Simple(
265 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_SHORT
, delta_1d12h_
));
267 // Test rounding behavior (detailed).
268 EXPECT_EQ(ASCIIToUTF16("59 seconds"), TimeFormat::Detailed(
269 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 100,
271 EXPECT_EQ(ASCIIToUTF16("1 minute 0 seconds"), TimeFormat::Detailed(
272 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 2,
274 EXPECT_EQ(ASCIIToUTF16("1 minute"), TimeFormat::Detailed(
275 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 1,
277 EXPECT_EQ(ASCIIToUTF16("59 minutes 59 seconds"), TimeFormat::Detailed(
278 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 60,
279 delta_59m59s499ms_
));
280 EXPECT_EQ(ASCIIToUTF16("1 hour 0 minutes"), TimeFormat::Detailed(
281 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 59,
282 delta_59m59s499ms_
));
283 EXPECT_EQ(ASCIIToUTF16("1 hour 0 minutes"), TimeFormat::Detailed(
284 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 2,
285 delta_59m59s499ms_
));
286 EXPECT_EQ(ASCIIToUTF16("1 hour"), TimeFormat::Detailed(
287 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 1,
288 delta_59m59s499ms_
));
289 EXPECT_EQ(ASCIIToUTF16("1 hour"), TimeFormat::Detailed(
290 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 1,
291 delta_59m59s500ms_
));
292 EXPECT_EQ(ASCIIToUTF16("1 hour 0 minutes"), TimeFormat::Detailed(
293 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 2,
294 delta_59m59s500ms_
));
295 EXPECT_EQ(ASCIIToUTF16("23 hours 59 minutes"), TimeFormat::Detailed(
296 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 24,
297 delta_23h59m29s999ms_
));
298 EXPECT_EQ(ASCIIToUTF16("1 day 0 hours"), TimeFormat::Detailed(
299 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 23,
300 delta_23h59m29s999ms_
));
301 EXPECT_EQ(ASCIIToUTF16("1 day 0 hours"), TimeFormat::Detailed(
302 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 2,
303 delta_23h59m29s999ms_
));
304 EXPECT_EQ(ASCIIToUTF16("1 day"), TimeFormat::Detailed(
305 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 1,
306 delta_23h59m29s999ms_
));
307 EXPECT_EQ(ASCIIToUTF16("1 day"), TimeFormat::Detailed(
308 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 1,
310 EXPECT_EQ(ASCIIToUTF16("1 day 0 hours"), TimeFormat::Detailed(
311 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, 2,
313 EXPECT_EQ(ASCIIToUTF16("1 day 0 hours"), TimeFormat::Detailed(
314 TimeFormat::FORMAT_DURATION
, TimeFormat::LENGTH_LONG
, -1,
318 // Test strings in default code path.
319 TEST_F(TimeFormatTest
, SimpleAndDetailedStrings
) {
323 // Test strings in fallback path in case of translator error.
324 TEST_F(TimeFormatTest
, SimpleAndDetailedStringFallback
) {
325 formatter_force_fallback
= true;
326 g_container
.Get().ResetForTesting();
328 formatter_force_fallback
= false;
329 g_container
.Get().ResetForTesting();
332 // crbug.com/159388: This test fails when daylight savings time ends.
333 TEST_F(TimeFormatTest
, RelativeDate
) {
334 base::Time now
= base::Time::Now();
335 base::string16 today_str
= TimeFormat::RelativeDate(now
, NULL
);
336 EXPECT_EQ(ASCIIToUTF16("Today"), today_str
);
338 base::Time yesterday
= now
- TimeDelta::FromDays(1);
339 base::string16 yesterday_str
= TimeFormat::RelativeDate(yesterday
, NULL
);
340 EXPECT_EQ(ASCIIToUTF16("Yesterday"), yesterday_str
);
342 base::Time two_days_ago
= now
- TimeDelta::FromDays(2);
343 base::string16 two_days_ago_str
=
344 TimeFormat::RelativeDate(two_days_ago
, NULL
);
345 EXPECT_TRUE(two_days_ago_str
.empty());
347 base::Time a_week_ago
= now
- TimeDelta::FromDays(7);
348 base::string16 a_week_ago_str
= TimeFormat::RelativeDate(a_week_ago
, NULL
);
349 EXPECT_TRUE(a_week_ago_str
.empty());