CompositeCursorAdapterTestpublic class CompositeCursorAdapterTest extends android.test.AndroidTestCase Tests for {@link CompositeCursorAdapter}.
To execute, run:
adb shell am instrument -e class com.android.common.widget.CompositeCursorAdapterTest \
-w com.android.common.tests/android.test.InstrumentationTestRunner
|
Methods Summary |
---|
private android.database.Cursor | makeCursor(java.lang.String name, int count)
MatrixCursor cursor = new MatrixCursor(new String[]{name});
for (int i = 0; i < count; i++) {
cursor.addRow(new Object[]{i});
}
return cursor;
| public void | testAreAllItemsEnabledFalse()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, false);
adapter.addPartition(true, true);
assertFalse(adapter.areAllItemsEnabled());
| public void | testAreAllItemsEnabledTrue()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, false);
adapter.addPartition(true, false);
assertTrue(adapter.areAllItemsEnabled());
| public void | testGetCountNoEmptySections()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(false, false);
adapter.addPartition(false, false);
adapter.changeCursor(0, makeCursor("a", 2));
adapter.changeCursor(1, makeCursor("b", 3));
assertEquals(5, adapter.getCount());
| public void | testGetCountWithHeadersAndNoEmptySections()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(false, true);
adapter.addPartition(false, true);
adapter.changeCursor(0, makeCursor("a", 2));
adapter.changeCursor(1, makeCursor("b", 3));
assertEquals(7, adapter.getCount());
| public void | testGetCountWithHiddenEmptySection()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(false, true);
adapter.addPartition(false, true);
adapter.changeCursor(1, makeCursor("a", 2));
assertEquals(3, adapter.getCount());
| public void | testGetCountWithShownEmptySection()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, true);
adapter.addPartition(true, true);
adapter.changeCursor(1, makeCursor("a", 2));
assertEquals(4, adapter.getCount());
| public void | testGetOffsetForPosition()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, false);
adapter.addPartition(true, true);
adapter.changeCursor(0, makeCursor("a", 1));
adapter.changeCursor(1, makeCursor("b", 2));
assertEquals(0, adapter.getOffsetInPartition(0));
assertEquals(-1, adapter.getOffsetInPartition(1));
assertEquals(0, adapter.getOffsetInPartition(2));
assertEquals(1, adapter.getOffsetInPartition(3));
| public void | testGetPartitionForPosition()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, false);
adapter.addPartition(true, true);
adapter.changeCursor(0, makeCursor("a", 1));
adapter.changeCursor(1, makeCursor("b", 2));
assertEquals(0, adapter.getPartitionForPosition(0));
assertEquals(1, adapter.getPartitionForPosition(1));
assertEquals(1, adapter.getPartitionForPosition(2));
assertEquals(1, adapter.getPartitionForPosition(3));
| public void | testGetPositionForPartition()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, true);
adapter.addPartition(true, true);
adapter.changeCursor(0, makeCursor("a", 1));
adapter.changeCursor(1, makeCursor("b", 2));
assertEquals(0, adapter.getPositionForPartition(0));
assertEquals(2, adapter.getPositionForPartition(1));
| public void | testGetViewNoEmptySections()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(false, false);
adapter.addPartition(false, false);
adapter.changeCursor(0, makeCursor("a", 1));
adapter.changeCursor(1, makeCursor("b", 2));
for (int i = 0; i < adapter.getCount(); i++) {
adapter.getView(i, null, null);
}
assertEquals("0a[0] 1b[0] 1b[1]", adapter.toString());
| public void | testGetViewWithHeadersNoEmptySections()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(false, true);
adapter.addPartition(false, true);
adapter.changeCursor(0, makeCursor("a", 1));
adapter.changeCursor(1, makeCursor("b", 2));
for (int i = 0; i < adapter.getCount(); i++) {
adapter.getView(i, null, null);
}
assertEquals("0a[H] 0a[0] 1b[H] 1b[0] 1b[1]", adapter.toString());
| public void | testGetViewWithHiddenEmptySections()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(false, false);
adapter.addPartition(false, false);
adapter.changeCursor(1, makeCursor("b", 2));
for (int i = 0; i < adapter.getCount(); i++) {
adapter.getView(i, null, null);
}
assertEquals("1b[0] 1b[1]", adapter.toString());
| public void | testGetViewWithShownEmptySections()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, true);
adapter.addPartition(true, true);
adapter.changeCursor(1, makeCursor("b", 2));
for (int i = 0; i < adapter.getCount(); i++) {
adapter.getView(i, null, null);
}
assertEquals("0[H] 1b[H] 1b[0] 1b[1]", adapter.toString());
| public void | testIsEnabled()
TestCompositeCursorAdapter adapter = new TestCompositeCursorAdapter();
adapter.addPartition(true, false);
adapter.addPartition(true, true);
adapter.changeCursor(0, makeCursor("a", 1));
adapter.changeCursor(1, makeCursor("b", 2));
assertTrue(adapter.isEnabled(0));
assertFalse(adapter.isEnabled(1));
assertTrue(adapter.isEnabled(2));
assertTrue(adapter.isEnabled(3));
|
|