| Index: chrome/common/time_format_unittest.cc
|
| diff --git a/chrome/common/time_format_unittest.cc b/chrome/common/time_format_unittest.cc
|
| index 1fdf0808e0f22f7c9c802cdbeb79223dcbd30f78..31976e3bd40838f24bf9f31e7429f12b64f3b351 100644
|
| --- a/chrome/common/time_format_unittest.cc
|
| +++ b/chrome/common/time_format_unittest.cc
|
| @@ -1,11 +1,13 @@
|
| -// Copyright (c) 2006-2008 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.
|
|
|
| #include <time.h>
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/string16.h"
|
| #include "base/time.h"
|
| +#include "base/utf_string_conversions.h"
|
| #include "chrome/common/time_format.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -14,26 +16,27 @@ using base::TimeDelta;
|
|
|
| TEST(TimeFormat, RelativeDate) {
|
| Time now = Time::Now();
|
| - std::wstring today_str = TimeFormat::RelativeDate(now, NULL);
|
| - EXPECT_EQ(L"Today", today_str);
|
| + string16 today_str = TimeFormat::RelativeDate(now, NULL);
|
| + EXPECT_EQ(ASCIIToUTF16("Today"), today_str);
|
|
|
| Time yesterday = now - TimeDelta::FromDays(1);
|
| - std::wstring yesterday_str = TimeFormat::RelativeDate(yesterday, NULL);
|
| - EXPECT_EQ(L"Yesterday", yesterday_str);
|
| + string16 yesterday_str = TimeFormat::RelativeDate(yesterday, NULL);
|
| + EXPECT_EQ(ASCIIToUTF16("Yesterday"), yesterday_str);
|
|
|
| Time two_days_ago = now - TimeDelta::FromDays(2);
|
| - std::wstring two_days_ago_str = TimeFormat::RelativeDate(two_days_ago, NULL);
|
| + string16 two_days_ago_str = TimeFormat::RelativeDate(two_days_ago, NULL);
|
| EXPECT_TRUE(two_days_ago_str.empty());
|
|
|
| Time a_week_ago = now - TimeDelta::FromDays(7);
|
| - std::wstring a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL);
|
| + string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL);
|
| EXPECT_TRUE(a_week_ago_str.empty());
|
| }
|
|
|
| namespace {
|
| -void TestTimeFormats(const TimeDelta delta, const std::wstring& expected) {
|
| - std::wstring expected_left = expected + L" left";
|
| - std::wstring expected_ago = expected + L" ago";
|
| +void TestTimeFormats(const TimeDelta delta, const char* expected_ascii) {
|
| + string16 expected = ASCIIToUTF16(expected_ascii);
|
| + string16 expected_left = expected + ASCIIToUTF16(" left");
|
| + string16 expected_ago = expected + ASCIIToUTF16(" ago");
|
| EXPECT_EQ(expected, TimeFormat::TimeRemainingShort(delta));
|
| EXPECT_EQ(expected_left, TimeFormat::TimeRemaining(delta));
|
| EXPECT_EQ(expected_ago, TimeFormat::TimeElapsed(delta));
|
| @@ -54,15 +57,15 @@ TEST(TimeFormat, FormatTime) {
|
|
|
| // TODO(jungshik) : These test only pass when the OS locale is 'en'.
|
| // We need to add SetUp() and TearDown() to set the locale to 'en'.
|
| - TestTimeFormats(twohundred_millisecs, L"0 secs");
|
| - TestTimeFormats(one_sec - twohundred_millisecs, L"0 secs");
|
| - TestTimeFormats(one_sec + twohundred_millisecs, L"1 sec");
|
| - TestTimeFormats(five_secs + twohundred_millisecs, L"5 secs");
|
| - TestTimeFormats(one_min + five_secs, L"1 min");
|
| - TestTimeFormats(three_mins + twohundred_millisecs, L"3 mins");
|
| - TestTimeFormats(one_hour + five_secs, L"1 hour");
|
| - TestTimeFormats(four_hours + five_secs, L"4 hours");
|
| - TestTimeFormats(one_day + five_secs, L"1 day");
|
| - TestTimeFormats(three_days, L"3 days");
|
| - TestTimeFormats(three_days + four_hours, L"3 days");
|
| + TestTimeFormats(twohundred_millisecs, "0 secs");
|
| + TestTimeFormats(one_sec - twohundred_millisecs, "0 secs");
|
| + TestTimeFormats(one_sec + twohundred_millisecs, "1 sec");
|
| + TestTimeFormats(five_secs + twohundred_millisecs, "5 secs");
|
| + TestTimeFormats(one_min + five_secs, "1 min");
|
| + TestTimeFormats(three_mins + twohundred_millisecs, "3 mins");
|
| + TestTimeFormats(one_hour + five_secs, "1 hour");
|
| + TestTimeFormats(four_hours + five_secs, "4 hours");
|
| + TestTimeFormats(one_day + five_secs, "1 day");
|
| + TestTimeFormats(three_days, "3 days");
|
| + TestTimeFormats(three_days + four_hours, "3 days");
|
| }
|
|
|