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

Unified Diff: ui/base/l10n/time_format_unittest.cc

Issue 139413005: Add tests for TimeRemainingLong() and TimeDurationLong() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes/improvements, as suggested by Bartosz Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/time_format_unittest.cc
diff --git a/ui/base/l10n/time_format_unittest.cc b/ui/base/l10n/time_format_unittest.cc
index 2392d2c41df460475d051b60a0019f01ebeed65c..f2c855707321fcb9c2878904928cc4d8d06593f4 100644
--- a/ui/base/l10n/time_format_unittest.cc
+++ b/ui/base/l10n/time_format_unittest.cc
@@ -18,12 +18,28 @@ namespace {
using base::TimeDelta;
void TestTimeFormats(const TimeDelta& delta, const char* expected_ascii) {
- base::string16 expected = ASCIIToUTF16(expected_ascii);
- base::string16 expected_left = expected + ASCIIToUTF16(" left");
- base::string16 expected_ago = expected + ASCIIToUTF16(" ago");
+ const base::string16 expected(ASCIIToUTF16(expected_ascii));
+ const base::string16 sec(ASCIIToUTF16("sec"));
+ const base::string16 min(ASCIIToUTF16("min"));
+
+ // expected_long_minute has "min" replaced by "minute".
+ base::string16 expected_long_minute = expected;
+ if (expected_long_minute.find(min) != base::string16::npos)
+ expected_long_minute.insert(expected_long_minute.find(min) + min.length(),
+ ASCIIToUTF16("ute"));
+
+ // expected_long has {"sec","min"} replaced by {"second","minute"}.
+ base::string16 expected_long = expected_long_minute;
+ if (expected_long.find(sec) != base::string16::npos)
+ expected_long.insert(expected_long.find(sec) + sec.length(),
+ ASCIIToUTF16("ond"));
jungshik at Google 2014/02/03 18:03:01 This string manipulation is really hacky, I'm afra
+
+ EXPECT_EQ(expected + ASCIIToUTF16(" ago"), TimeFormat::TimeElapsed(delta));
+ EXPECT_EQ(expected + ASCIIToUTF16(" left"), TimeFormat::TimeRemaining(delta));
+ EXPECT_EQ(expected_long_minute + ASCIIToUTF16(" left"),
+ TimeFormat::TimeRemainingLong(delta));
EXPECT_EQ(expected, TimeFormat::TimeRemainingShort(delta));
- EXPECT_EQ(expected_left, TimeFormat::TimeRemaining(delta));
- EXPECT_EQ(expected_ago, TimeFormat::TimeElapsed(delta));
+ EXPECT_EQ(expected_long, TimeFormat::TimeDurationLong(delta));
}
TEST(TimeFormat, FormatTime) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698