ListWithScreenOfNoSelectablesTestpublic class ListWithScreenOfNoSelectablesTest extends android.test.ActivityInstrumentationTestCase
Fields Summary |
---|
private android.widget.ListView | mListView |
Constructors Summary |
---|
public ListWithScreenOfNoSelectablesTest()
super("com.android.frameworktest", ListWithScreenOfNoSelectables.class);
|
Methods Summary |
---|
protected void | setUp()
super.setUp();
mListView = getActivity().getListView();
| public void | testGoFromNoSelectionToSelectionExists()
// go down untile first (and only selectable) item is off screen
View first = mListView.getChildAt(0);
while (first.getParent() != null) {
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
}
// nothing should be selected
assertEquals("selected position", ListView.INVALID_POSITION, mListView.getSelectedItemPosition());
assertNull("selected view", mListView.getSelectedView());
// go up once to bring the selectable back on screen
sendKeys(KeyEvent.KEYCODE_DPAD_UP);
assertEquals("first visible position", 0, mListView.getFirstVisiblePosition());
assertEquals("selected position", ListView.INVALID_POSITION, mListView.getSelectedItemPosition());
// up once more should give it selection
sendKeys(KeyEvent.KEYCODE_DPAD_UP);
assertEquals("selected position", 0, mListView.getSelectedItemPosition());
| public void | testGoFromSelectedViewExistsToNoSelectedViewExists()
// go down untile first (and only selectable) item is off screen
View first = mListView.getChildAt(0);
while (first.getParent() != null) {
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
}
// nothing should be selected
assertEquals("selected position", ListView.INVALID_POSITION, mListView.getSelectedItemPosition());
assertNull("selected view", mListView.getSelectedView());
| public void | testPanDownAcrossUnselectableChildrenToBottom()
final int lastPosition = mListView.getCount() - 1;
final int maxDowns = 20;
for(int count = 0; count < maxDowns && mListView.getLastVisiblePosition() <= lastPosition; count++) {
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
}
assertEquals("last visible position not the last position in the list even "
+ "after " + maxDowns + " downs", lastPosition, mListView.getLastVisiblePosition());
| public void | testPreconditions()
assertTrue("expecting first position to be selectable",
mListView.getAdapter().isEnabled(0));
final int numItems = mListView.getCount();
for (int i = 1; i < numItems; i++) {
assertFalse("expecting item to be unselectable (index " + i +")",
mListView.getAdapter().isEnabled(i));
}
assertTrue("expecting that not all views fit on screen",
mListView.getChildCount() < mListView.getCount());
|
|