WinCairo build fails to link.
[WebKit-https.git] / Source / WebKit / chromium / tests / LocaleWinTest.cpp
index 8e40ae4..bc98881 100644 (file)
@@ -90,19 +90,7 @@ protected:
         return locale->formatDateTime(dateComponents(year, month, day));
     }
 
-    double parseDate(LCID lcid, const String& dateString)
-    {
-        OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
-        return locale->parseDateTime(dateString, DateComponents::Date);
-    }
-
 #if ENABLE(CALENDAR_PICKER)
-    String dateFormatText(LCID lcid)
-    {
-        OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
-        return locale->dateFormatText();
-    }
-
     unsigned firstDayOfWeek(LCID lcid)
     {
         OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
@@ -147,6 +135,12 @@ protected:
         return locale->shortTimeFormat();
     }
 
+    String shortMonthLabel(LCID lcid, unsigned index)
+    {
+        OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
+        return locale->shortMonthLabels()[index];
+    }
+
     String timeAMPMLabel(LCID lcid, unsigned index)
     {
         OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
@@ -161,59 +155,6 @@ protected:
 #endif
 };
 
-TEST_F(LocaleWinTest, TestLocalizedDateFormatText)
-{
-    EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("y/M/d", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("yy/MM/dd", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("yyy/MMM/ddd", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("yyyy/MMMM/dddd", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("/month/day, year", LocaleWin::dateFormatText("/MM/dd, yyyy", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("month/day, year=year.", LocaleWin::dateFormatText("MM/dd, 'year='yyyy.", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("month-day 'year", LocaleWin::dateFormatText("MM-dd ''yyy", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("month-day aaa'bbb year", LocaleWin::dateFormatText("MM-dd 'aaa''bbb' yyy", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("year/month/day/year/month/day", LocaleWin::dateFormatText("yyyy/MMMM/dddd/yyyy/MMMM/dddd", "year", "month", "day").utf8().data());
-    EXPECT_STREQ("YY/mm/DD", LocaleWin::dateFormatText("YY/mm/DD", "year", "month", "day").utf8().data());
-}
-
-TEST_F(LocaleWinTest, TestParse)
-{
-    OwnPtr<LocaleWin> locale = LocaleWin::create(EnglishUS);
-
-    EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MM/dd/yy", 2012, "04/27/12"));
-    EXPECT_EQ(msForDate(2062, April, 27), locale->parseDate("MM/dd/yy", 2012, "04/27/62"));
-    EXPECT_EQ(msForDate(1963, April, 27), locale->parseDate("MM/dd/yy", 2012, "04/27/63"));
-    EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MM/dd/yy", 2012, "4/27/2012"));
-    EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MM/dd/yy", 2012, "Apr/27/2012"));
-    EXPECT_EQ(msForDate(2, April, 27), locale->parseDate("MM/d/yy", 2012, "April/27/2"));
-    EXPECT_EQ(msForDate(2, April, 27), locale->parseDate("MM/d/yy", 2012, "april/27/2"));
-    EXPECT_TRUE(isnan(locale->parseDate("MM/d/yy", 2012, "april/27")));
-    EXPECT_TRUE(isnan(locale->parseDate("MM/d/yy", 2012, "april/27/")));
-    EXPECT_TRUE(isnan(locale->parseDate("MM/d/yy", 2012, " april/27/")));
-
-    EXPECT_EQ(msForDate(12, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "04/7/12"));
-    EXPECT_EQ(msForDate(62, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "04/07/62"));
-    EXPECT_EQ(msForDate(63, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "04/07/63"));
-    EXPECT_EQ(msForDate(2012, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "4/7/2012"));
-    EXPECT_EQ(msForDate(2012, May, 7), locale->parseDate("MMM/d/yyyy", 2012, "May/007/2012"));
-    EXPECT_EQ(msForDate(2, May, 27), locale->parseDate("MM/d/yyyy", 2012, "May/0027/2"));
-    EXPECT_TRUE(isnan(locale->parseDate("MM/d/yyyy", 2012, "May///0027///2")));
-    EXPECT_TRUE(isnan(locale->parseDate("MM/d/yyyy", 2012, "Mayyyyyy/0027/2")));
-
-    EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MMMM/dd/y", 2012, "04/27/2"));
-    EXPECT_EQ(msForDate(2017, April, 27), locale->parseDate("MMMM/dd/y", 2012, "04/27/7"));
-    EXPECT_EQ(msForDate(2008, April, 27), locale->parseDate("MMMM/dd/y", 2012, "04/27/8"));
-    EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MMMM/dd/y", 2012, "4/27/2012"));
-    EXPECT_EQ(msForDate(2012, December, 27), locale->parseDate("MMMM/dd/y", 2012, "December/27/2012"));
-    EXPECT_EQ(msForDate(2012, November, 27), locale->parseDate("MMMM/d/y", 2012, "November/27/2"));
-    EXPECT_TRUE(isnan(locale->parseDate("MMMM/d/y", 2012, "November 27 2")));
-    EXPECT_TRUE(isnan(locale->parseDate("MMMM/d/y", 2012, "November 32 2")));
-    EXPECT_TRUE(isnan(locale->parseDate("MMMM/d/y", 2012, "-1/-1/-1")));
-
-    OwnPtr<LocaleWin> persian = LocaleWin::create(Persian);
-    // U+06F1 U+06F6 / U+06F0 U+06F8 / 2012
-    EXPECT_EQ(msForDate(2012, August, 16), persian->parseDate("dd/MM/yyyy", 2012, String::fromUTF8("\xDB\xB1\xDB\xB6/\xDB\xB0\xDB\xB8/2012")));
-}
-
 TEST_F(LocaleWinTest, formatDate)
 {
     EXPECT_STREQ("04/27/2005", formatDate(EnglishUS, 2005, April, 27).utf8().data());
@@ -221,21 +162,7 @@ TEST_F(LocaleWinTest, formatDate)
     EXPECT_STREQ("2005/04/27", formatDate(JapaneseJP, 2005, April, 27).utf8().data());
 }
 
-TEST_F(LocaleWinTest, parseDate)
-{
-    EXPECT_EQ(msForDate(2005, April, 27), parseDate(EnglishUS, "April/27/2005"));
-    EXPECT_EQ(msForDate(2005, April, 27), parseDate(FrenchFR, "27/avril/2005"));
-    EXPECT_EQ(msForDate(2005, April, 27), parseDate(JapaneseJP, "2005/04/27"));
-}
-
 #if ENABLE(CALENDAR_PICKER)
-TEST_F(LocaleWinTest, dateFormatText)
-{
-    EXPECT_STREQ("Month/Day/Year", dateFormatText(EnglishUS).utf8().data());
-    EXPECT_STREQ("Day/Month/Year", dateFormatText(FrenchFR).utf8().data());
-    EXPECT_STREQ("Year/Month/Day", dateFormatText(JapaneseJP).utf8().data());
-}
-
 TEST_F(LocaleWinTest, firstDayOfWeek)
 {
     EXPECT_EQ(Sunday, firstDayOfWeek(EnglishUS));
@@ -284,17 +211,17 @@ TEST_F(LocaleWinTest, isRTL)
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
 TEST_F(LocaleWinTest, dateFormat)
 {
-    EXPECT_STREQ("y'-'M'-'d", LocaleWin::dateFormat("y-M-d").utf8().data());
+    EXPECT_STREQ("y-M-d", LocaleWin::dateFormat("y-M-d").utf8().data());
     EXPECT_STREQ("''yy'-'''MM'''-'dd", LocaleWin::dateFormat("''yy-''MM''-dd").utf8().data());
     EXPECT_STREQ("yyyy'-''''-'MMM'''''-'dd", LocaleWin::dateFormat("yyyy-''''-MMM''''-dd").utf8().data());
-    EXPECT_STREQ("yyyy'-'''''MMMM'-'dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data());
+    EXPECT_STREQ("yyyy'-'''''MMMM-dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data());
 }
 
 TEST_F(LocaleWinTest, monthFormat)
 {
-    EXPECT_STREQ("MMMM', 'yyyy", monthFormat(EnglishUS).utf8().data());
-    EXPECT_STREQ("MMMM' 'yyyy", monthFormat(FrenchFR).utf8().data());
-    EXPECT_STREQ("yyyy'\xE5\xB9\xB4'M'\xE6\x9C\x88'", monthFormat(JapaneseJP).utf8().data());
+    EXPECT_STREQ("MMMMyyyy", monthFormat(EnglishUS).utf8().data());
+    EXPECT_STREQ("MMMM yyyy", monthFormat(FrenchFR).utf8().data());
+    EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat(JapaneseJP).utf8().data());
 }
 
 TEST_F(LocaleWinTest, timeFormat)
@@ -306,9 +233,19 @@ TEST_F(LocaleWinTest, timeFormat)
 
 TEST_F(LocaleWinTest, shortTimeFormat)
 {
-    EXPECT_STREQ("h:mm:ss a", shortTimeFormat(EnglishUS).utf8().data());
-    EXPECT_STREQ("HH:mm:ss", shortTimeFormat(FrenchFR).utf8().data());
-    EXPECT_STREQ("H:mm:ss", shortTimeFormat(JapaneseJP).utf8().data());
+    EXPECT_STREQ("h:mm a", shortTimeFormat(EnglishUS).utf8().data());
+    EXPECT_STREQ("HH:mm", shortTimeFormat(FrenchFR).utf8().data());
+    EXPECT_STREQ("H:mm", shortTimeFormat(JapaneseJP).utf8().data());
+}
+
+TEST_F(LocaleWinTest, shortMonthLabels)
+{
+    EXPECT_STREQ("Jan", shortMonthLabel(EnglishUS, 0).utf8().data());
+    EXPECT_STREQ("Dec", shortMonthLabel(EnglishUS, 11).utf8().data());
+    EXPECT_STREQ("janv.", shortMonthLabel(FrenchFR, 0).utf8().data());
+    EXPECT_STREQ("d\xC3\xA9" "c.", shortMonthLabel(FrenchFR, 11).utf8().data());
+    EXPECT_STREQ("1", shortMonthLabel(JapaneseJP, 0).utf8().data());
+    EXPECT_STREQ("12", shortMonthLabel(JapaneseJP, 11).utf8().data());
 }
 
 TEST_F(LocaleWinTest, timeAMPMLabels)