| Index: chrome/browser/web_resource/promo_resource_service_unittest.cc
|
| diff --git a/chrome/browser/web_resource/promo_resource_service_unittest.cc b/chrome/browser/web_resource/promo_resource_service_unittest.cc
|
| index 57dfad684a337efbf90759dbb1c0fc4b0d9f078a..2c06d7bddf51e2669889ed838c24de7daa948166 100644
|
| --- a/chrome/browser/web_resource/promo_resource_service_unittest.cc
|
| +++ b/chrome/browser/web_resource/promo_resource_service_unittest.cc
|
| @@ -32,28 +32,26 @@ namespace {
|
|
|
| const char kDateFormat[] = "dd MMM yyyy HH:mm:ss zzz";
|
|
|
| -std::pair<double, std::string> YearFromNow() {
|
| +bool YearFromNow(double* date_epoch, std::string* date_string) {
|
| + *date_epoch = (base::Time::Now() + base::TimeDelta::FromDays(365)).ToTimeT();
|
| +
|
| UErrorCode status = U_ZERO_ERROR;
|
| icu::SimpleDateFormat simple_formatter(icu::UnicodeString(kDateFormat),
|
| icu::Locale("en_US"),
|
| status);
|
| - DCHECK(U_SUCCESS(status));
|
| -
|
| - const double year_from_now =
|
| - (base::Time::Now() + base::TimeDelta::FromDays(365)).ToTimeT();
|
| + if (!U_SUCCESS(status))
|
| + return false;
|
|
|
| icu::UnicodeString date_unicode_string;
|
| - simple_formatter.format(static_cast<UDate>(year_from_now * 1000),
|
| + simple_formatter.format(static_cast<UDate>(*date_epoch * 1000),
|
| date_unicode_string,
|
| status);
|
| - DCHECK(U_SUCCESS(status));
|
| + if (!U_SUCCESS(status))
|
| + return false;
|
|
|
| - std::string date_string;
|
| - UTF16ToUTF8(date_unicode_string.getBuffer(),
|
| - static_cast<size_t>(date_unicode_string.length()),
|
| - &date_string);
|
| -
|
| - return std::make_pair(year_from_now, date_string);
|
| + return UTF16ToUTF8(date_unicode_string.getBuffer(),
|
| + static_cast<size_t>(date_unicode_string.length()),
|
| + date_string);
|
| }
|
|
|
| } // namespace
|
| @@ -90,13 +88,16 @@ class NotificationPromoTest {
|
| double start,
|
| int num_groups, int initial_segment, int increment,
|
| int time_slice, int max_group, int max_views) {
|
| - std::pair<double, std::string> year_from_now = YearFromNow();
|
| + double year_from_now_epoch;
|
| + std::string year_from_now_string;
|
| + ASSERT_TRUE(YearFromNow(&year_from_now_epoch, &year_from_now_string));
|
| +
|
| std::vector<std::string> replacements;
|
| - replacements.push_back(year_from_now.second);
|
| + replacements.push_back(year_from_now_string);
|
|
|
| - std::string json_with_year(
|
| + std::string json_with_end_date(
|
| ReplaceStringPlaceholders(json, replacements, NULL));
|
| - Value* value(base::JSONReader::Read(json_with_year));
|
| + Value* value(base::JSONReader::Read(json_with_end_date));
|
| ASSERT_TRUE(value);
|
|
|
| DictionaryValue* dict = NULL;
|
| @@ -108,7 +109,7 @@ class NotificationPromoTest {
|
| promo_text_ = promo_text;
|
|
|
| start_ = start;
|
| - end_ = year_from_now.first;
|
| + end_ = year_from_now_epoch;
|
|
|
| num_groups_ = num_groups;
|
| initial_segment_ = initial_segment;
|
|
|