| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 protected: | 81 protected: |
| 82 Labels labelsFromTwoElements(const String& element1, const String& element2) | 82 Labels labelsFromTwoElements(const String& element1, const String& element2) |
| 83 { | 83 { |
| 84 Vector<String> labels = Vector<String>(); | 84 Vector<String> labels = Vector<String>(); |
| 85 labels.append(element1); | 85 labels.append(element1); |
| 86 labels.append(element2); | 86 labels.append(element2); |
| 87 return Labels(labels); | 87 return Labels(labels); |
| 88 } | 88 } |
| 89 | 89 |
| 90 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | |
| 91 String monthFormat(const char* localeString) | 90 String monthFormat(const char* localeString) |
| 92 { | 91 { |
| 93 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); | 92 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); |
| 94 return locale->monthFormat(); | 93 return locale->monthFormat(); |
| 95 } | 94 } |
| 96 | 95 |
| 97 String localizedDateFormatText(const char* localeString) | 96 String localizedDateFormatText(const char* localeString) |
| 98 { | 97 { |
| 99 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); | 98 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); |
| 100 return locale->timeFormat(); | 99 return locale->timeFormat(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 128 { | 127 { |
| 129 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); | 128 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); |
| 130 return Labels(locale->timeAMPMLabels()); | 129 return Labels(locale->timeAMPMLabels()); |
| 131 } | 130 } |
| 132 | 131 |
| 133 bool isRTL(const char* localeString) | 132 bool isRTL(const char* localeString) |
| 134 { | 133 { |
| 135 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); | 134 OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); |
| 136 return locale->isRTL(); | 135 return locale->isRTL(); |
| 137 } | 136 } |
| 138 #endif | |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 std::ostream& operator<<(std::ostream& os, const LocaleICUTest::Labels& labels) | 139 std::ostream& operator<<(std::ostream& os, const LocaleICUTest::Labels& labels) |
| 142 { | 140 { |
| 143 return os << labels.toString().utf8().data(); | 141 return os << labels.toString().utf8().data(); |
| 144 } | 142 } |
| 145 | 143 |
| 146 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | |
| 147 TEST_F(LocaleICUTest, isRTL) | 144 TEST_F(LocaleICUTest, isRTL) |
| 148 { | 145 { |
| 149 EXPECT_TRUE(isRTL("ar-EG")); | 146 EXPECT_TRUE(isRTL("ar-EG")); |
| 150 EXPECT_FALSE(isRTL("en-us")); | 147 EXPECT_FALSE(isRTL("en-us")); |
| 151 EXPECT_FALSE(isRTL("ja-jp")); | 148 EXPECT_FALSE(isRTL("ja-jp")); |
| 152 EXPECT_FALSE(isRTL("**invalid**")); | 149 EXPECT_FALSE(isRTL("**invalid**")); |
| 153 } | 150 } |
| 154 | 151 |
| 155 TEST_F(LocaleICUTest, monthFormat) | 152 TEST_F(LocaleICUTest, monthFormat) |
| 156 { | 153 { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 { | 239 { |
| 243 OwnPtr<Locale> locale = Locale::create(localeIdentifier); | 240 OwnPtr<Locale> locale = Locale::create(localeIdentifier); |
| 244 return locale->localizedDecimalSeparator(); | 241 return locale->localizedDecimalSeparator(); |
| 245 } | 242 } |
| 246 | 243 |
| 247 TEST_F(LocaleICUTest, localizedDecimalSeparator) | 244 TEST_F(LocaleICUTest, localizedDecimalSeparator) |
| 248 { | 245 { |
| 249 EXPECT_EQ(String("."), testDecimalSeparator("en_US")); | 246 EXPECT_EQ(String("."), testDecimalSeparator("en_US")); |
| 250 EXPECT_EQ(String(","), testDecimalSeparator("fr")); | 247 EXPECT_EQ(String(","), testDecimalSeparator("fr")); |
| 251 } | 248 } |
| 252 #endif | |
| 253 | 249 |
| 254 void testNumberIsReversible(const AtomicString& localeIdentifier, const char* or
iginal, const char* shouldHave = 0) | 250 void testNumberIsReversible(const AtomicString& localeIdentifier, const char* or
iginal, const char* shouldHave = 0) |
| 255 { | 251 { |
| 256 OwnPtr<Locale> locale = Locale::create(localeIdentifier); | 252 OwnPtr<Locale> locale = Locale::create(localeIdentifier); |
| 257 String localized = locale->convertToLocalizedNumber(original); | 253 String localized = locale->convertToLocalizedNumber(original); |
| 258 if (shouldHave) | 254 if (shouldHave) |
| 259 EXPECT_TRUE(localized.contains(shouldHave)); | 255 EXPECT_TRUE(localized.contains(shouldHave)); |
| 260 String converted = locale->convertFromLocalizedNumber(localized); | 256 String converted = locale->convertFromLocalizedNumber(localized); |
| 261 EXPECT_EQ(original, converted); | 257 EXPECT_EQ(original, converted); |
| 262 } | 258 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 289 testNumbers("de_DE"); | 285 testNumbers("de_DE"); |
| 290 testNumbers("es_ES"); | 286 testNumbers("es_ES"); |
| 291 testNumbers("ja_JP"); | 287 testNumbers("ja_JP"); |
| 292 testNumbers("ko_KR"); | 288 testNumbers("ko_KR"); |
| 293 testNumbers("zh_CN"); | 289 testNumbers("zh_CN"); |
| 294 testNumbers("zh_HK"); | 290 testNumbers("zh_HK"); |
| 295 testNumbers("zh_TW"); | 291 testNumbers("zh_TW"); |
| 296 } | 292 } |
| 297 | 293 |
| 298 } // namespace blink | 294 } // namespace blink |
| OLD | NEW |