ArrayTestpublic class ArrayTest extends android.test.AndroidTestCase
Fields Summary |
---|
private android.content.res.Resources | mResources |
Methods Summary |
---|
private void | checkEntry(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 void | checkIntArray(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 void | checkStringArray(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 void | checkTextArray(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 void | setUp()
super.setUp();
mResources = mContext.getResources();
| public void | testIntegers()
checkIntArray(R.array.strings, new int[] {0, 0, 0});
checkIntArray(R.array.integers, new int[] {0, 1, 101});
| public void | testStrings()
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});
|
|