Search in sources :

Example 51 with Instrumentation

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);
}
Also used : Instrumentation(android.app.Instrumentation) Activity(android.app.Activity) Intent(android.content.Intent) File(java.io.File) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 52 with Instrumentation

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();
}
Also used : Message(android.os.Message) Instrumentation(android.app.Instrumentation) Handler(android.os.Handler) Intent(android.content.Intent)

Example 53 with Instrumentation

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);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 54 with Instrumentation

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);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 55 with Instrumentation

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);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Aggregations

Instrumentation (android.app.Instrumentation)225 LargeTest (android.test.suitebuilder.annotation.LargeTest)59 FlakyTest (android.test.FlakyTest)49 Intent (android.content.Intent)37 KeyEvent (android.view.KeyEvent)30 MotionEvent (android.view.MotionEvent)27 Point (android.graphics.Point)25 MediumTest (android.test.suitebuilder.annotation.MediumTest)18 Activity (android.app.Activity)14 Field (java.lang.reflect.Field)10 CameraActivity (com.android.camera.CameraActivity)8 Uri (android.net.Uri)7 File (java.io.File)7 Handler (android.os.Handler)6 KeyCharacterMap (android.view.KeyCharacterMap)6 Button (android.widget.Button)6 ListView (android.widget.ListView)6 Message (android.os.Message)5 MessageQueue (android.os.MessageQueue)4 EditText (android.widget.EditText)4