Search in sources :

Example 36 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 37 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 38 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 39 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 40 with Instrumentation

use of android.app.Instrumentation in project cucumber-jvm by cucumber.

the class CucumberActivitySteps method before.

@Before
public void before() {
    assertEquals(0, steps);
    Instrumentation instrumentation = getInstrumentation();
    assertNotNull(instrumentation);
    assertNotNull(getActivity());
    String testPackageName = instrumentation.getContext().getPackageName();
    String targetPackageName = instrumentation.getContext().getPackageName();
    assertEquals(testPackageName, targetPackageName);
}
Also used : Instrumentation(android.app.Instrumentation) Before(cucumber.api.java.Before)

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