use of android.app.Instrumentation in project android_frameworks_base by DirtyUnicorns.
the class ListScrollListenerTest method testKeyScrolling.
@LargeTest
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);
}
use of android.app.Instrumentation in project android_frameworks_base by DirtyUnicorns.
the class ListViewHeightTest method testButtons.
@MediumTest
public void testButtons() {
Instrumentation inst = getInstrumentation();
final Button button1 = (Button) mActivity.findViewById(R.id.button1);
final Button button2 = (Button) mActivity.findViewById(R.id.button2);
final Button button3 = (Button) mActivity.findViewById(R.id.button3);
ListView list = (ListView) mActivity.findViewById(R.id.inner_list);
assertEquals("Unexpected items in adapter", 0, list.getCount());
assertEquals("Unexpected children in list view", 0, list.getChildCount());
mActivity.runOnUiThread(new Runnable() {
public void run() {
button1.performClick();
}
});
inst.waitForIdleSync();
assertTrue("List not be visible after clicking button1", list.isShown());
assertTrue("List incorrect height", list.getHeight() == 200);
mActivity.runOnUiThread(new Runnable() {
public void run() {
button2.performClick();
}
});
inst.waitForIdleSync();
assertTrue("List not be visible after clicking button2", list.isShown());
mActivity.runOnUiThread(new Runnable() {
public void run() {
button3.performClick();
}
});
inst.waitForIdleSync();
assertFalse("List should not be visible clicking button3", list.isShown());
}
use of android.app.Instrumentation in project android_frameworks_base by DirtyUnicorns.
the class ListEmptyViewTest method testZeroToOneForwardBack.
@MediumTest
public void testZeroToOneForwardBack() {
Instrumentation inst = getInstrumentation();
inst.invokeMenuActionSync(mActivity, mActivity.MENU_ADD, 0);
inst.waitForIdleSync();
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
// Navigate forward
Intent intent = new Intent();
intent.setClass(mActivity, ListWithEmptyView.class);
mActivity.startActivity(intent);
// Navigate backward
inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
inst.waitForIdleSync();
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
}
use of android.app.Instrumentation in project android_frameworks_base by DirtyUnicorns.
the class ListEmptyViewTest method testZeroToManyToZero.
@LargeTest
public void testZeroToManyToZero() {
Instrumentation inst = getInstrumentation();
int i;
for (i = 0; i < 10; i++) {
inst.invokeMenuActionSync(mActivity, mActivity.MENU_ADD, 0);
inst.waitForIdleSync();
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
}
for (i = 0; i < 10; i++) {
inst.invokeMenuActionSync(mActivity, mActivity.MENU_REMOVE, 0);
inst.waitForIdleSync();
if (i < 9) {
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
} else {
assertTrue("Empty view not shown", mActivity.getEmptyView().getVisibility() == View.VISIBLE);
assertTrue("List still shown", mActivity.getListView().getVisibility() == View.GONE);
}
}
// Navigate forward
Intent intent = new Intent();
intent.setClass(mActivity, ListWithEmptyView.class);
mActivity.startActivity(intent);
// Navigate backward
inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
inst.waitForIdleSync();
assertTrue("Empty view not shown", mActivity.getEmptyView().getVisibility() == View.VISIBLE);
assertTrue("List still shown", mActivity.getListView().getVisibility() == View.GONE);
}
use of android.app.Instrumentation in project android_frameworks_base by DirtyUnicorns.
the class ListHeterogeneousTest method testKeyScrolling.
@LargeTest
public void testKeyScrolling() {
Instrumentation inst = getInstrumentation();
int count = mListView.getAdapter().getCount();
for (int i = 0; i < count - 1; i++) {
inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
}
inst.waitForIdleSync();
int convertMissesBefore = mActivity.getConvertMisses();
assertEquals("Unexpected convert misses", 0, convertMissesBefore);
for (int i = 0; i < count - 1; i++) {
inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_UP);
}
inst.waitForIdleSync();
int convertMissesAfter = mActivity.getConvertMisses();
assertEquals("Unexpected convert misses", 0, convertMissesAfter);
}
Aggregations