diff options
-rw-r--r-- | base/file_util_unittest.cc | 4 | ||||
-rw-r--r-- | base/metrics/field_trial.cc | 3 | ||||
-rw-r--r-- | base/pr_time_unittest.cc | 118 | ||||
-rw-r--r-- | base/third_party/nspr/prtime.h | 2 | ||||
-rw-r--r-- | base/time.cc | 12 | ||||
-rw-r--r-- | base/time.h | 2 | ||||
-rw-r--r-- | base/time_unittest.cc | 219 | ||||
-rw-r--r-- | chrome/browser/web_resource/promo_resource_service.cc | 12 | ||||
-rw-r--r-- | chrome/common/metrics_helpers.cc | 2 | ||||
-rw-r--r-- | net/ftp/ftp_util_unittest.cc | 2 | ||||
-rw-r--r-- | net/http/http_response_headers.cc | 3 | ||||
-rw-r--r-- | net/http/http_response_headers_unittest.cc | 6 | ||||
-rw-r--r-- | webkit/blob/blob_storage_controller_unittest.cc | 8 | ||||
-rw-r--r-- | webkit/fileapi/file_system_dir_url_request_job_unittest.cc | 6 |
14 files changed, 157 insertions, 242 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index c60a703..fe3927d 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -1779,13 +1779,13 @@ TEST_F(FileUtilTest, TouchFile) { base::Time access_time; // This timestamp is divisible by one day (in local timezone), // to make it work on FAT too. - ASSERT_TRUE(base::Time::FromString("Wed, 16 Nov 1994, 00:00:00", + ASSERT_TRUE(base::Time::FromString(L"Wed, 16 Nov 1994, 00:00:00", &access_time)); base::Time modification_time; // Note that this timestamp is divisible by two (seconds) - FAT stores // modification times with 2s resolution. - ASSERT_TRUE(base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", &modification_time)); ASSERT_TRUE(file_util::TouchFile(foobar, access_time, modification_time)); diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc index 99dce41..2c87f07 100644 --- a/base/metrics/field_trial.cc +++ b/base/metrics/field_trial.cc @@ -157,7 +157,8 @@ FieldTrial::~FieldTrial() {} Time FieldTrial::GetBuildTime() { Time integral_build_time; const char* kDateTime = __DATE__ " " __TIME__; - bool result = Time::FromString(kDateTime, &integral_build_time); + bool result = Time::FromString(ASCIIToWide(kDateTime).c_str(), + &integral_build_time); DCHECK(result); return integral_build_time; } diff --git a/base/pr_time_unittest.cc b/base/pr_time_unittest.cc index 5c8bad1..646eb16 100644 --- a/base/pr_time_unittest.cc +++ b/base/pr_time_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -132,6 +132,122 @@ TEST_F(PRTimeTest, ParseTimeTest9) { EXPECT_EQ(parsed_time, comparison_time_pdt); } +// This tests the Time::FromString wrapper over PR_ParseTimeString +TEST_F(PRTimeTest, ParseTimeTest10) { + Time parsed_time; + bool result = Time::FromString(L"15/10/07 12:45", &parsed_time); + EXPECT_TRUE(result); + + time_t computed_time = parsed_time.ToTimeT(); + time_t time_to_compare = comparison_time_local_ / + Time::kMicrosecondsPerSecond; + EXPECT_EQ(computed_time, time_to_compare); +} + +// This tests the Time::FromString wrapper over PR_ParseTimeString +TEST_F(PRTimeTest, ParseTimeTest11) { + Time parsed_time; + bool result = Time::FromString(L"Mon, 15 Oct 2007 19:45:00 GMT", + &parsed_time); + EXPECT_TRUE(result); + + time_t computed_time = parsed_time.ToTimeT(); + time_t time_to_compare = comparison_time_pdt / Time::kMicrosecondsPerSecond; + EXPECT_EQ(computed_time, time_to_compare); +} + +// Test some of edge cases around epoch, etc. +TEST_F(PRTimeTest, ParseTimeTestEpoch0) { + Time parsed_time; + + // time_t == epoch == 0 + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 01:00:00 +0100 1970", + &parsed_time)); + EXPECT_EQ(0, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:00:00 GMT 1970", + &parsed_time)); + EXPECT_EQ(0, parsed_time.ToTimeT()); +} + +TEST_F(PRTimeTest, ParseTimeTestEpoch1) { + Time parsed_time; + + // time_t == 1 second after epoch == 1 + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 01:00:01 +0100 1970", + &parsed_time)); + EXPECT_EQ(1, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:00:01 GMT 1970", + &parsed_time)); + EXPECT_EQ(1, parsed_time.ToTimeT()); +} + +TEST_F(PRTimeTest, ParseTimeTestEpoch2) { + Time parsed_time; + + // time_t == 2 seconds after epoch == 2 + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 01:00:02 +0100 1970", + &parsed_time)); + EXPECT_EQ(2, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:00:02 GMT 1970", + &parsed_time)); + EXPECT_EQ(2, parsed_time.ToTimeT()); +} + +TEST_F(PRTimeTest, ParseTimeTestEpochNeg1) { + Time parsed_time; + + // time_t == 1 second before epoch == -1 + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:59:59 +0100 1970", + &parsed_time)); + EXPECT_EQ(-1, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Wed Dec 31 23:59:59 GMT 1969", + &parsed_time)); + EXPECT_EQ(-1, parsed_time.ToTimeT()); +} + +// If time_t is 32 bits, a date after year 2038 will overflow time_t and +// cause timegm() to return -1. The parsed time should not be 1 second +// before epoch. +TEST_F(PRTimeTest, ParseTimeTestEpochNotNeg1) { + Time parsed_time; + + EXPECT_TRUE(Time::FromString(L"Wed Dec 31 23:59:59 GMT 2100", + &parsed_time)); + EXPECT_NE(-1, parsed_time.ToTimeT()); +} + +TEST_F(PRTimeTest, ParseTimeTestEpochNeg2) { + Time parsed_time; + + // time_t == 2 seconds before epoch == -2 + EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:59:58 +0100 1970", + &parsed_time)); + EXPECT_EQ(-2, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Wed Dec 31 23:59:58 GMT 1969", + &parsed_time)); + EXPECT_EQ(-2, parsed_time.ToTimeT()); +} + +TEST_F(PRTimeTest, ParseTimeTestEpoch1960) { + Time parsed_time; + + // time_t before Epoch, in 1960 + EXPECT_TRUE(Time::FromString(L"Wed Jun 29 19:40:01 +0100 1960", + &parsed_time)); + EXPECT_EQ(-299999999, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Wed Jun 29 18:40:01 GMT 1960", + &parsed_time)); + EXPECT_EQ(-299999999, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString(L"Wed Jun 29 17:40:01 GMT 1960", + &parsed_time)); + EXPECT_EQ(-300003599, parsed_time.ToTimeT()); +} + +TEST_F(PRTimeTest, ParseTimeTestEmpty) { + Time parsed_time; + EXPECT_FALSE(Time::FromString(L"", &parsed_time)); +} + // This test should not crash when compiled with Visual C++ 2005 (see // http://crbug.com/4387). TEST_F(PRTimeTest, ParseTimeTestOutOfRange) { diff --git a/base/third_party/nspr/prtime.h b/base/third_party/nspr/prtime.h index be94794..a207021 100644 --- a/base/third_party/nspr/prtime.h +++ b/base/third_party/nspr/prtime.h @@ -230,7 +230,7 @@ NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt); * from the unit test. */ -NSPR_API(PRStatus) PR_ParseTimeString ( +BASE_API PRStatus PR_ParseTimeString ( const char *string, PRBool default_to_gmt, PRTime *result); diff --git a/base/time.cc b/base/time.cc index 859810e..766f599 100644 --- a/base/time.cc +++ b/base/time.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -98,18 +98,16 @@ Time Time::LocalMidnight() const { } // static -bool Time::FromString(const char* time_string, Time* parsed_time) { +bool Time::FromString(const wchar_t* time_string, Time* parsed_time) { DCHECK((time_string != NULL) && (parsed_time != NULL)); - - if (time_string[0] == '\0') + std::string ascii_time_string = SysWideToUTF8(time_string); + if (ascii_time_string.length() == 0) return false; - PRTime result_time = 0; - PRStatus result = PR_ParseTimeString(time_string, PR_FALSE, + PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, &result_time); if (PR_SUCCESS != result) return false; - result_time += kTimeTToMicrosecondsOffset; *parsed_time = Time(result_time); return true; diff --git a/base/time.h b/base/time.h index 9ece389..1b05e24 100644 --- a/base/time.h +++ b/base/time.h @@ -317,7 +317,7 @@ class BASE_API Time { // in the input string, we assume local time. // TODO(iyengar) Move the FromString/FromTimeT/ToTimeT/FromFileTime to // a new time converter class. - static bool FromString(const char* time_string, Time* parsed_time); + static bool FromString(const wchar_t* time_string, Time* parsed_time); // For serializing, use FromInternalValue to reconstitute. Please don't use // this and do arithmetic on it, as it is more error prone than using the diff --git a/base/time_unittest.cc b/base/time_unittest.cc index 6ba03b8..6c64b48 100644 --- a/base/time_unittest.cc +++ b/base/time_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,42 +13,8 @@ using base::Time; using base::TimeDelta; using base::TimeTicks; -// Specialized test fixture allowing time strings without timezones to be -// tested by comparing them to a known time in the local zone. -// See also pr_time_unittests.cc -class TimeTest : public testing::Test { - protected: - virtual void SetUp() { - // Use mktime to get a time_t, and turn it into a PRTime by converting - // seconds to microseconds. Use 15th Oct 2007 12:45:00 local. This - // must be a time guaranteed to be outside of a DST fallback hour in - // any timezone. - struct tm local_comparison_tm = { - 0, // second - 45, // minute - 12, // hour - 15, // day of month - 10 - 1, // month - 2007 - 1900, // year - 0, // day of week (ignored, output only) - 0, // day of year (ignored, output only) - -1 // DST in effect, -1 tells mktime to figure it out - }; - - time_t converted_time = mktime(&local_comparison_tm); - ASSERT_GT(converted_time, 0); - comparison_time_local_ = Time::FromTimeT(converted_time); - - // time_t representation of 15th Oct 2007 12:45:00 PDT - comparison_time_pdt_ = Time::FromTimeT(1192477500); - } - - Time comparison_time_local_; - Time comparison_time_pdt_; -}; - // Test conversions to/from time_t and exploding/unexploding. -TEST_F(TimeTest, TimeT) { +TEST(Time, TimeT) { // C library time and exploded time. time_t now_t_1 = time(NULL); struct tm tms; @@ -86,7 +52,7 @@ TEST_F(TimeTest, TimeT) { EXPECT_EQ(0, Time::FromTimeT(0).ToInternalValue()); } -TEST_F(TimeTest, FromExplodedWithMilliseconds) { +TEST(Time, FromExplodedWithMilliseconds) { // Some platform implementations of FromExploded are liable to drop // milliseconds if we aren't careful. Time now = Time::NowFromSystemTime(); @@ -99,14 +65,14 @@ TEST_F(TimeTest, FromExplodedWithMilliseconds) { EXPECT_EQ(exploded1.millisecond, exploded2.millisecond); } -TEST_F(TimeTest, ZeroIsSymmetric) { +TEST(Time, ZeroIsSymmetric) { Time zero_time(Time::FromTimeT(0)); EXPECT_EQ(0, zero_time.ToTimeT()); EXPECT_EQ(0.0, zero_time.ToDoubleT()); } -TEST_F(TimeTest, LocalExplode) { +TEST(Time, LocalExplode) { Time a = Time::Now(); Time::Exploded exploded; a.LocalExplode(&exploded); @@ -119,7 +85,7 @@ TEST_F(TimeTest, LocalExplode) { EXPECT_TRUE((a - b) < TimeDelta::FromSeconds(1)); } -TEST_F(TimeTest, UTCExplode) { +TEST(Time, UTCExplode) { Time a = Time::Now(); Time::Exploded exploded; a.UTCExplode(&exploded); @@ -128,7 +94,7 @@ TEST_F(TimeTest, UTCExplode) { EXPECT_TRUE((a - b) < TimeDelta::FromSeconds(1)); } -TEST_F(TimeTest, LocalMidnight) { +TEST(Time, LocalMidnight) { Time::Exploded exploded; Time::Now().LocalMidnight().LocalExplode(&exploded); EXPECT_EQ(0, exploded.hour); @@ -137,177 +103,6 @@ TEST_F(TimeTest, LocalMidnight) { EXPECT_EQ(0, exploded.millisecond); } -TEST_F(TimeTest, ParseTimeTest1) { - time_t current_time = 0; - time(¤t_time); - - const int BUFFER_SIZE = 64; - struct tm local_time = {0}; - char time_buf[BUFFER_SIZE] = {0}; -#if defined(OS_WIN) - localtime_s(&local_time, ¤t_time); - asctime_s(time_buf, arraysize(time_buf), &local_time); -#elif defined(OS_POSIX) - localtime_r(¤t_time, &local_time); - asctime_r(&local_time, time_buf); -#endif - - Time parsed_time; - EXPECT_TRUE(Time::FromString(time_buf, &parsed_time)); - EXPECT_EQ(current_time, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTest2) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest3) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest4) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest5) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest6) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest7) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest8) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest9) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest10) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time)); - EXPECT_EQ(parsed_time, comparison_time_local_); -} - -// Test some of edge cases around epoch, etc. -TEST_F(TimeTest, ParseTimeTestEpoch0) { - Time parsed_time; - - // time_t == epoch == 0 - EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:00 +0100 1970", - &parsed_time)); - EXPECT_EQ(0, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:00 GMT 1970", - &parsed_time)); - EXPECT_EQ(0, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpoch1) { - Time parsed_time; - - // time_t == 1 second after epoch == 1 - EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:01 +0100 1970", - &parsed_time)); - EXPECT_EQ(1, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:01 GMT 1970", - &parsed_time)); - EXPECT_EQ(1, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpoch2) { - Time parsed_time; - - // time_t == 2 seconds after epoch == 2 - EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:02 +0100 1970", - &parsed_time)); - EXPECT_EQ(2, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:02 GMT 1970", - &parsed_time)); - EXPECT_EQ(2, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpochNeg1) { - Time parsed_time; - - // time_t == 1 second before epoch == -1 - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:59 +0100 1970", - &parsed_time)); - EXPECT_EQ(-1, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 1969", - &parsed_time)); - EXPECT_EQ(-1, parsed_time.ToTimeT()); -} - -// If time_t is 32 bits, a date after year 2038 will overflow time_t and -// cause timegm() to return -1. The parsed time should not be 1 second -// before epoch. -TEST_F(TimeTest, ParseTimeTestEpochNotNeg1) { - Time parsed_time; - - EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100", - &parsed_time)); - EXPECT_NE(-1, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpochNeg2) { - Time parsed_time; - - // time_t == 2 seconds before epoch == -2 - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:58 +0100 1970", - &parsed_time)); - EXPECT_EQ(-2, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:58 GMT 1969", - &parsed_time)); - EXPECT_EQ(-2, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpoch1960) { - Time parsed_time; - - // time_t before Epoch, in 1960 - EXPECT_TRUE(Time::FromString("Wed Jun 29 19:40:01 +0100 1960", - &parsed_time)); - EXPECT_EQ(-299999999, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Jun 29 18:40:01 GMT 1960", - &parsed_time)); - EXPECT_EQ(-299999999, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Jun 29 17:40:01 GMT 1960", - &parsed_time)); - EXPECT_EQ(-300003599, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEmpty) { - Time parsed_time; - EXPECT_FALSE(Time::FromString("", &parsed_time)); -} - -TEST_F(TimeTest, ParseTimeTestInvalidString) { - Time parsed_time; - EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time)); -} - TEST(TimeTicks, Deltas) { for (int index = 0; index < 50; index++) { TimeTicks ticks_start = TimeTicks::Now(); diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc index 01aed7e..8c9e9a4 100644 --- a/chrome/browser/web_resource/promo_resource_service.cc +++ b/chrome/browser/web_resource/promo_resource_service.cc @@ -268,8 +268,10 @@ void PromoResourceService::UnpackPromoSignal( promo_end_string.length() > 0) { base::Time start_time; base::Time end_time; - if (base::Time::FromString(promo_start_string.c_str(), &start_time) && - base::Time::FromString(promo_end_string.c_str(), &end_time)) { + if (base::Time::FromString( + ASCIIToWide(promo_start_string).c_str(), &start_time) && + base::Time::FromString( + ASCIIToWide(promo_end_string).c_str(), &end_time)) { // Add group time slice, adjusted from hours to seconds. promo_start = start_time.ToDoubleT() + (prefs_->FindPreference(prefs::kNTPPromoGroup) ? @@ -428,8 +430,10 @@ void PromoResourceService::UnpackLogoSignal( logo_end_string.length() > 0) { base::Time start_time; base::Time end_time; - if (base::Time::FromString(logo_start_string.c_str(), &start_time) && - base::Time::FromString(logo_end_string.c_str(), &end_time)) { + if (base::Time::FromString( + ASCIIToWide(logo_start_string).c_str(), &start_time) && + base::Time::FromString( + ASCIIToWide(logo_end_string).c_str(), &end_time)) { logo_start = start_time.ToDoubleT(); logo_end = end_time.ToDoubleT(); } diff --git a/chrome/common/metrics_helpers.cc b/chrome/common/metrics_helpers.cc index 028d0b3..0441862 100644 --- a/chrome/common/metrics_helpers.cc +++ b/chrome/common/metrics_helpers.cc @@ -372,7 +372,7 @@ int64 MetricsLogBase::GetBuildTime() { if (!integral_build_time) { Time time; const char* kDateTime = __DATE__ " " __TIME__ " GMT"; - bool result = Time::FromString(kDateTime, &time); + bool result = Time::FromString(ASCIIToWide(kDateTime).c_str(), &time); DCHECK(result); integral_build_time = static_cast<int64>(time.ToTimeT()); } diff --git a/net/ftp/ftp_util_unittest.cc b/net/ftp/ftp_util_unittest.cc index 94c1837..4f26817 100644 --- a/net/ftp/ftp_util_unittest.cc +++ b/net/ftp/ftp_util_unittest.cc @@ -106,7 +106,7 @@ TEST(FtpUtilTest, VMSPathToUnix) { TEST(FtpUtilTest, LsDateListingToTime) { base::Time mock_current_time; - ASSERT_TRUE(base::Time::FromString("Tue, 15 Nov 1994 12:45:26 GMT", + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", &mock_current_time)); const struct { diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc index 5d46cb6..9b7ffc2 100644 --- a/net/http/http_response_headers.cc +++ b/net/http/http_response_headers.cc @@ -1047,7 +1047,8 @@ bool HttpResponseHeaders::GetTimeValuedHeader(const std::string& name, if (!EnumerateHeader(NULL, name, &value)) return false; - return Time::FromString(value.c_str(), result); + std::wstring value_wide(value.begin(), value.end()); // inflate ascii + return Time::FromString(value_wide.c_str(), result); } bool HttpResponseHeaders::IsKeepAlive() const { diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 4848510..483667c 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -812,9 +812,9 @@ TEST(HttpResponseHeadersTest, RequiresValidation) { // TODO(darin): add many many more tests here }; base::Time request_time, response_time, current_time; - base::Time::FromString("Wed, 28 Nov 2007 00:40:09 GMT", &request_time); - base::Time::FromString("Wed, 28 Nov 2007 00:40:12 GMT", &response_time); - base::Time::FromString("Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); + base::Time::FromString(L"Wed, 28 Nov 2007 00:40:09 GMT", &request_time); + base::Time::FromString(L"Wed, 28 Nov 2007 00:40:12 GMT", &response_time); + base::Time::FromString(L"Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::string headers(tests[i].headers); diff --git a/webkit/blob/blob_storage_controller_unittest.cc b/webkit/blob/blob_storage_controller_unittest.cc index 27beb44..884c18a 100644 --- a/webkit/blob/blob_storage_controller_unittest.cc +++ b/webkit/blob/blob_storage_controller_unittest.cc @@ -18,8 +18,8 @@ namespace webkit_blob { TEST(BlobStorageControllerTest, RegisterBlobUrl) { // Setup a set of blob data for testing. base::Time time1, time2; - base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); - base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); + base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", &time1); + base::Time::FromString(L"Mon, 14 Nov 1994, 11:30:49 GMT", &time2); scoped_refptr<BlobData> blob_data1(new BlobData()); blob_data1->AppendData("Data1"); @@ -80,8 +80,8 @@ TEST(BlobStorageControllerTest, RegisterBlobUrl) { TEST(BlobStorageControllerTest, ResolveBlobReferencesInUploadData) { // Setup blob data for testing. base::Time time1, time2; - base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); - base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); + base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", &time1); + base::Time::FromString(L"Mon, 14 Nov 1994, 11:30:49 GMT", &time2); scoped_ptr<BlobStorageController> blob_storage_controller( new BlobStorageController()); diff --git a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc index 738c64d..a40c6a0 100644 --- a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc @@ -196,9 +196,9 @@ class FileSystemDirURLRequestJobTest : public testing::Test { base::Time date; icu::UnicodeString date_ustr(match.group(5, status)); - std::string date_str; - UTF16ToUTF8(date_ustr.getBuffer(), date_ustr.length(), &date_str); - EXPECT_TRUE(base::Time::FromString(date_str.c_str(), &date)); + std::wstring date_wstr; + UTF16ToWide(date_ustr.getBuffer(), date_ustr.length(), &date_wstr); + EXPECT_TRUE(base::Time::FromString(date_wstr.c_str(), &date)); EXPECT_FALSE(date.is_null()); } |