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

Unified Diff: base/i18n/time_formatting_unittest.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 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 | « base/i18n/time_formatting.cc ('k') | base/i18n/timezone.h » ('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
deleted file mode 100644
index 93856280d9a94dc24e8188320360c6a8874b0ec8..0000000000000000000000000000000000000000
--- a/base/i18n/time_formatting_unittest.cc
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright (c) 2011 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 "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"
-#include "third_party/icu/source/i18n/unicode/tzfmt.h"
-
-namespace base {
-namespace {
-
-const Time::Exploded kTestDateTimeExploded = {
- 2011, 4, 6, 30, // Sat, Apr 30, 2011
- 15, 42, 7, 0 // 15:42:07.000
-};
-
-// Returns difference between the local time and GMT formatted as string.
-// This function gets |time| because the difference depends on time,
-// see https://en.wikipedia.org/wiki/Daylight_saving_time for details.
-base::string16 GetShortTimeZone(const Time& time) {
- UErrorCode status = U_ZERO_ERROR;
- scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
- scoped_ptr<icu::TimeZoneFormat> zone_formatter(
- icu::TimeZoneFormat::createInstance(icu::Locale::getDefault(), status));
- EXPECT_TRUE(U_SUCCESS(status));
- icu::UnicodeString name;
- zone_formatter->format(UTZFMT_STYLE_SPECIFIC_SHORT, *zone,
- static_cast<UDate>(time.ToDoubleT() * 1000), name,
- nullptr);
- 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.
- i18n::SetICUDefaultLocale("en_US");
-
- Time time(Time::FromLocalExploded(kTestDateTimeExploded));
- string16 clock24h(ASCIIToUTF16("15:42"));
- string16 clock12h_pm(ASCIIToUTF16("3:42 PM"));
- string16 clock12h(ASCIIToUTF16("3:42"));
- string16 clock24h_millis(ASCIIToUTF16("15:42:07.000"));
-
- // The default is 12h clock.
- EXPECT_EQ(clock12h_pm, TimeFormatTimeOfDay(time));
- EXPECT_EQ(clock24h_millis, TimeFormatTimeOfDayWithMilliseconds(time));
- EXPECT_EQ(k12HourClock, GetHourClockType());
- // k{Keep,Drop}AmPm should not affect for 24h clock.
- EXPECT_EQ(clock24h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k24HourClock,
- kKeepAmPm));
- EXPECT_EQ(clock24h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k24HourClock,
- kDropAmPm));
- // k{Keep,Drop}AmPm affects for 12h clock.
- EXPECT_EQ(clock12h_pm,
- TimeFormatTimeOfDayWithHourClockType(time,
- k12HourClock,
- kKeepAmPm));
- EXPECT_EQ(clock12h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k12HourClock,
- kDropAmPm));
-}
-
-TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault24h) {
- // Test for a locale defaulted to 24h clock.
- // As an instance, we use third_party/icu/source/data/locales/en_GB.txt.
- i18n::SetICUDefaultLocale("en_GB");
-
- Time time(Time::FromLocalExploded(kTestDateTimeExploded));
- string16 clock24h(ASCIIToUTF16("15:42"));
- string16 clock12h_pm(ASCIIToUTF16("3:42 pm"));
- string16 clock12h(ASCIIToUTF16("3:42"));
- string16 clock24h_millis(ASCIIToUTF16("15:42:07.000"));
-
- // The default is 24h clock.
- EXPECT_EQ(clock24h, TimeFormatTimeOfDay(time));
- EXPECT_EQ(clock24h_millis, TimeFormatTimeOfDayWithMilliseconds(time));
- EXPECT_EQ(k24HourClock, GetHourClockType());
- // k{Keep,Drop}AmPm should not affect for 24h clock.
- EXPECT_EQ(clock24h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k24HourClock,
- kKeepAmPm));
- EXPECT_EQ(clock24h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k24HourClock,
- kDropAmPm));
- // k{Keep,Drop}AmPm affects for 12h clock.
- EXPECT_EQ(clock12h_pm,
- TimeFormatTimeOfDayWithHourClockType(time,
- k12HourClock,
- kKeepAmPm));
- EXPECT_EQ(clock12h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k12HourClock,
- kDropAmPm));
-}
-
-TEST(TimeFormattingTest, TimeFormatTimeOfDayJP) {
- // Test for a locale that uses different mark than "AM" and "PM".
- // As an instance, we use third_party/icu/source/data/locales/ja.txt.
- i18n::SetICUDefaultLocale("ja_JP");
-
- Time time(Time::FromLocalExploded(kTestDateTimeExploded));
- string16 clock24h(ASCIIToUTF16("15:42"));
- string16 clock12h_pm(WideToUTF16(L"\x5348\x5f8c" L"3:42"));
- string16 clock12h(ASCIIToUTF16("3:42"));
-
- // The default is 24h clock.
- EXPECT_EQ(clock24h, TimeFormatTimeOfDay(time));
- EXPECT_EQ(k24HourClock, GetHourClockType());
- // k{Keep,Drop}AmPm should not affect for 24h clock.
- EXPECT_EQ(clock24h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k24HourClock,
- kKeepAmPm));
- EXPECT_EQ(clock24h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k24HourClock,
- kDropAmPm));
- // k{Keep,Drop}AmPm affects for 12h clock.
- EXPECT_EQ(clock12h_pm,
- TimeFormatTimeOfDayWithHourClockType(time,
- k12HourClock,
- kKeepAmPm));
- EXPECT_EQ(clock12h,
- TimeFormatTimeOfDayWithHourClockType(time,
- k12HourClock,
- kDropAmPm));
-}
-
-TEST(TimeFormattingTest, TimeFormatDateUS) {
- // See third_party/icu/source/data/locales/en.txt.
- // The date patterns are "EEEE, MMMM d, y", "MMM d, y", and "M/d/yy".
- i18n::SetICUDefaultLocale("en_US");
-
- Time time(Time::FromLocalExploded(kTestDateTimeExploded));
-
- EXPECT_EQ(ASCIIToUTF16("Apr 30, 2011"), TimeFormatShortDate(time));
- EXPECT_EQ(ASCIIToUTF16("4/30/11"), TimeFormatShortDateNumeric(time));
-
- EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM"),
- TimeFormatShortDateAndTime(time));
- EXPECT_EQ(ASCIIToUTF16("4/30/11, 3:42:07 PM ") + GetShortTimeZone(time),
- TimeFormatShortDateAndTimeWithTimeZone(time));
-
- EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011 at 3:42:07 PM"),
- TimeFormatFriendlyDateAndTime(time));
-
- EXPECT_EQ(ASCIIToUTF16("Saturday, April 30, 2011"),
- TimeFormatFriendlyDate(time));
-}
-
-TEST(TimeFormattingTest, TimeFormatDateGB) {
- // See third_party/icu/source/data/locales/en_GB.txt.
- // The date patterns are "EEEE, d MMMM y", "d MMM y", and "dd/MM/yyyy".
- i18n::SetICUDefaultLocale("en_GB");
-
- Time time(Time::FromLocalExploded(kTestDateTimeExploded));
-
- EXPECT_EQ(ASCIIToUTF16("30 Apr 2011"), TimeFormatShortDate(time));
- 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(time),
- TimeFormatShortDateAndTimeWithTimeZone(time));
- EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"),
- TimeFormatFriendlyDateAndTime(time));
- EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"),
- TimeFormatFriendlyDate(time));
-}
-
-} // namespace
-} // namespace base
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | base/i18n/timezone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698