ListWithEditTextHeaderTestpublic class ListWithEditTextHeaderTest extends android.test.ActivityInstrumentationTestCase2
Fields Summary |
---|
private android.widget.ListView | mListView |
Constructors Summary |
---|
public ListWithEditTextHeaderTest()
super(ListWithEditTextHeader.class);
|
Methods Summary |
---|
protected void | setUp()
super.setUp();
mListView = getActivity().getListView();
| public void | testClickingHeaderKeepsFocus()
TouchUtils.clickView(this, mListView.getChildAt(0));
assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
assertEquals("something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
| public void | testClickingHeaderWhenOtherItemHasFocusGivesHeaderFocus()
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
assertEquals("selected position", 1, mListView.getSelectedItemPosition());
TouchUtils.clickView(this, mListView.getChildAt(0));
assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
assertEquals("something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
| public void | testPreconditions()
assertTrue("listview.getItemsCanFocus()", mListView.getItemsCanFocus());
assertFalse("out of touch-mode", mListView.isInTouchMode());
assertEquals("header view count", 1, mListView.getHeaderViewsCount());
assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
| public void | testScrollingDoesNotDetachHeaderViewFromWindow()
View header = mListView.getChildAt(0);
assertNotNull("header is not attached to a window (?!)", header.getWindowToken());
// Scroll header off the screen and back onto the screen
int numItemsOnScreen = mListView.getChildCount();
for (int i = 0; i < numItemsOnScreen; i++) {
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
}
for (int i = 0; i < numItemsOnScreen; i++) {
sendKeys(KeyEvent.KEYCODE_DPAD_UP);
}
// Make sure the header was not accidentally left detached from its window
assertNotNull("header has lost its window", header.getWindowToken());
|
|