ListScrollListenerTestpublic class ListScrollListenerTest extends android.test.ActivityInstrumentationTestCase implements AbsListView.OnScrollListener
Fields Summary |
---|
private ListScrollListener | mActivity | private android.widget.ListView | mListView | private int | mFirstVisibleItem | private int | mVisibleItemCount | private int | mTotalItemCount |
Constructors Summary |
---|
public ListScrollListenerTest()
super("com.android.frameworks.coretests", ListScrollListener.class);
|
Methods Summary |
---|
public void | onScroll(android.widget.AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
mFirstVisibleItem = firstVisibleItem;
mVisibleItemCount = visibleItemCount;
mTotalItemCount = totalItemCount;
| public void | onScrollStateChanged(android.widget.AbsListView view, int scrollState)
| protected void | setUp()
super.setUp();
mActivity = getActivity();
mListView = getActivity().getListView();
mListView.setOnScrollListener(this);
| public void | testKeyScrolling()
Instrumentation inst = getInstrumentation();
int firstVisibleItem = mFirstVisibleItem;
for (int i = 0; i < mVisibleItemCount * 2; i++) {
inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
}
inst.waitForIdleSync();
assertTrue("Arrow scroll did not happen", mFirstVisibleItem > firstVisibleItem);
firstVisibleItem = mFirstVisibleItem;
inst.sendCharacterSync(KeyEvent.KEYCODE_SPACE);
inst.waitForIdleSync();
assertTrue("Page scroll did not happen", mFirstVisibleItem > firstVisibleItem);
firstVisibleItem = mFirstVisibleItem;
KeyEvent down = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_DPAD_DOWN, 0, KeyEvent.META_ALT_ON);
KeyEvent up = new KeyEvent(0, 0, KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_DPAD_DOWN, 0, KeyEvent.META_ALT_ON);
inst.sendKeySync(down);
inst.sendKeySync(up);
inst.waitForIdleSync();
assertTrue("Full scroll did not happen", mFirstVisibleItem > firstVisibleItem);
assertEquals("Full scroll did not happen", mTotalItemCount,
mFirstVisibleItem + mVisibleItemCount);
| public void | testPreconditions()
assertNotNull(mActivity);
assertNotNull(mListView);
assertEquals(0, mFirstVisibleItem);
| public void | testTouchScrolling()
int firstVisibleItem = mFirstVisibleItem;
TouchUtils.dragQuarterScreenUp(this);
TouchUtils.dragQuarterScreenUp(this);
assertTrue("Touch scroll did not happen", mFirstVisibleItem > firstVisibleItem);
|
|