Search in sources :

Example 91 with Instrumentation

use of android.app.Instrumentation in project android_frameworks_base by crdroidandroid.

the class ListScrollListenerTest method testKeyScrolling.

@LargeTest
public void testKeyScrolling() {
    Instrumentation inst = getInstrumentation();
    int firstVisibleItem = mFirstVisibleItem;
    for (int i = 0; i < mVisibleItemCount * 2; i++) {
        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
    }
    inst.waitForIdleSync();
    assertTrue("Arrow scroll did not happen", mFirstVisibleItem > firstVisibleItem);
    firstVisibleItem = mFirstVisibleItem;
    inst.sendCharacterSync(KeyEvent.KEYCODE_SPACE);
    inst.waitForIdleSync();
    assertTrue("Page scroll did not happen", mFirstVisibleItem > firstVisibleItem);
    firstVisibleItem = mFirstVisibleItem;
    KeyEvent down = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_DOWN, 0, KeyEvent.META_ALT_ON);
    KeyEvent up = new KeyEvent(0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_DOWN, 0, KeyEvent.META_ALT_ON);
    inst.sendKeySync(down);
    inst.sendKeySync(up);
    inst.waitForIdleSync();
    assertTrue("Full scroll did not happen", mFirstVisibleItem > firstVisibleItem);
    assertEquals("Full scroll did not happen", mTotalItemCount, mFirstVisibleItem + mVisibleItemCount);
}
Also used : KeyEvent(android.view.KeyEvent) Instrumentation(android.app.Instrumentation) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 92 with Instrumentation

use of android.app.Instrumentation in project android_packages_apps_Camera by CyanogenMod.

the class CameraTestCase method performClick.

protected void performClick(final int id) {
    Activity activity = getActivity();
    getInstrumentation().waitForIdleSync();
    assertNotNull(activity.findViewById(id));
    Instrumentation inst = getInstrumentation();
    inst.runOnMainSync(new Runnable() {

        @Override
        public void run() {
            View v = getActivity().findViewById(id);
            float x = (v.getLeft() + v.getRight()) / 2;
            float y = (v.getTop() + v.getBottom()) / 2;
            MotionEvent down = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, x, y, 0, 0, 0, 0, 0, 0, 0);
            MotionEvent up = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, x, y, 0, 0, 0, 0, 0, 0, 0);
            View parent = (View) v.getParent();
            parent.dispatchTouchEvent(down);
            parent.dispatchTouchEvent(up);
        }
    });
    inst.waitForIdleSync();
}
Also used : Activity(android.app.Activity) Instrumentation(android.app.Instrumentation) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 93 with Instrumentation

use of android.app.Instrumentation in project android_packages_apps_Camera by CyanogenMod.

the class CameraTestCase method internalTestFailToConnect.

protected void internalTestFailToConnect() throws Exception {
    CameraHolder.injectMockCamera(mCameraInfo, null);
    getActivity();
    Instrumentation inst = getInstrumentation();
    inst.waitForIdleSync();
    // close dialog
    inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
}
Also used : Instrumentation(android.app.Instrumentation)

Example 94 with Instrumentation

use of android.app.Instrumentation in project android_packages_apps_Camera by CyanogenMod.

the class CameraStartUp method launchVideo.

private long launchVideo() {
    long startupTime = 0;
    try {
        Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
        intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        long beforeStart = System.currentTimeMillis();
        Instrumentation inst = getInstrumentation();
        Activity recorderActivity = inst.startActivitySync(intent);
        long cameraStarted = System.currentTimeMillis();
        recorderActivity.finish();
        startupTime = cameraStarted - beforeStart;
        Log.v(TAG, "Video Startup Time = " + startupTime);
        // wait for 1s to make sure it reach a clean stage
        Thread.sleep(WAIT_TIME_FOR_PREVIEW);
        Log.v(TAG, "video startup time: " + startupTime);
    } catch (Exception e) {
        Log.v(TAG, "Got exception", e);
        fail("Fails to launch video output file");
    }
    return startupTime;
}
Also used : Instrumentation(android.app.Instrumentation) CameraActivity(com.android.camera.CameraActivity) Activity(android.app.Activity) Intent(android.content.Intent)

Example 95 with Instrumentation

use of android.app.Instrumentation in project android_packages_apps_Camera by CyanogenMod.

the class ImageCapture method testFrontImageCapture.

@LargeTest
public void testFrontImageCapture() throws Exception {
    Instrumentation inst = getInstrumentation();
    Intent intent = new Intent();
    intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(EXTRAS_CAMERA_FACING, android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
    Activity act = inst.startActivitySync(intent);
    Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
    captureImages("Front Camera Image Capture\n", inst);
    act.finish();
}
Also used : Instrumentation(android.app.Instrumentation) CameraActivity(com.android.camera.CameraActivity) Activity(android.app.Activity) Intent(android.content.Intent) LargeTest(android.test.suitebuilder.annotation.LargeTest)

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