From 5df067af93e6b386167f11cdf12701b7905ee444 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Tue, 15 Mar 2011 16:29:00 +0800 Subject: Add image capture intent test. Change-Id: Iba7ecf9054b630a14f1bf24ba223e0eecb1c3fd4 --- .../com/android/camera/functional/CameraTest.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/src/com/android/camera/functional/CameraTest.java b/tests/src/com/android/camera/functional/CameraTest.java index 9d71301..8f47e70 100644 --- a/tests/src/com/android/camera/functional/CameraTest.java +++ b/tests/src/com/android/camera/functional/CameraTest.java @@ -1,10 +1,13 @@ package com.android.camera.functional; import com.android.camera.Camera; +import com.android.camera.R; import com.android.camera.VideoCamera; import android.app.Activity; +import android.app.Instrumentation; import android.content.Intent; +import android.graphics.Bitmap; import android.net.Uri; import android.os.Environment; import android.os.Process; @@ -12,6 +15,7 @@ import android.provider.MediaStore; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; +import android.view.KeyEvent; import java.io.File; import java.lang.ref.WeakReference; @@ -65,4 +69,33 @@ public class CameraTest extends InstrumentationTestCase { // If applications are leaking activity, every reference is reachable. assertTrue(refCount != TEST_COUNT); } + + @LargeTest + public void testImageCaptureIntent() throws Exception { + Instrumentation inst = getInstrumentation(); + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + final Camera activity = (Camera) launchActivityWithIntent( + inst.getTargetContext().getPackageName(), Camera.class, + intent); + + // Take a picture + inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS)); + inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA); + Thread.sleep(4000); + + // Press done button. + inst.runOnMainSync(new Runnable() { + public void run() { + activity.findViewById(R.id.btn_done).performClick(); + } + }); + + assertTrue(activity.isFinishing()); + assertEquals(Activity.RESULT_OK, activity.getResultCode()); + Intent resultData = activity.getResultData(); + Bitmap bitmap = (Bitmap) resultData.getParcelableExtra("data"); + assertNotNull(bitmap); + assertTrue(bitmap.getWidth() > 0); + assertTrue(bitmap.getHeight() > 0); + } } -- cgit v1.1