Search in sources :

Example 31 with Instrumentation

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

the class AutoCompleteTextViewPopup method testPopupSetListSelection.

/** Test that we can move the selection and it responds as expected */
@FlakyTest(tolerance = 3)
public void testPopupSetListSelection() 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);
    // set and check
    runTestOnUiThread(new Runnable() {

        public void run() {
            textView.setListSelection(0);
        }
    });
    instrumentation.waitForIdleSync();
    waitAssertListSelection("set selection to (0)", textView, 0);
    // Use movement to cross-check the movement
    sendKeys("DPAD_DOWN");
    waitAssertListSelection("move selection to (1)", textView, 1);
    // TODO: FlakyTest repeat runs will not currently call setUp, clear state
    clearText(textView);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 32 with Instrumentation

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

the class KeyUtils method longClick.

/**
     * Simulates a long click via the keyboard.
     * 
     * @param test The test case that is being run. 
     */
public static void longClick(ActivityInstrumentationTestCase test) {
    final Instrumentation inst = test.getInstrumentation();
    inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER));
    try {
        Thread.sleep((long) (ViewConfiguration.getLongPressTimeout() * 1.5f));
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER));
}
Also used : KeyEvent(android.view.KeyEvent) Instrumentation(android.app.Instrumentation)

Example 33 with Instrumentation

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

the class ListEmptyViewTest method testZeroToOneForwardBack.

@MediumTest
public void testZeroToOneForwardBack() {
    Instrumentation inst = getInstrumentation();
    inst.invokeMenuActionSync(mActivity, mActivity.MENU_ADD, 0);
    inst.waitForIdleSync();
    assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
    assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
    // Navigate forward
    Intent intent = new Intent();
    intent.setClass(mActivity, ListWithEmptyView.class);
    mActivity.startActivity(intent);
    // Navigate backward
    inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
    inst.waitForIdleSync();
    assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
    assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
}
Also used : Instrumentation(android.app.Instrumentation) Intent(android.content.Intent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 34 with Instrumentation

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

the class ListHeterogeneousTest method testKeyScrolling.

@LargeTest
public void testKeyScrolling() {
    Instrumentation inst = getInstrumentation();
    int count = mListView.getAdapter().getCount();
    for (int i = 0; i < count - 1; i++) {
        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
    }
    inst.waitForIdleSync();
    int convertMissesBefore = mActivity.getConvertMisses();
    assertEquals("Unexpected convert misses", 0, convertMissesBefore);
    for (int i = 0; i < count - 1; i++) {
        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_UP);
    }
    inst.waitForIdleSync();
    int convertMissesAfter = mActivity.getConvertMisses();
    assertEquals("Unexpected convert misses", 0, convertMissesAfter);
}
Also used : Instrumentation(android.app.Instrumentation) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 35 with Instrumentation

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

the class ListManagedCursorTest method testTouchScrollingToTrackballMode.

/**
     * Scroll the list using touch, launch new activity, change to trackball mode, hit back, make
     * sure we're still scrolled.
     */
@FlakyTest(tolerance = 3)
@LargeTest
public void testTouchScrollingToTrackballMode() {
    Instrumentation inst = getInstrumentation();
    int firstVisiblePosition = touchScroll(inst);
    inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
    inst.waitForIdleSync();
    inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
    inst.waitForIdleSync();
    inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
    inst.waitForIdleSync();
    assertTrue("List not in trackball mode", !mListView.isInTouchMode());
    assertTrue("List did not preserve scroll position", firstVisiblePosition == mListView.getFirstVisiblePosition());
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest) 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