GridScrollListenerTestpublic class GridScrollListenerTest extends android.test.ActivityInstrumentationTestCase implements AbsListView.OnScrollListener
Fields Summary |
---|
private com.android.frameworktest.gridview.GridScrollListener | mActivity | private android.widget.GridView | mGridView | private int | mFirstVisibleItem | private int | mVisibleItemCount | private int | mTotalItemCount |
Constructors Summary |
---|
public GridScrollListenerTest()
super("com.android.frameworktest", GridScrollListener.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();
mGridView = getActivity().getGridView();
mGridView.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(mGridView);
assertEquals(0, mFirstVisibleItem);
| public void | testTouchScrolling()
Instrumentation inst = getInstrumentation();
int firstVisibleItem = mFirstVisibleItem;
TouchUtils.dragQuarterScreenUp(this);
TouchUtils.dragQuarterScreenUp(this);
assertTrue("Touch scroll did not happen", mFirstVisibleItem > firstVisibleItem);
|
|