| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 92 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 93 return locale->formatDateTime(dateComponents(year, month, day)); | 93 return locale->formatDateTime(dateComponents(year, month, day)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 String formatTime(const String& localeString, int hour, int minute, int seco
nd, int millisecond, bool useShortFormat) | 96 String formatTime(const String& localeString, int hour, int minute, int seco
nd, int millisecond, bool useShortFormat) |
| 97 { | 97 { |
| 98 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 98 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 99 return locale->formatDateTime(timeComponents(hour, minute, second, milli
second), (useShortFormat ? Locale::FormatTypeShort : Locale::FormatTypeMedium)); | 99 return locale->formatDateTime(timeComponents(hour, minute, second, milli
second), (useShortFormat ? Locale::FormatTypeShort : Locale::FormatTypeMedium)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 #if ENABLE(CALENDAR_PICKER) | |
| 103 unsigned firstDayOfWeek(const String& localeString) | 102 unsigned firstDayOfWeek(const String& localeString) |
| 104 { | 103 { |
| 105 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 104 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 106 return locale->firstDayOfWeek(); | 105 return locale->firstDayOfWeek(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 String monthLabel(const String& localeString, unsigned index) | 108 String monthLabel(const String& localeString, unsigned index) |
| 110 { | 109 { |
| 111 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 110 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 112 return locale->monthLabels()[index]; | 111 return locale->monthLabels()[index]; |
| 113 } | 112 } |
| 114 | 113 |
| 115 String weekDayShortLabel(const String& localeString, unsigned index) | 114 String weekDayShortLabel(const String& localeString, unsigned index) |
| 116 { | 115 { |
| 117 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 116 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 118 return locale->weekDayShortLabels()[index]; | 117 return locale->weekDayShortLabels()[index]; |
| 119 } | 118 } |
| 120 | 119 |
| 121 bool isRTL(const String& localeString) | 120 bool isRTL(const String& localeString) |
| 122 { | 121 { |
| 123 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 122 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 124 return locale->isRTL(); | 123 return locale->isRTL(); |
| 125 } | 124 } |
| 126 #endif | |
| 127 | 125 |
| 128 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 126 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 129 String monthFormat(const String& localeString) | 127 String monthFormat(const String& localeString) |
| 130 { | 128 { |
| 131 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); | 129 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); |
| 132 return locale->monthFormat(); | 130 return locale->monthFormat(); |
| 133 } | 131 } |
| 134 | 132 |
| 135 String timeFormat(const String& localeString) | 133 String timeFormat(const String& localeString) |
| 136 { | 134 { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 EXPECT_STREQ("\xD9\xA1\xD9\xA2:\xD9\xA0\xD9\xA0 \xD8\xB5", formatTime("ar",
00, 00, 00, 000, true).utf8().data()); | 212 EXPECT_STREQ("\xD9\xA1\xD9\xA2:\xD9\xA0\xD9\xA0 \xD8\xB5", formatTime("ar",
00, 00, 00, 000, true).utf8().data()); |
| 215 EXPECT_STREQ("\xDB\xB0:\xDB\xB0\xDB\xB0", formatTime("fa", 00, 00, 00, 000,
true).utf8().data()); | 213 EXPECT_STREQ("\xDB\xB0:\xDB\xB0\xDB\xB0", formatTime("fa", 00, 00, 00, 000,
true).utf8().data()); |
| 216 | 214 |
| 217 EXPECT_STREQ("7:07:07.007 AM", formatTime("en_US", 07, 07, 07, 007, false).u
tf8().data()); | 215 EXPECT_STREQ("7:07:07.007 AM", formatTime("en_US", 07, 07, 07, 007, false).u
tf8().data()); |
| 218 EXPECT_STREQ("07:07:07,007", formatTime("fr_FR", 07, 07, 07, 007, false).utf
8().data()); | 216 EXPECT_STREQ("07:07:07,007", formatTime("fr_FR", 07, 07, 07, 007, false).utf
8().data()); |
| 219 EXPECT_STREQ("7:07:07.007", formatTime("ja_JP", 07, 07, 07, 007, false).utf8
().data()); | 217 EXPECT_STREQ("7:07:07.007", formatTime("ja_JP", 07, 07, 07, 007, false).utf8
().data()); |
| 220 EXPECT_STREQ("\xD9\xA7:\xD9\xA0\xD9\xA7:\xD9\xA0\xD9\xA7\xD9\xAB\xD9\xA0\xD9
\xA0\xD9\xA7 \xD8\xB5", formatTime("ar", 07, 07, 07, 007, false).utf8().data()); | 218 EXPECT_STREQ("\xD9\xA7:\xD9\xA0\xD9\xA7:\xD9\xA0\xD9\xA7\xD9\xAB\xD9\xA0\xD9
\xA0\xD9\xA7 \xD8\xB5", formatTime("ar", 07, 07, 07, 007, false).utf8().data()); |
| 221 EXPECT_STREQ("\xDB\xB7:\xDB\xB0\xDB\xB7:\xDB\xB0\xDB\xB7\xD9\xAB\xDB\xB0\xDB
\xB0\xDB\xB7", formatTime("fa", 07, 07, 07, 007, false).utf8().data()); | 219 EXPECT_STREQ("\xDB\xB7:\xDB\xB0\xDB\xB7:\xDB\xB0\xDB\xB7\xD9\xAB\xDB\xB0\xDB
\xB0\xDB\xB7", formatTime("fa", 07, 07, 07, 007, false).utf8().data()); |
| 222 } | 220 } |
| 223 | 221 |
| 224 #if ENABLE(CALENDAR_PICKER) | |
| 225 TEST_F(LocaleMacTest, firstDayOfWeek) | 222 TEST_F(LocaleMacTest, firstDayOfWeek) |
| 226 { | 223 { |
| 227 EXPECT_EQ(Sunday, firstDayOfWeek("en_US")); | 224 EXPECT_EQ(Sunday, firstDayOfWeek("en_US")); |
| 228 EXPECT_EQ(Monday, firstDayOfWeek("fr_FR")); | 225 EXPECT_EQ(Monday, firstDayOfWeek("fr_FR")); |
| 229 EXPECT_EQ(Sunday, firstDayOfWeek("ja_JP")); | 226 EXPECT_EQ(Sunday, firstDayOfWeek("ja_JP")); |
| 230 } | 227 } |
| 231 | 228 |
| 232 TEST_F(LocaleMacTest, monthLabels) | 229 TEST_F(LocaleMacTest, monthLabels) |
| 233 { | 230 { |
| 234 EXPECT_STREQ("January", monthLabel("en_US", January).utf8().data()); | 231 EXPECT_STREQ("January", monthLabel("en_US", January).utf8().data()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 259 EXPECT_STREQ("\xE5\x9C\x9F", weekDayShortLabel("ja_JP", Saturday).utf8().dat
a()); | 256 EXPECT_STREQ("\xE5\x9C\x9F", weekDayShortLabel("ja_JP", Saturday).utf8().dat
a()); |
| 260 } | 257 } |
| 261 | 258 |
| 262 TEST_F(LocaleMacTest, isRTL) | 259 TEST_F(LocaleMacTest, isRTL) |
| 263 { | 260 { |
| 264 EXPECT_TRUE(isRTL("ar-eg")); | 261 EXPECT_TRUE(isRTL("ar-eg")); |
| 265 EXPECT_FALSE(isRTL("en-us")); | 262 EXPECT_FALSE(isRTL("en-us")); |
| 266 EXPECT_FALSE(isRTL("ja-jp")); | 263 EXPECT_FALSE(isRTL("ja-jp")); |
| 267 EXPECT_FALSE(isRTL("**invalid**")); | 264 EXPECT_FALSE(isRTL("**invalid**")); |
| 268 } | 265 } |
| 269 #endif | |
| 270 | 266 |
| 271 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 267 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 272 TEST_F(LocaleMacTest, monthFormat) | 268 TEST_F(LocaleMacTest, monthFormat) |
| 273 { | 269 { |
| 274 EXPECT_STREQ("MMMM yyyy", monthFormat("en_US").utf8().data()); | 270 EXPECT_STREQ("MMMM yyyy", monthFormat("en_US").utf8().data()); |
| 275 EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat("ja_JP").utf8().da
ta()); | 271 EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat("ja_JP").utf8().da
ta()); |
| 276 | 272 |
| 277 // fr_FR and ru return different results on OS versions. | 273 // fr_FR and ru return different results on OS versions. |
| 278 // "MMM yyyy" "LLL yyyy" on 10.6 and 10.7 | 274 // "MMM yyyy" "LLL yyyy" on 10.6 and 10.7 |
| 279 // "MMM y" "LLL y" on 10.8 | 275 // "MMM y" "LLL y" on 10.8 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 testNumbers("ar"); | 379 testNumbers("ar"); |
| 384 testNumbers("de_DE"); | 380 testNumbers("de_DE"); |
| 385 testNumbers("es_ES"); | 381 testNumbers("es_ES"); |
| 386 testNumbers("fa"); | 382 testNumbers("fa"); |
| 387 testNumbers("ja_JP"); | 383 testNumbers("ja_JP"); |
| 388 testNumbers("ko_KR"); | 384 testNumbers("ko_KR"); |
| 389 testNumbers("zh_CN"); | 385 testNumbers("zh_CN"); |
| 390 testNumbers("zh_HK"); | 386 testNumbers("zh_HK"); |
| 391 testNumbers("zh_TW"); | 387 testNumbers("zh_TW"); |
| 392 } | 388 } |
| OLD | NEW |