Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7028838e authored by Victor Chang's avatar Victor Chang
Browse files

Update android.text.format tests and regenerate LocaleDataTables.cpp due to ICU 72 upgrade

The command:
./tools/localedata/extract_icu_data.py $ANDROID_BUILD_TOP > libs/androidfw/LocaleDataTables.cpp

Bug: 239910154
Test: atest FrameworksCoreTests:android.text.format
Change-Id: I28d816021056d0c7b39789f830663a7da6fcbe70
parent 9e7649d5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -156,8 +156,8 @@ public class DateFormatTest {
    @DisableCompatChanges({DateFormat.DISALLOW_DUPLICATE_FIELD_IN_SKELETON})
    public void testGetBestDateTimePattern_enableDuplicateField() {
        // en-US uses 12-hour format by default.
        assertEquals("h:mm a", DateFormat.getBestDateTimePattern(Locale.US, "jmma"));
        assertEquals("h:mm a", DateFormat.getBestDateTimePattern(Locale.US, "ahmma"));
        assertEquals("h:mm\u202fa", DateFormat.getBestDateTimePattern(Locale.US, "jmma"));
        assertEquals("h:mm\u202fa", DateFormat.getBestDateTimePattern(Locale.US, "ahmma"));
    }

    private static void assertIllegalArgumentException(Locale l, String skeleton) {
+108 −93

File changed.

Preview size limit exceeded, changes collapsed.

+5 −5
Original line number Diff line number Diff line
@@ -139,16 +139,16 @@ public class DateUtilsTest {
                fixedTime, java.text.DateFormat.SHORT, java.text.DateFormat.FULL));

        final long hourDuration = 2 * 60 * 60 * 1000;
        assertEquals("5:30:15 AM Greenwich Mean Time", DateUtils.formatSameDayTime(
        assertEquals("5:30:15\u202fAM Greenwich Mean Time", DateUtils.formatSameDayTime(
                fixedTime + hourDuration, fixedTime, java.text.DateFormat.FULL,
                java.text.DateFormat.FULL));
        assertEquals("5:30:15 AM", DateUtils.formatSameDayTime(fixedTime + hourDuration,
        assertEquals("5:30:15\u202fAM", DateUtils.formatSameDayTime(fixedTime + hourDuration,
                fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.DEFAULT));
        assertEquals("5:30:15 AM GMT", DateUtils.formatSameDayTime(fixedTime + hourDuration,
        assertEquals("5:30:15\u202fAM GMT", DateUtils.formatSameDayTime(fixedTime + hourDuration,
                fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.LONG));
        assertEquals("5:30:15 AM", DateUtils.formatSameDayTime(fixedTime + hourDuration,
        assertEquals("5:30:15\u202fAM", DateUtils.formatSameDayTime(fixedTime + hourDuration,
                fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.MEDIUM));
        assertEquals("5:30 AM", DateUtils.formatSameDayTime(fixedTime + hourDuration,
        assertEquals("5:30\u202fAM", DateUtils.formatSameDayTime(fixedTime + hourDuration,
                fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.SHORT));
    }

+30 −30
Original line number Diff line number Diff line
@@ -468,37 +468,37 @@ public class RelativeDateTimeFormatterTest {
        cal.set(2015, Calendar.FEBRUARY, 5, 10, 50, 0);
        final long base = cal.getTimeInMillis();

        assertEquals("5 seconds ago, 10:49 AM",
        assertEquals("5 seconds ago, 10:49\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 5 * SECOND_IN_MILLIS, base, 0,
                        MINUTE_IN_MILLIS, 0));
        assertEquals("5 min. ago, 10:45 AM",
        assertEquals("5 min. ago, 10:45\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 5 * MINUTE_IN_MILLIS, base, 0,
                        HOUR_IN_MILLIS, FORMAT_ABBREV_RELATIVE));
        assertEquals("0 hr. ago, 10:45 AM",
        assertEquals("0 hr. ago, 10:45\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 5 * MINUTE_IN_MILLIS, base,
                        HOUR_IN_MILLIS, DAY_IN_MILLIS, FORMAT_ABBREV_RELATIVE));
        assertEquals("5 hours ago, 5:50 AM",
        assertEquals("5 hours ago, 5:50\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 5 * HOUR_IN_MILLIS, base,
                        HOUR_IN_MILLIS, DAY_IN_MILLIS, 0));
        assertEquals("Yesterday, 7:50 PM",
        assertEquals("Yesterday, 7:50\u202fPM",
                getRelativeDateTimeString(en_US, tz, base - 15 * HOUR_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, FORMAT_ABBREV_RELATIVE));
        assertEquals("5 days ago, 10:50 AM",
        assertEquals("5 days ago, 10:50\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 5 * DAY_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));
        assertEquals("Jan 29, 10:50 AM",
        assertEquals("Jan 29, 10:50\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 7 * DAY_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));
        assertEquals("11/27/2014, 10:50 AM",
        assertEquals("11/27/2014, 10:50\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 10 * WEEK_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));
        assertEquals("11/27/2014, 10:50 AM",
        assertEquals("11/27/2014, 10:50\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 10 * WEEK_IN_MILLIS, base, 0,
                        YEAR_IN_MILLIS, 0));

        // User-supplied flags should be ignored when formatting the date clause.
        final int FORMAT_SHOW_WEEKDAY = 0x00002;
        assertEquals("11/27/2014, 10:50 AM",
        assertEquals("11/27/2014, 10:50\u202fAM",
                getRelativeDateTimeString(en_US, tz, base - 10 * WEEK_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS,
                        FORMAT_ABBREV_ALL | FORMAT_SHOW_WEEKDAY));
@@ -514,14 +514,14 @@ public class RelativeDateTimeFormatterTest {
        // So 5 hours before 3:15 AM should be formatted as 'Yesterday, 9:15 PM'.
        cal.set(2014, Calendar.MARCH, 9, 3, 15, 0);
        long base = cal.getTimeInMillis();
        assertEquals("Yesterday, 9:15 PM",
        assertEquals("Yesterday, 9:15\u202fPM",
                getRelativeDateTimeString(en_US, tz, base - 5 * HOUR_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));

        // 1 hour after 2:00 AM should be formatted as 'In 1 hour, 4:00 AM'.
        cal.set(2014, Calendar.MARCH, 9, 2, 0, 0);
        base = cal.getTimeInMillis();
        assertEquals("In 1 hour, 4:00 AM",
        assertEquals("In 1 hour, 4:00\u202fAM",
                getRelativeDateTimeString(en_US, tz, base + 1 * HOUR_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));

@@ -529,22 +529,22 @@ public class RelativeDateTimeFormatterTest {
        // 1:00 AM. 8 hours before 5:20 AM should be 'Yesterday, 10:20 PM'.
        cal.set(2014, Calendar.NOVEMBER, 2, 5, 20, 0);
        base = cal.getTimeInMillis();
        assertEquals("Yesterday, 10:20 PM",
        assertEquals("Yesterday, 10:20\u202fPM",
                getRelativeDateTimeString(en_US, tz, base - 8 * HOUR_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));

        cal.set(2014, Calendar.NOVEMBER, 2, 0, 45, 0);
        base = cal.getTimeInMillis();
        // 45 minutes after 0:45 AM should be 'In 45 minutes, 1:30 AM'.
        assertEquals("In 45 minutes, 1:30 AM",
        assertEquals("In 45 minutes, 1:30\u202fAM",
                getRelativeDateTimeString(en_US, tz, base + 45 * MINUTE_IN_MILLIS, base, 0,
                        WEEK_IN_MILLIS, 0));
        // 45 minutes later, it should be 'In 45 minutes, 1:15 AM'.
        assertEquals("In 45 minutes, 1:15 AM",
        assertEquals("In 45 minutes, 1:15\u202fAM",
                getRelativeDateTimeString(en_US, tz, base + 90 * MINUTE_IN_MILLIS,
                        base + 45 * MINUTE_IN_MILLIS, 0, WEEK_IN_MILLIS, 0));
        // Another 45 minutes later, it should be 'In 45 minutes, 2:00 AM'.
        assertEquals("In 45 minutes, 2:00 AM",
        assertEquals("In 45 minutes, 2:00\u202fAM",
                getRelativeDateTimeString(en_US, tz, base + 135 * MINUTE_IN_MILLIS,
                        base + 90 * MINUTE_IN_MILLIS, 0, WEEK_IN_MILLIS, 0));
    }
@@ -593,7 +593,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar yesterdayCalendar1 = Calendar.getInstance(tz, en_US);
        yesterdayCalendar1.set(2011, Calendar.SEPTEMBER, 1, 10, 24, 0);
        long yesterday1 = yesterdayCalendar1.getTimeInMillis();
        assertEquals("Yesterday, 10:24 AM",
        assertEquals("Yesterday, 10:24\u202fAM",
                getRelativeDateTimeString(en_US, tz, yesterday1, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -601,7 +601,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar yesterdayCalendar2 = Calendar.getInstance(tz, en_US);
        yesterdayCalendar2.set(2011, Calendar.SEPTEMBER, 1, 10, 22, 0);
        long yesterday2 = yesterdayCalendar2.getTimeInMillis();
        assertEquals("Yesterday, 10:22 AM",
        assertEquals("Yesterday, 10:22\u202fAM",
                getRelativeDateTimeString(en_US, tz, yesterday2, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -609,7 +609,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar twoDaysAgoCalendar1 = Calendar.getInstance(tz, en_US);
        twoDaysAgoCalendar1.set(2011, Calendar.AUGUST, 31, 10, 24, 0);
        long twoDaysAgo1 = twoDaysAgoCalendar1.getTimeInMillis();
        assertEquals("2 days ago, 10:24 AM",
        assertEquals("2 days ago, 10:24\u202fAM",
                getRelativeDateTimeString(en_US, tz, twoDaysAgo1, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -617,7 +617,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar twoDaysAgoCalendar2 = Calendar.getInstance(tz, en_US);
        twoDaysAgoCalendar2.set(2011, Calendar.AUGUST, 31, 10, 22, 0);
        long twoDaysAgo2 = twoDaysAgoCalendar2.getTimeInMillis();
        assertEquals("2 days ago, 10:22 AM",
        assertEquals("2 days ago, 10:22\u202fAM",
                getRelativeDateTimeString(en_US, tz, twoDaysAgo2, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -625,7 +625,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar tomorrowCalendar1 = Calendar.getInstance(tz, en_US);
        tomorrowCalendar1.set(2011, Calendar.SEPTEMBER, 3, 10, 22, 0);
        long tomorrow1 = tomorrowCalendar1.getTimeInMillis();
        assertEquals("Tomorrow, 10:22 AM",
        assertEquals("Tomorrow, 10:22\u202fAM",
                getRelativeDateTimeString(en_US, tz, tomorrow1, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -633,7 +633,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar tomorrowCalendar2 = Calendar.getInstance(tz, en_US);
        tomorrowCalendar2.set(2011, Calendar.SEPTEMBER, 3, 10, 24, 0);
        long tomorrow2 = tomorrowCalendar2.getTimeInMillis();
        assertEquals("Tomorrow, 10:24 AM",
        assertEquals("Tomorrow, 10:24\u202fAM",
                getRelativeDateTimeString(en_US, tz, tomorrow2, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -641,7 +641,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar twoDaysLaterCalendar1 = Calendar.getInstance(tz, en_US);
        twoDaysLaterCalendar1.set(2011, Calendar.SEPTEMBER, 4, 10, 22, 0);
        long twoDaysLater1 = twoDaysLaterCalendar1.getTimeInMillis();
        assertEquals("In 2 days, 10:22 AM",
        assertEquals("In 2 days, 10:22\u202fAM",
                getRelativeDateTimeString(en_US, tz, twoDaysLater1, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));

@@ -649,7 +649,7 @@ public class RelativeDateTimeFormatterTest {
        Calendar twoDaysLaterCalendar2 = Calendar.getInstance(tz, en_US);
        twoDaysLaterCalendar2.set(2011, Calendar.SEPTEMBER, 4, 10, 24, 0);
        long twoDaysLater2 = twoDaysLaterCalendar2.getTimeInMillis();
        assertEquals("In 2 days, 10:24 AM",
        assertEquals("In 2 days, 10:24\u202fAM",
                getRelativeDateTimeString(en_US, tz, twoDaysLater2, now, MINUTE_IN_MILLIS,
                        WEEK_IN_MILLIS, 0));
    }
@@ -664,11 +664,11 @@ public class RelativeDateTimeFormatterTest {
        cal.set(2012, Calendar.FEBRUARY, 5, 10, 50, 0);
        long base = cal.getTimeInMillis();

        assertEquals("Feb 5, 5:50 AM", getRelativeDateTimeString(en_US, tz,
        assertEquals("Feb 5, 5:50\u202fAM", getRelativeDateTimeString(en_US, tz,
                base - 5 * HOUR_IN_MILLIS, base, 0, MINUTE_IN_MILLIS, 0));
        assertEquals("Jan 29, 10:50 AM", getRelativeDateTimeString(en_US, tz,
        assertEquals("Jan 29, 10:50\u202fAM", getRelativeDateTimeString(en_US, tz,
                base - 7 * DAY_IN_MILLIS, base, 0, WEEK_IN_MILLIS, 0));
        assertEquals("11/27/2011, 10:50 AM", getRelativeDateTimeString(en_US, tz,
        assertEquals("11/27/2011, 10:50\u202fAM", getRelativeDateTimeString(en_US, tz,
                base - 10 * WEEK_IN_MILLIS, base, 0, WEEK_IN_MILLIS, 0));

        assertEquals("January 6", getRelativeTimeSpanString(en_US, tz,
@@ -687,11 +687,11 @@ public class RelativeDateTimeFormatterTest {
        // Feb 5, 2018 at 10:50 PST
        cal.set(2018, Calendar.FEBRUARY, 5, 10, 50, 0);
        base = cal.getTimeInMillis();
        assertEquals("Feb 5, 5:50 AM", getRelativeDateTimeString(en_US, tz,
        assertEquals("Feb 5, 5:50\u202fAM", getRelativeDateTimeString(en_US, tz,
                base - 5 * HOUR_IN_MILLIS, base, 0, MINUTE_IN_MILLIS, 0));
        assertEquals("Jan 29, 10:50 AM", getRelativeDateTimeString(en_US, tz,
        assertEquals("Jan 29, 10:50\u202fAM", getRelativeDateTimeString(en_US, tz,
                base - 7 * DAY_IN_MILLIS, base, 0, WEEK_IN_MILLIS, 0));
        assertEquals("11/27/2017, 10:50 AM", getRelativeDateTimeString(en_US, tz,
        assertEquals("11/27/2017, 10:50\u202fAM", getRelativeDateTimeString(en_US, tz,
                base - 10 * WEEK_IN_MILLIS, base, 0, WEEK_IN_MILLIS, 0));

        assertEquals("January 6", getRelativeTimeSpanString(en_US, tz,
+11 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({
    {0xACE00000u, 46u}, // ahl -> Latn
    {0xB8E00000u,  1u}, // aho -> Ahom
    {0x99200000u, 46u}, // ajg -> Latn
    {0xCD200000u,  2u}, // ajt -> Arab
    {0x616B0000u, 46u}, // ak -> Latn
    {0xA9400000u, 101u}, // akk -> Xsux
    {0x81600000u, 46u}, // ala -> Latn
@@ -1053,6 +1054,7 @@ const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({
    {0xB70D0000u, 46u}, // nyn -> Latn
    {0xA32D0000u, 46u}, // nzi -> Latn
    {0x6F630000u, 46u}, // oc -> Latn
    {0x6F634553u, 46u}, // oc-ES -> Latn
    {0x88CE0000u, 46u}, // ogc -> Latn
    {0x6F6A0000u, 11u}, // oj -> Cans
    {0xC92E0000u, 11u}, // ojs -> Cans
@@ -1093,6 +1095,7 @@ const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({
    {0xB4EF0000u, 71u}, // phn -> Phnx
    {0xAD0F0000u, 46u}, // pil -> Latn
    {0xBD0F0000u, 46u}, // pip -> Latn
    {0xC90F0000u, 46u}, // pis -> Latn
    {0x814F0000u,  9u}, // pka -> Brah
    {0xB94F0000u, 46u}, // pko -> Latn
    {0x706C0000u, 46u}, // pl -> Latn
@@ -1204,12 +1207,14 @@ const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({
    {0xE1720000u, 46u}, // sly -> Latn
    {0x736D0000u, 46u}, // sm -> Latn
    {0x81920000u, 46u}, // sma -> Latn
    {0x8D920000u, 46u}, // smd -> Latn
    {0xA5920000u, 46u}, // smj -> Latn
    {0xB5920000u, 46u}, // smn -> Latn
    {0xBD920000u, 76u}, // smp -> Samr
    {0xC1920000u, 46u}, // smq -> Latn
    {0xC9920000u, 46u}, // sms -> Latn
    {0x736E0000u, 46u}, // sn -> Latn
    {0x85B20000u, 46u}, // snb -> Latn
    {0x89B20000u, 46u}, // snc -> Latn
    {0xA9B20000u, 46u}, // snk -> Latn
    {0xBDB20000u, 46u}, // snp -> Latn
@@ -1314,6 +1319,7 @@ const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({
    {0x746F0000u, 46u}, // to -> Latn
    {0x95D30000u, 46u}, // tof -> Latn
    {0x99D30000u, 46u}, // tog -> Latn
    {0xA9D30000u, 46u}, // tok -> Latn
    {0xC1D30000u, 46u}, // toq -> Latn
    {0xA1F30000u, 46u}, // tpi -> Latn
    {0xB1F30000u, 46u}, // tpm -> Latn
@@ -1527,6 +1533,7 @@ std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({
    0x61665A414C61746ELLU, // af_Latn_ZA
    0xC0C0434D4C61746ELLU, // agq_Latn_CM
    0xB8E0494E41686F6DLLU, // aho_Ahom_IN
    0xCD20544E41726162LLU, // ajt_Arab_TN
    0x616B47484C61746ELLU, // ak_Latn_GH
    0xA940495158737578LLU, // akk_Xsux_IQ
    0xB560584B4C61746ELLU, // aln_Latn_XK
@@ -1534,6 +1541,7 @@ std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({
    0x616D455445746869LLU, // am_Ethi_ET
    0xB9804E474C61746ELLU, // amo_Latn_NG
    0x616E45534C61746ELLU, // an_Latn_ES
    0xB5A04E474C61746ELLU, // ann_Latn_NG
    0xE5C049444C61746ELLU, // aoz_Latn_ID
    0x8DE0544741726162LLU, // apd_Arab_TG
    0x6172454741726162LLU, // ar_Arab_EG
@@ -2039,6 +2047,7 @@ std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({
    0xB88F49525870656FLLU, // peo_Xpeo_IR
    0xACAF44454C61746ELLU, // pfl_Latn_DE
    0xB4EF4C4250686E78LLU, // phn_Phnx_LB
    0xC90F53424C61746ELLU, // pis_Latn_SB
    0x814F494E42726168LLU, // pka_Brah_IN
    0xB94F4B454C61746ELLU, // pko_Latn_KE
    0x706C504C4C61746ELLU, // pl_Latn_PL
@@ -2119,11 +2128,13 @@ std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({
    0xE17249444C61746ELLU, // sly_Latn_ID
    0x736D57534C61746ELLU, // sm_Latn_WS
    0x819253454C61746ELLU, // sma_Latn_SE
    0x8D92414F4C61746ELLU, // smd_Latn_AO
    0xA59253454C61746ELLU, // smj_Latn_SE
    0xB59246494C61746ELLU, // smn_Latn_FI
    0xBD92494C53616D72LLU, // smp_Samr_IL
    0xC99246494C61746ELLU, // sms_Latn_FI
    0x736E5A574C61746ELLU, // sn_Latn_ZW
    0x85B24D594C61746ELLU, // snb_Latn_MY
    0xA9B24D4C4C61746ELLU, // snk_Latn_ML
    0x736F534F4C61746ELLU, // so_Latn_SO
    0x99D2555A536F6764LLU, // sog_Sogd_UZ