Index: base/i18n/time_formatting_unittest.cc |
diff --git a/base/i18n/time_formatting_unittest.cc b/base/i18n/time_formatting_unittest.cc |
index 9f152c0b2d90e88796be753c0a7a05008a08118c..64bc6636a13ad48f1d9c7aaabf7112c6e9543de9 100644 |
--- a/base/i18n/time_formatting_unittest.cc |
+++ b/base/i18n/time_formatting_unittest.cc |
@@ -17,6 +17,21 @@ |
namespace base { |
namespace { |
+class ScopedSetICUDefaultLocale { |
+ std::string default_locale; |
+ |
+ public: |
+ ScopedSetICUDefaultLocale(std::string locale); |
+ ~ScopedSetICUDefaultLocale(); |
+}; |
+ |
+ScopedSetICUDefaultLocale::ScopedSetICUDefaultLocale(std::string locale) |
+ : default_locale(locale) {} |
+ |
+ScopedSetICUDefaultLocale::~ScopedSetICUDefaultLocale() { |
+ i18n::SetICUDefaultLocale(default_locale.data()); |
+} |
+ |
const Time::Exploded kTestDateTimeExploded = { |
2011, 4, 6, 30, // Sat, Apr 30, 2011 |
15, 42, 7, 0 // 15:42:07.000 |
@@ -41,6 +56,7 @@ base::string16 GetShortTimeZone(const Time& time) { |
TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) { |
// Test for a locale defaulted to 12h clock. |
// As an instance, we use third_party/icu/source/data/locales/en.txt. |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("en_US"); |
Time time(Time::FromLocalExploded(kTestDateTimeExploded)); |
@@ -76,6 +92,7 @@ TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) { |
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. |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("en_GB"); |
Time time(Time::FromLocalExploded(kTestDateTimeExploded)); |
@@ -111,6 +128,7 @@ TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault24h) { |
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. |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("ja_JP"); |
Time time(Time::FromLocalExploded(kTestDateTimeExploded)); |
@@ -144,6 +162,7 @@ TEST(TimeFormattingTest, TimeFormatTimeOfDayJP) { |
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". |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("en_US"); |
Time time(Time::FromLocalExploded(kTestDateTimeExploded)); |
@@ -166,6 +185,7 @@ TEST(TimeFormattingTest, TimeFormatDateUS) { |
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". |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("en_GB"); |
Time time(Time::FromLocalExploded(kTestDateTimeExploded)); |