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

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: Re-formatted according to Bartosz' suggestions 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 6f6acc42cd6008e9ebef23af354c585b88490d89..129fd795893e6a284aef982bab7c6b3483f133ba 100644
--- a/ui/base/l10n/time_format_unittest.cc
+++ b/ui/base/l10n/time_format_unittest.cc
@@ -18,12 +18,31 @@ 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"));
+ const base::string16 ond(ASCIIToUTF16("ond"));
bartfab (slow) 2014/01/31 12:58:23 Nit: No longer used.
Thiemo Nagel 2014/01/31 14:10:36 Done.
+ const base::string16 ute();
bartfab (slow) 2014/01/31 12:58:23 Nit: No longer used and actually completely wrong
Thiemo Nagel 2014/01/31 14:10:36 That's embarrassing. I forgot to remove ond and ut
+
+ base::string16 expected_long = expected; // sec, min --> second, minute
+ base::string16 expected_long_minute = expected; // min --> minute
+
+ if (expected_long.find(sec) != base::string16::npos)
+ expected_long.insert(expected_long.find(sec) + sec.length(),
+ ASCIIToUTF16("ond"));
+ if (expected_long.find(min) != base::string16::npos)
+ expected_long.insert(expected_long.find(min) + min.length(),
+ ASCIIToUTF16("ute"));
+ if (expected_long_minute.find(min) != base::string16::npos)
bartfab (slow) 2014/01/31 12:58:23 Nit: Not sure whether it would make things cleaner
Thiemo Nagel 2014/01/31 14:10:36 Good idea! I have the impression that this makes t
+ expected_long_minute.insert(expected_long_minute.find(min) + min.length(),
+ ASCIIToUTF16("ute"));
+
+ 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));
bartfab (slow) 2014/01/31 12:58:23 Is there a reason that TimeDurationLong() expands
Thiemo Nagel 2014/01/31 14:10:36 I fully agree. However, this behaviour is documen
}
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