use of android.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
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);
}
use of android.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
the class PowerMeasurement method testPageLoadStaticNYTimes.
public void testPageLoadStaticNYTimes() throws Throwable {
Instrumentation mInst = getInstrumentation();
PowerTestActivity act = getActivity();
Intent intent = new Intent(mInst.getContext(), PowerTestActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
long start = System.currentTimeMillis();
PowerTestActivity activity = (PowerTestActivity) mInst.startActivitySync(intent);
activity.reset();
//send a message with the new URL
Handler handler = activity.getHandler();
Message msg = handler.obtainMessage(PowerTestActivity.MSG_NAVIGATE, TIME_OUT, DELAY);
msg.getData().putString(PowerTestActivity.MSG_NAV_URL, TESTING_URL);
msg.getData().putBoolean(PowerTestActivity.MSG_NAV_LOGTIME, true);
handler.sendMessage(msg);
boolean timeoutFlag = activity.waitUntilDone();
long end = System.currentTimeMillis();
assertFalse(TESTING_URL + " failed to load", timeoutFlag);
boolean pageErrorFlag = activity.getPageError();
assertFalse(TESTING_URL + " is not available, either network is down or the server is down", pageErrorFlag);
Log.v(LOGTAG, "Page is loaded in " + activity.getPageLoadTime() + " ms.");
// Force to clean up the cache dir so that it get back to the clean
// state
Runtime fileRemoval = Runtime.getRuntime();
String cmdBecomeSu = "su";
boolean clearCacheSuccess = false;
try {
Process runsum = fileRemoval.exec(cmdBecomeSu);
int exitVal = runsum.waitFor();
String rmfile = "rm -r /data/data/com.android.browserpowertest/cache";
Process removal = fileRemoval.exec(rmfile);
exitVal = removal.waitFor();
if (exitVal == 0) {
clearCacheSuccess = true;
}
} catch (Exception e) {
assertTrue("Fails to clear the cahche", false);
}
assertTrue("Fails to clear the cahche", clearCacheSuccess);
activity.finish();
}
use of android.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
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.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
the class AutoCompleteTextViewCallbacks method testPopupNoSelection.
/** Test that the initial popup of the suggestions does not select anything.
*/
@FlakyTest(tolerance = 3)
public void testPopupNoSelection() throws Exception {
AutoCompleteTextViewSimple theActivity = getActivity();
AutoCompleteTextView textView = theActivity.getTextView();
final Instrumentation instrumentation = getInstrumentation();
// focus and type
textView.requestFocus();
instrumentation.waitForIdleSync();
sendKeys("A");
instrumentation.waitForIdleSync();
// give UI time to settle
Thread.sleep(WAIT_TIME);
// now check for selection callbacks. Nothing should be clicked or selected.
assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
assertFalse("onItemSelected should not be called", theActivity.mItemSelectedCalled);
// arguably, this should be "false", because we aren't deselecting - we shouldn't
// really be calling it. But it's not the end of the world, and we might wind up
// breaking something if we change this.
//assertTrue("onNothingSelected should be called", theActivity.mNothingSelectedCalled);
}
use of android.app.Instrumentation in project android_frameworks_base by ResurrectionRemix.
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);
}
Aggregations