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);
}
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();
}
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);
}
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;
}
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();
}
Aggregations