Loading core/tests/coretests/res/values-id/strings.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <!-- Used in ResourcesLocaleTest. --> <string name="locale_test_res_1">Pengujian ID</string> </resources> core/tests/coretests/res/values-in/strings.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <!-- Used in ResourcesLocaleTest. --> <string name="locale_test_res_2">Pengujian IN</string> </resources> core/tests/coretests/res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,13 @@ <string name="textview_hebrew_text">םמab?!</string> <!-- Used in ResourcesLocaleTest. Also defined in values-id. "id" is the new ISO code for Indonesian. --> <string name="locale_test_res_1">Testing ID</string> <!-- Used in ResourcesLocaleTest. Also defined in values-in. "in" is the deprecated ISO code for Indonesian. --> <string name="locale_test_res_2">Testing IN</string> <!-- Used in ResourcesLocaleTest. --> <string name="locale_test_res_3">Testing EN</string> <!-- SizeAdaptiveLayout --> <string name="first">Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.</string> <string name="actor">Abe Lincoln</string> Loading core/tests/coretests/src/android/content/res/ResourcesLocaleTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.res; import android.content.Context; import android.os.FileUtils; import android.os.LocaleList; import android.platform.test.annotations.Presubmit; Loading Loading @@ -97,4 +98,24 @@ public class ResourcesLocaleTest extends AndroidTestCase { assertEquals(Locale.forLanguageTag("pl-PL"), resources.getConfiguration().getLocales().get(0)); } @SmallTest public void testDeprecatedISOLanguageCode() { assertResGetString(Locale.US, R.string.locale_test_res_1, "Testing ID"); assertResGetString(Locale.forLanguageTag("id"), R.string.locale_test_res_2, "Pengujian IN"); assertResGetString(Locale.forLanguageTag("id"), R.string.locale_test_res_3, "Testing EN"); assertResGetString(new Locale("id"), R.string.locale_test_res_2, "Pengujian IN"); assertResGetString(new Locale("id"), R.string.locale_test_res_3, "Testing EN"); // The new ISO code "id" isn't supported yet, and thus the values-id are ignored. assertResGetString(new Locale("id"), R.string.locale_test_res_1, "Testing ID"); assertResGetString(Locale.forLanguageTag("id"), R.string.locale_test_res_1, "Testing ID"); } private void assertResGetString(Locale locale, int resId, String expectedString) { LocaleList locales = new LocaleList(locale); final Configuration config = new Configuration(); config.setLocales(locales); Context newContext = getContext().createConfigurationContext(config); assertEquals(expectedString, newContext.getResources().getString(resId)); } } Loading
core/tests/coretests/res/values-id/strings.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <!-- Used in ResourcesLocaleTest. --> <string name="locale_test_res_1">Pengujian ID</string> </resources>
core/tests/coretests/res/values-in/strings.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <!-- Used in ResourcesLocaleTest. --> <string name="locale_test_res_2">Pengujian IN</string> </resources>
core/tests/coretests/res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,13 @@ <string name="textview_hebrew_text">םמab?!</string> <!-- Used in ResourcesLocaleTest. Also defined in values-id. "id" is the new ISO code for Indonesian. --> <string name="locale_test_res_1">Testing ID</string> <!-- Used in ResourcesLocaleTest. Also defined in values-in. "in" is the deprecated ISO code for Indonesian. --> <string name="locale_test_res_2">Testing IN</string> <!-- Used in ResourcesLocaleTest. --> <string name="locale_test_res_3">Testing EN</string> <!-- SizeAdaptiveLayout --> <string name="first">Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.</string> <string name="actor">Abe Lincoln</string> Loading
core/tests/coretests/src/android/content/res/ResourcesLocaleTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.res; import android.content.Context; import android.os.FileUtils; import android.os.LocaleList; import android.platform.test.annotations.Presubmit; Loading Loading @@ -97,4 +98,24 @@ public class ResourcesLocaleTest extends AndroidTestCase { assertEquals(Locale.forLanguageTag("pl-PL"), resources.getConfiguration().getLocales().get(0)); } @SmallTest public void testDeprecatedISOLanguageCode() { assertResGetString(Locale.US, R.string.locale_test_res_1, "Testing ID"); assertResGetString(Locale.forLanguageTag("id"), R.string.locale_test_res_2, "Pengujian IN"); assertResGetString(Locale.forLanguageTag("id"), R.string.locale_test_res_3, "Testing EN"); assertResGetString(new Locale("id"), R.string.locale_test_res_2, "Pengujian IN"); assertResGetString(new Locale("id"), R.string.locale_test_res_3, "Testing EN"); // The new ISO code "id" isn't supported yet, and thus the values-id are ignored. assertResGetString(new Locale("id"), R.string.locale_test_res_1, "Testing ID"); assertResGetString(Locale.forLanguageTag("id"), R.string.locale_test_res_1, "Testing ID"); } private void assertResGetString(Locale locale, int resId, String expectedString) { LocaleList locales = new LocaleList(locale); final Configuration config = new Configuration(); config.setLocales(locales); Context newContext = getContext().createConfigurationContext(config); assertEquals(expectedString, newContext.getResources().getString(resId)); } }