FileDocCategorySizeDatePackage
PluralResourcesTest.javaAPI DocAndroid 1.5 API3372Wed May 06 22:42:02 BST 2009com.android.unit_tests.content

PluralResourcesTest

public class PluralResourcesTest extends android.test.AndroidTestCase

Fields Summary
private static final String
TAG
private android.content.res.Resources
mResources
Constructors Summary
Methods Summary
android.content.res.ResourcesresourcesForLanguage(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 voidsetUp()


    
         
        super.setUp();
        mResources = mContext.getResources();
    
public voidtestCzech()

        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 voidtestPlurals()

        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");