summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/camera/functional
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-03-15 16:29:00 +0800
committerWu-cheng Li <wuchengli@google.com>2011-03-15 17:19:14 +0800
commit5df067af93e6b386167f11cdf12701b7905ee444 (patch)
tree6a8c6bf8a457ef2a4406f5354edadcca20e46506 /tests/src/com/android/camera/functional
parentc9713f275106d2125867e4c0ef3c20d2fdf66022 (diff)
downloadLegacyCamera-5df067af93e6b386167f11cdf12701b7905ee444.zip
LegacyCamera-5df067af93e6b386167f11cdf12701b7905ee444.tar.gz
LegacyCamera-5df067af93e6b386167f11cdf12701b7905ee444.tar.bz2
Add image capture intent test.
Change-Id: Iba7ecf9054b630a14f1bf24ba223e0eecb1c3fd4
Diffstat (limited to 'tests/src/com/android/camera/functional')
-rw-r--r--tests/src/com/android/camera/functional/CameraTest.java33
1 files changed, 33 insertions, 0 deletions
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);
+ }
}