use of android.test.FlakyTest in project android_frameworks_base by ParanoidAndroid.
the class AutoCompleteTextViewPopup method testPopupGetListSelection.
/** Test that we can look at the selection as we move around */
@FlakyTest(tolerance = 3)
public void testPopupGetListSelection() throws Throwable {
AutoCompleteTextViewSimple theActivity = getActivity();
final AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
// No initial selection
waitAssertListSelection(textView, ListView.INVALID_POSITION);
// check for selection position as expected
sendKeys("DPAD_DOWN");
waitAssertListSelection("move selection to (0)", textView, 0);
// Repeat for one more movement
sendKeys("DPAD_DOWN");
waitAssertListSelection("move selection to (1)", textView, 1);
// TODO: FlakyTest repeat runs will not currently call setUp, clear state
clearText(textView);
}
use of android.test.FlakyTest in project android_frameworks_base by ParanoidAndroid.
the class AutoCompleteTextViewCallbacks method testPopupLeaveSelection.
/** Test that arrow-up out of the popup calls the onNothingSelected callback */
@FlakyTest(tolerance = 3)
public void testPopupLeaveSelection() {
final AutoCompleteTextViewSimple theActivity = getActivity();
AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
instrumentation.waitForIdleSync();
// move down into the popup
sendKeys("DPAD_DOWN");
instrumentation.waitForIdleSync();
textView.post(new Runnable() {
public void run() {
// prepare to move down into the popup
theActivity.resetItemListeners();
}
});
sendKeys("DPAD_UP");
instrumentation.waitForIdleSync();
// now check for selection callbacks.
assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
assertFalse("onItemSelected should not be called", theActivity.mItemSelectedCalled);
assertTrue("onNothingSelected should be called", theActivity.mNothingSelectedCalled);
}
use of android.test.FlakyTest in project platform_frameworks_base by android.
the class AutoCompleteTextViewPopup method testPopupSetListSelection.
/** Test that we can move the selection and it responds as expected */
@FlakyTest(tolerance = 3)
public void testPopupSetListSelection() throws Throwable {
AutoCompleteTextViewSimple theActivity = getActivity();
final AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
// No initial selection
waitAssertListSelection(textView, ListView.INVALID_POSITION);
// set and check
runTestOnUiThread(new Runnable() {
public void run() {
textView.setListSelection(0);
}
});
instrumentation.waitForIdleSync();
waitAssertListSelection("set selection to (0)", textView, 0);
// Use movement to cross-check the movement
sendKeys("DPAD_DOWN");
waitAssertListSelection("move selection to (1)", textView, 1);
// TODO: FlakyTest repeat runs will not currently call setUp, clear state
clearText(textView);
}
use of android.test.FlakyTest in project platform_frameworks_base by android.
the class AutoCompleteTextViewPopup method testPopupNavigateNoAdapter.
/** Make sure we handle an empty adapter properly */
@FlakyTest(tolerance = 3)
public void testPopupNavigateNoAdapter() throws Throwable {
AutoCompleteTextViewSimple theActivity = getActivity();
final AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
// No initial selection
waitAssertListSelection(textView, ListView.INVALID_POSITION);
// check for selection position as expected
sendKeys("DPAD_DOWN");
waitAssertListSelection(textView, 0);
// Now get rid of the adapter
runTestOnUiThread(new Runnable() {
public void run() {
textView.setAdapter((ArrayAdapter<?>) null);
}
});
instrumentation.waitForIdleSync();
// now try moving "down" - nothing should happen since there's no longer an adapter
sendKeys("DPAD_DOWN");
// TODO: FlakyTest repeat runs will not currently call setUp, clear state
clearText(textView);
}
use of android.test.FlakyTest in project platform_frameworks_base by android.
the class AutoCompleteTextViewPopup method testPopupShow.
/** Test the show/hide behavior of the drop-down. */
@FlakyTest(tolerance = 3)
public void testPopupShow() throws Throwable {
AutoCompleteTextViewSimple theActivity = getActivity();
final AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// Drop-down should not be showing when no text has been entered
assertFalse("isPopupShowing() on start", textView.isPopupShowing());
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
// Drop-down should now be visible
waitAssertPopupShowState("isPopupShowing() after typing", textView, true);
// Clear the text
runTestOnUiThread(new Runnable() {
public void run() {
textView.setText("");
}
});
instrumentation.waitForIdleSync();
// Drop-down should be hidden when text is cleared
waitAssertPopupShowState("isPopupShowing() after text cleared", textView, false);
// Set the text, without filtering
runTestOnUiThread(new Runnable() {
public void run() {
textView.setText("a", false);
}
});
instrumentation.waitForIdleSync();
// Drop-down should still be hidden
waitAssertPopupShowState("isPopupShowing() after setText(\"a\", false)", textView, false);
// Set the text, now with filtering
runTestOnUiThread(new Runnable() {
public void run() {
textView.setText("a");
}
});
instrumentation.waitForIdleSync();
// Drop-down should show up after setText() with filtering
waitAssertPopupShowState("isPopupShowing() after text set", textView, true);
// TODO: FlakyTest repeat runs will not currently call setUp, clear state
clearText(textView);
}
Aggregations