PluralResourcesTestpublic class PluralResourcesTest extends android.test.AndroidTestCase
Fields Summary |
---|
private static final String | TAG | private android.content.res.Resources | mResources |
Methods Summary |
---|
android.content.res.Resources | resourcesForLanguage(java.lang.String lang)
Configuration config = new Configuration();
config.updateFrom(mResources.getConfiguration());
config.locale = new Locale(lang);
return new Resources(mResources.getAssets(), mResources.getDisplayMetrics(), config);
| protected void | setUp()
super.setUp();
mResources = mContext.getResources();
| public void | testCzech()
CharSequence cs;
Resources res = resourcesForLanguage("cs");
cs = res.getQuantityText(R.plurals.plurals_test, 0);
Log.d(TAG, "czech 0 cs=" + cs);
Assert.assertEquals(cs.toString(), "Some Czech dogs");
cs = res.getQuantityText(R.plurals.plurals_test, 1);
Log.d(TAG, "czech 1 cs=" + cs);
Assert.assertEquals(cs.toString(), "A Czech dog");
cs = res.getQuantityText(R.plurals.plurals_test, 2);
Log.d(TAG, "czech 2 cs=" + cs);
Assert.assertEquals(cs.toString(), "Few Czech dogs");
cs = res.getQuantityText(R.plurals.plurals_test, 5);
Assert.assertEquals(cs.toString(), "Some Czech dogs");
cs = res.getQuantityText(R.plurals.plurals_test, 500);
Assert.assertEquals(cs.toString(), "Some Czech dogs");
| public void | testPlurals()
CharSequence cs;
Resources res = resourcesForLanguage("en");
cs = res.getQuantityText(R.plurals.plurals_test, 0);
Log.d(TAG, "english 0 cs=" + cs);
Assert.assertEquals(cs.toString(), "Some dogs");
cs = res.getQuantityText(R.plurals.plurals_test, 1);
Log.d(TAG, "english 1 cs=" + cs);
Assert.assertEquals(cs.toString(), "A dog");
cs = res.getQuantityText(R.plurals.plurals_test, 2);
Assert.assertEquals(cs.toString(), "Some dogs");
cs = res.getQuantityText(R.plurals.plurals_test, 5);
Assert.assertEquals(cs.toString(), "Some dogs");
cs = res.getQuantityText(R.plurals.plurals_test, 500);
Assert.assertEquals(cs.toString(), "Some dogs");
|
|