use of android.app.Instrumentation in project platform_frameworks_base by android.
the class AutoCompleteTextViewCallbacks method testPopupEnterSelection.
/** Test that arrow-down into the popup calls the onSelected callback. */
@FlakyTest(tolerance = 3)
public void testPopupEnterSelection() throws Exception {
final AutoCompleteTextViewSimple theActivity = getActivity();
AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
textView.post(new Runnable() {
public void run() {
// prepare to move down into the popup
theActivity.resetItemListeners();
}
});
sendKeys("DPAD_DOWN");
instrumentation.waitForIdleSync();
// give UI time to settle
Thread.sleep(WAIT_TIME);
// now check for selection callbacks.
assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
assertTrue("onItemSelected should be called", theActivity.mItemSelectedCalled);
assertEquals("onItemSelected position", 0, theActivity.mItemSelectedPosition);
assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
textView.post(new Runnable() {
public void run() {
// try one more time - should move from 0 to 1
theActivity.resetItemListeners();
}
});
sendKeys("DPAD_DOWN");
instrumentation.waitForIdleSync();
// give UI time to settle
Thread.sleep(WAIT_TIME);
// now check for selection callbacks.
assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
assertTrue("onItemSelected should be called", theActivity.mItemSelectedCalled);
assertEquals("onItemSelected position", 1, theActivity.mItemSelectedPosition);
assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
}
use of android.app.Instrumentation in project platform_frameworks_base by android.
the class InstrumentationTestCase method sendKeys.
/**
* Sends a series of key events through instrumentation and waits for idle. For instance:
* sendKeys(KEYCODE_DPAD_LEFT, KEYCODE_DPAD_CENTER).
*
* @param keys The series of key codes to send through instrumentation.
*/
public void sendKeys(int... keys) {
final int count = keys.length;
final Instrumentation instrumentation = getInstrumentation();
for (int i = 0; i < count; i++) {
try {
instrumentation.sendKeyDownUpSync(keys[i]);
} catch (SecurityException e) {
// Ignore security exceptions that are now thrown
// when trying to send to another app, to retain
// compatibility with existing tests.
}
}
instrumentation.waitForIdleSync();
}
use of android.app.Instrumentation in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class ListEmptyViewTest method testZeroToOne.
@MediumTest
public void testZeroToOne() {
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);
}
use of android.app.Instrumentation in project platform_frameworks_base by android.
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);
}
Aggregations