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

Unified Diff: chrome/browser/web_resource/promo_resource_service_unittest.cc

Issue 11823007: Fix some pecularities in my C++ style for achuith@. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 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: 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..b4fe5639bd0f84dc2ff52933c5fa5492046ae6e8 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_double, std::string* date_string) {
achuithb 2013/01/08 22:44:43 You still need a function comment. Can we rename d
Dan Beam 2013/01/08 22:53:06 Done.
+ *date_double = (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_double * 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_double;
achuithb 2013/01/08 22:44:43 year_from_now_epoch or year_from_now_msec?
Dan Beam 2013/01/08 22:53:06 Done.
+ std::string year_from_now_string;
+ ASSERT_TRUE(YearFromNow(&year_from_now_double, &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_double;
num_groups_ = num_groups;
initial_segment_ = initial_segment;
« 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