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

Side by Side Diff: ui/base/l10n/time_format_unittest.cc

Issue 2747253004: Implement (FORMAT_ELAPSED, LENGTH_LONG) in time_format (Closed)
Patch Set: Created 3 years, 9 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 | « ui/base/l10n/time_format.h ('k') | ui/strings/ui_strings.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 "ui/base/l10n/time_format.h" 5 #include "ui/base/l10n/time_format.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 EXPECT_EQ(ASCIIToUTF16("1 day left"), TimeFormat::Simple( 108 EXPECT_EQ(ASCIIToUTF16("1 day left"), TimeFormat::Simple(
109 TimeFormat::FORMAT_REMAINING, TimeFormat::LENGTH_LONG, delta_1d_)); 109 TimeFormat::FORMAT_REMAINING, TimeFormat::LENGTH_LONG, delta_1d_));
110 EXPECT_EQ(ASCIIToUTF16("1 sec ago"), TimeFormat::Simple( 110 EXPECT_EQ(ASCIIToUTF16("1 sec ago"), TimeFormat::Simple(
111 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1s_)); 111 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1s_));
112 EXPECT_EQ(ASCIIToUTF16("1 min ago"), TimeFormat::Simple( 112 EXPECT_EQ(ASCIIToUTF16("1 min ago"), TimeFormat::Simple(
113 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1m_)); 113 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1m_));
114 EXPECT_EQ(ASCIIToUTF16("1 hour ago"), TimeFormat::Simple( 114 EXPECT_EQ(ASCIIToUTF16("1 hour ago"), TimeFormat::Simple(
115 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1h_)); 115 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1h_));
116 EXPECT_EQ(ASCIIToUTF16("1 day ago"), TimeFormat::Simple( 116 EXPECT_EQ(ASCIIToUTF16("1 day ago"), TimeFormat::Simple(
117 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1d_)); 117 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_1d_));
118 EXPECT_EQ(ASCIIToUTF16("1 second ago"),
119 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
120 TimeFormat::LENGTH_LONG, delta_1s_));
121 EXPECT_EQ(ASCIIToUTF16("1 minute ago"),
122 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
123 TimeFormat::LENGTH_LONG, delta_1m_));
124 EXPECT_EQ(ASCIIToUTF16("1 hour ago"),
125 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
126 TimeFormat::LENGTH_LONG, delta_1h_));
127 EXPECT_EQ(ASCIIToUTF16("1 day ago"),
128 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
129 TimeFormat::LENGTH_LONG, delta_1d_));
118 130
119 // Test English strings (simple, plural). 131 // Test English strings (simple, plural).
120 EXPECT_EQ(ASCIIToUTF16("2 secs"), TimeFormat::Simple( 132 EXPECT_EQ(ASCIIToUTF16("2 secs"), TimeFormat::Simple(
121 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2s_)); 133 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2s_));
122 EXPECT_EQ(ASCIIToUTF16("2 mins"), TimeFormat::Simple( 134 EXPECT_EQ(ASCIIToUTF16("2 mins"), TimeFormat::Simple(
123 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2m_)); 135 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2m_));
124 EXPECT_EQ(ASCIIToUTF16("2 hours"), TimeFormat::Simple( 136 EXPECT_EQ(ASCIIToUTF16("2 hours"), TimeFormat::Simple(
125 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2h_)); 137 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2h_));
126 EXPECT_EQ(ASCIIToUTF16("2 days"), TimeFormat::Simple( 138 EXPECT_EQ(ASCIIToUTF16("2 days"), TimeFormat::Simple(
127 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2d_)); 139 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_SHORT, delta_2d_));
(...skipping 22 matching lines...) Expand all
150 EXPECT_EQ(ASCIIToUTF16("2 days left"), TimeFormat::Simple( 162 EXPECT_EQ(ASCIIToUTF16("2 days left"), TimeFormat::Simple(
151 TimeFormat::FORMAT_REMAINING, TimeFormat::LENGTH_LONG, delta_2d_)); 163 TimeFormat::FORMAT_REMAINING, TimeFormat::LENGTH_LONG, delta_2d_));
152 EXPECT_EQ(ASCIIToUTF16("2 secs ago"), TimeFormat::Simple( 164 EXPECT_EQ(ASCIIToUTF16("2 secs ago"), TimeFormat::Simple(
153 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2s_)); 165 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2s_));
154 EXPECT_EQ(ASCIIToUTF16("2 mins ago"), TimeFormat::Simple( 166 EXPECT_EQ(ASCIIToUTF16("2 mins ago"), TimeFormat::Simple(
155 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2m_)); 167 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2m_));
156 EXPECT_EQ(ASCIIToUTF16("2 hours ago"), TimeFormat::Simple( 168 EXPECT_EQ(ASCIIToUTF16("2 hours ago"), TimeFormat::Simple(
157 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2h_)); 169 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2h_));
158 EXPECT_EQ(ASCIIToUTF16("2 days ago"), TimeFormat::Simple( 170 EXPECT_EQ(ASCIIToUTF16("2 days ago"), TimeFormat::Simple(
159 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2d_)); 171 TimeFormat::FORMAT_ELAPSED, TimeFormat::LENGTH_SHORT, delta_2d_));
172 EXPECT_EQ(ASCIIToUTF16("2 seconds ago"),
173 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
174 TimeFormat::LENGTH_LONG, delta_2s_));
175 EXPECT_EQ(ASCIIToUTF16("2 minutes ago"),
176 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
177 TimeFormat::LENGTH_LONG, delta_2m_));
178 EXPECT_EQ(ASCIIToUTF16("2 hours ago"),
179 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
180 TimeFormat::LENGTH_SHORT, delta_2h_));
181 EXPECT_EQ(ASCIIToUTF16("2 days ago"),
182 TimeFormat::Simple(TimeFormat::FORMAT_ELAPSED,
183 TimeFormat::LENGTH_SHORT, delta_2d_));
160 184
161 // Test English strings (detailed, singular and plural). 185 // Test English strings (detailed, singular and plural).
162 EXPECT_EQ(ASCIIToUTF16("1 minute and 2 seconds"), TimeFormat::Detailed( 186 EXPECT_EQ(ASCIIToUTF16("1 minute and 2 seconds"), TimeFormat::Detailed(
163 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_1m2s_)); 187 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_1m2s_));
164 EXPECT_EQ(ASCIIToUTF16("2 minutes and 1 second"), TimeFormat::Detailed( 188 EXPECT_EQ(ASCIIToUTF16("2 minutes and 1 second"), TimeFormat::Detailed(
165 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_2m1s_)); 189 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_2m1s_));
166 EXPECT_EQ(ASCIIToUTF16("1 hour and 2 minutes"), TimeFormat::Detailed( 190 EXPECT_EQ(ASCIIToUTF16("1 hour and 2 minutes"), TimeFormat::Detailed(
167 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_1h2m_)); 191 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_1h2m_));
168 EXPECT_EQ(ASCIIToUTF16("2 hours and 1 minute"), TimeFormat::Detailed( 192 EXPECT_EQ(ASCIIToUTF16("2 hours and 1 minute"), TimeFormat::Detailed(
169 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_2h1m_)); 193 TimeFormat::FORMAT_DURATION, TimeFormat::LENGTH_LONG, 3, delta_2h1m_));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 TimeFormat::RelativeDate(two_days_ago, NULL); 367 TimeFormat::RelativeDate(two_days_ago, NULL);
344 EXPECT_TRUE(two_days_ago_str.empty()); 368 EXPECT_TRUE(two_days_ago_str.empty());
345 369
346 base::Time a_week_ago = now - TimeDelta::FromDays(7); 370 base::Time a_week_ago = now - TimeDelta::FromDays(7);
347 base::string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL); 371 base::string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL);
348 EXPECT_TRUE(a_week_ago_str.empty()); 372 EXPECT_TRUE(a_week_ago_str.empty());
349 } 373 }
350 374
351 } // namespace 375 } // namespace
352 } // namespace ui 376 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/l10n/time_format.h ('k') | ui/strings/ui_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698