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

ArrayTest

public class ArrayTest extends android.test.AndroidTestCase

Fields Summary
private android.content.res.Resources
mResources
Constructors Summary
Methods Summary
private voidcheckEntry(int resid, int index, java.lang.Object res, java.lang.Object expected)

        assertEquals("in resource 0x" + Integer.toHexString(resid)
                + " at index " + index, expected, res);
    
private voidcheckIntArray(int resid, int[] expected)

        int[] res = mResources.getIntArray(resid);
        assertEquals(res.length, expected.length);
        for (int i=0; i<expected.length; i++) {
            assertEquals("in resource 0x" + Integer.toHexString(resid)
                    + " at index " + i, expected[i], res[i]);
        }
    
private voidcheckStringArray(int resid, java.lang.String[] expected)

        String[] res = mResources.getStringArray(resid);
        assertEquals(res.length, expected.length);
        for (int i=0; i<expected.length; i++) {
            checkEntry(resid, i, res[i], expected[i]);
        }
    
private voidcheckTextArray(int resid, java.lang.String[] expected)

        CharSequence[] res = mResources.getTextArray(resid);
        assertEquals(res.length, expected.length);
        for (int i=0; i<expected.length; i++) {
            checkEntry(resid, i, res[i], expected[i]);
        }
    
protected voidsetUp()

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

        checkIntArray(R.array.strings, new int[] {0, 0, 0});
        checkIntArray(R.array.integers, new int[] {0, 1, 101});
    
public voidtestStrings()

        checkStringArray(R.array.strings, new String[] {"zero", "1", "here"});
        checkTextArray(R.array.strings, new String[] {"zero", "1", "here"});
        checkStringArray(R.array.integers, new String[] {null, null, null});
        checkTextArray(R.array.integers, new String[] {null, null, null});