Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/common/time_format.h" | 5 #include "chrome/common/time_format.h" |
| 6 | 6 |
| 7 #include "base/string16.h" | 7 #include "base/string16.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 TestTimeFormats(one_min + five_secs, "1 min"); | 42 TestTimeFormats(one_min + five_secs, "1 min"); |
| 43 TestTimeFormats(three_mins + twohundred_millisecs, "3 mins"); | 43 TestTimeFormats(three_mins + twohundred_millisecs, "3 mins"); |
| 44 TestTimeFormats(one_hour + five_secs, "1 hour"); | 44 TestTimeFormats(one_hour + five_secs, "1 hour"); |
| 45 TestTimeFormats(four_hours + five_secs, "4 hours"); | 45 TestTimeFormats(four_hours + five_secs, "4 hours"); |
| 46 TestTimeFormats(one_day + five_secs, "1 day"); | 46 TestTimeFormats(one_day + five_secs, "1 day"); |
| 47 TestTimeFormats(three_days, "3 days"); | 47 TestTimeFormats(three_days, "3 days"); |
| 48 TestTimeFormats(three_days + four_hours, "3 days"); | 48 TestTimeFormats(three_days + four_hours, "3 days"); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // crbug.com/159388: This test fails when daylight savings time ends. | 51 // crbug.com/159388: This test fails when daylight savings time ends. |
| 52 TEST(TimeFormat, FLAKY_RelativeDate) { | 52 TEST(TimeFormat, RelativeDate) { |
|
jam
2012/12/21 23:12:22
seems like this should be DISABLED
| |
| 53 base::Time now = base::Time::Now(); | 53 base::Time now = base::Time::Now(); |
| 54 string16 today_str = TimeFormat::RelativeDate(now, NULL); | 54 string16 today_str = TimeFormat::RelativeDate(now, NULL); |
| 55 EXPECT_EQ(ASCIIToUTF16("Today"), today_str); | 55 EXPECT_EQ(ASCIIToUTF16("Today"), today_str); |
| 56 | 56 |
| 57 base::Time yesterday = now - TimeDelta::FromDays(1); | 57 base::Time yesterday = now - TimeDelta::FromDays(1); |
| 58 string16 yesterday_str = TimeFormat::RelativeDate(yesterday, NULL); | 58 string16 yesterday_str = TimeFormat::RelativeDate(yesterday, NULL); |
| 59 EXPECT_EQ(ASCIIToUTF16("Yesterday"), yesterday_str); | 59 EXPECT_EQ(ASCIIToUTF16("Yesterday"), yesterday_str); |
| 60 | 60 |
| 61 base::Time two_days_ago = now - TimeDelta::FromDays(2); | 61 base::Time two_days_ago = now - TimeDelta::FromDays(2); |
| 62 string16 two_days_ago_str = TimeFormat::RelativeDate(two_days_ago, NULL); | 62 string16 two_days_ago_str = TimeFormat::RelativeDate(two_days_ago, NULL); |
| 63 EXPECT_TRUE(two_days_ago_str.empty()); | 63 EXPECT_TRUE(two_days_ago_str.empty()); |
| 64 | 64 |
| 65 base::Time a_week_ago = now - TimeDelta::FromDays(7); | 65 base::Time a_week_ago = now - TimeDelta::FromDays(7); |
| 66 string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL); | 66 string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL); |
| 67 EXPECT_TRUE(a_week_ago_str.empty()); | 67 EXPECT_TRUE(a_week_ago_str.empty()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| OLD | NEW |