use of android.app.Instrumentation in project android_frameworks_base by AOSPA.
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);
}
use of android.app.Instrumentation in project android_frameworks_base by AOSPA.
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.app.Instrumentation in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
the class AutoCompleteTextViewPopup method testPopupClearListSelection.
/** Test that we can clear the selection */
@FlakyTest(tolerance = 3)
public void testPopupClearListSelection() 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);
// clear it
runTestOnUiThread(new Runnable() {
public void run() {
textView.clearListSelection();
}
});
instrumentation.waitForIdleSync();
waitAssertListSelection("setListSelection(ListView.INVALID_POSITION)", textView, ListView.INVALID_POSITION);
// TODO: FlakyTest repeat runs will not currently call setUp, clear state
clearText(textView);
}
use of android.app.Instrumentation in project android_frameworks_base by AOSPA.
the class EffectsVideoCapture method testBackEffectsVideoCapture.
@LargeTest
public void testBackEffectsVideoCapture() throws Exception {
Instrumentation inst = getInstrumentation();
Intent intent = new Intent();
intent.setClass(getInstrumentation().getTargetContext(), CameraEffectsRecordingSample.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("OUTPUT_FILENAME", Environment.getExternalStorageDirectory().toString() + "/CameraEffectsRecordingTest.mp4");
Activity act = inst.startActivitySync(intent);
captureVideos("Back Camera Video Capture\n", inst);
act.finish();
// Verification
File file = new File(Environment.getExternalStorageDirectory(), "CameraEffectsRecordingTest.mp4");
Uri uri = Uri.fromFile(file);
verify(getActivity(), uri);
}
Aggregations