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

Unified Diff: base/i18n/time_formatting_unittest.cc

Issue 827123004: The Certificate Web UI incorrectly formats the issued and expires dates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Rebase on ToT Created 5 years, 10 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 | « base/i18n/time_formatting.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/time_formatting_unittest.cc
diff --git a/base/i18n/time_formatting_unittest.cc b/base/i18n/time_formatting_unittest.cc
index 0c2a6e6b852e950201937f8cb681d10f6fb0466d..04846c9ea3b563cbc4a120b44184d831974d5332 100644
--- a/base/i18n/time_formatting_unittest.cc
+++ b/base/i18n/time_formatting_unittest.cc
@@ -5,10 +5,13 @@
#include "base/i18n/time_formatting.h"
#include "base/i18n/rtl.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/icu/source/common/unicode/uversion.h"
+#include "third_party/icu/source/i18n/unicode/calendar.h"
+#include "third_party/icu/source/i18n/unicode/timezone.h"
namespace base {
namespace {
@@ -18,6 +21,19 @@ const Time::Exploded kTestDateTimeExploded = {
15, 42, 7, 0 // 15:42:07.000
};
+base::string16 GetShortTimeZone() {
+ scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
+ // This code shamelessly taken from
+ // src/chrome/browser/chromeos/system/timezone_util.cc.
+ int raw_offset, dst_offset;
+ UErrorCode status;
+ zone->getOffset(icu::Calendar::getNow(), false, raw_offset, dst_offset,
+ status);
+ icu::UnicodeString name;
+ zone->getDisplayName(true, icu::TimeZone::SHORT, name);
+ return base::string16(name.getBuffer(), name.length());
+}
+
TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) {
// Test for a locale defaulted to 12h clock.
// As an instance, we use third_party/icu/source/data/locales/en.txt.
@@ -129,6 +145,8 @@ TEST(TimeFormattingTest, TimeFormatDateUS) {
EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM"),
TimeFormatShortDateAndTime(time));
+ EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM ") + GetShortTimeZone(),
+ TimeFormatShortDateAndTimeWithTimeZone(time));
EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011 at 3:42:07 PM"),
TimeFormatFriendlyDateAndTime(time));
@@ -148,6 +166,8 @@ TEST(TimeFormattingTest, TimeFormatDateGB) {
EXPECT_EQ(ASCIIToUTF16("30/04/2011"), TimeFormatShortDateNumeric(time));
EXPECT_EQ(ASCIIToUTF16("30/04/2011 15:42:07"),
TimeFormatShortDateAndTime(time));
+ EXPECT_EQ(ASCIIToUTF16("30/04/2011 15:42:07 ") + GetShortTimeZone(),
+ TimeFormatShortDateAndTimeWithTimeZone(time));
EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 15:42:07"),
TimeFormatFriendlyDateAndTime(time));
EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"),
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698