Search in sources :

Example 11 with Instrumentation

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

the class ListManagedCursorTest method testKeyScrolling.

/**
     * Scroll the list using arrows, launch new activity, hit back, make sure we're still scrolled.
     */
@LargeTest
public void testKeyScrolling() {
    Instrumentation inst = getInstrumentation();
    int firstVisiblePosition = arrowScroll(inst);
    inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
    inst.waitForIdleSync();
    assertTrue("List changed to touch mode", !mListView.isInTouchMode());
    assertTrue("List did not preserve scroll position", firstVisiblePosition == mListView.getFirstVisiblePosition());
}
Also used : Instrumentation(android.app.Instrumentation) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 12 with Instrumentation

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

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 13 with Instrumentation

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

the class ListViewHeightTest method testButtons.

@MediumTest
public void testButtons() {
    Instrumentation inst = getInstrumentation();
    final Button button1 = (Button) mActivity.findViewById(R.id.button1);
    final Button button2 = (Button) mActivity.findViewById(R.id.button2);
    final Button button3 = (Button) mActivity.findViewById(R.id.button3);
    ListView list = (ListView) mActivity.findViewById(R.id.inner_list);
    assertEquals("Unexpected items in adapter", 0, list.getCount());
    assertEquals("Unexpected children in list view", 0, list.getChildCount());
    mActivity.runOnUiThread(new Runnable() {

        public void run() {
            button1.performClick();
        }
    });
    inst.waitForIdleSync();
    assertTrue("List not be visible after clicking button1", list.isShown());
    assertTrue("List incorrect height", list.getHeight() == 200);
    mActivity.runOnUiThread(new Runnable() {

        public void run() {
            button2.performClick();
        }
    });
    inst.waitForIdleSync();
    assertTrue("List not be visible after clicking button2", list.isShown());
    mActivity.runOnUiThread(new Runnable() {

        public void run() {
            button3.performClick();
        }
    });
    inst.waitForIdleSync();
    assertFalse("List should not be visible clicking button3", list.isShown());
}
Also used : ListView(android.widget.ListView) Button(android.widget.Button) Instrumentation(android.app.Instrumentation) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 14 with Instrumentation

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

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 15 with Instrumentation

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

the class TouchUtils method drag.

/**
     * Simulate touching a specific location and dragging to a new location.
     * 
     * @param test The test case that is being run
     * @param fromX X coordinate of the initial touch, in screen coordinates
     * @param toX Xcoordinate of the drag destination, in screen coordinates
     * @param fromY X coordinate of the initial touch, in screen coordinates
     * @param toY Y coordinate of the drag destination, in screen coordinates
     * @param stepCount How many move steps to include in the drag
     */
public static void drag(InstrumentationTestCase test, float fromX, float toX, float fromY, float toY, int stepCount) {
    Instrumentation inst = test.getInstrumentation();
    long downTime = SystemClock.uptimeMillis();
    long eventTime = SystemClock.uptimeMillis();
    float y = fromY;
    float x = fromX;
    float yStep = (toY - fromY) / stepCount;
    float xStep = (toX - fromX) / stepCount;
    MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0);
    inst.sendPointerSync(event);
    inst.waitForIdleSync();
    for (int i = 0; i < stepCount; ++i) {
        y += yStep;
        x += xStep;
        eventTime = SystemClock.uptimeMillis();
        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x, y, 0);
        inst.sendPointerSync(event);
        inst.waitForIdleSync();
    }
    eventTime = SystemClock.uptimeMillis();
    event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0);
    inst.sendPointerSync(event);
    inst.waitForIdleSync();
}
Also used : Instrumentation(android.app.Instrumentation) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent)

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