use of android.app.Instrumentation in project android_frameworks_base by AOSPA.
the class KeyUtils method longClick.
/**
* Simulates a long click via the keyboard.
*
* @param test The test case that is being run.
*/
public static void longClick(ActivityInstrumentationTestCase test) {
final Instrumentation inst = test.getInstrumentation();
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER));
try {
Thread.sleep((long) (ViewConfiguration.getLongPressTimeout() * 1.5f));
} catch (InterruptedException e) {
e.printStackTrace();
}
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER));
}
use of android.app.Instrumentation in project android_frameworks_base by AOSPA.
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);
}
use of android.app.Instrumentation in project android_frameworks_base by AOSPA.
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 AOSPA.
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 Rosie by Karumi.
the class InjectedInstrumentationTest method getApplication.
private MainApplication getApplication() {
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
MainApplication app = (MainApplication) instrumentation.getTargetContext().getApplicationContext();
return app;
}
Aggregations