summaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-11-26 14:03:08 +0800
committerWu-cheng Li <wuchengli@google.com>2010-11-29 13:59:59 +0800
commit559f5cf9f42c4983eaef9e6e55ff3ba7c406426a (patch)
treea93bb107a8b5ca14ecce963a02ef5c452d5fb638 /tests/src
parent9b7bfbc8ac25f1df20b7ed0aa79bf1f36299e981 (diff)
downloadLegacyCamera-559f5cf9f42c4983eaef9e6e55ff3ba7c406426a.zip
LegacyCamera-559f5cf9f42c4983eaef9e6e55ff3ba7c406426a.tar.gz
LegacyCamera-559f5cf9f42c4983eaef9e6e55ff3ba7c406426a.tar.bz2
Remove the hard-coded package name in camera tests.
bug:3210567 Change-Id: I4bdc012bc39cb15459cdd6e03164be7d88e492d3
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/camera/functional/CameraTest.java16
-rwxr-xr-xtests/src/com/android/camera/power/ImageAndVideoCapture.java7
-rwxr-xr-xtests/src/com/android/camera/stress/CameraLatency.java2
-rw-r--r--tests/src/com/android/camera/stress/CameraStartUp.java10
-rwxr-xr-xtests/src/com/android/camera/stress/ImageCapture.java7
-rwxr-xr-xtests/src/com/android/camera/stress/SwitchPreview.java11
6 files changed, 28 insertions, 25 deletions
diff --git a/tests/src/com/android/camera/functional/CameraTest.java b/tests/src/com/android/camera/functional/CameraTest.java
index bf0bb64..9d71301 100644
--- a/tests/src/com/android/camera/functional/CameraTest.java
+++ b/tests/src/com/android/camera/functional/CameraTest.java
@@ -1,5 +1,8 @@
package com.android.camera.functional;
+import com.android.camera.Camera;
+import com.android.camera.VideoCamera;
+
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
@@ -16,14 +19,11 @@ import java.util.ArrayList;
public class CameraTest extends InstrumentationTestCase {
private static final String TAG = "CameraTest";
- private static final String CAMERA_PACKAGE = "com.google.android.camera";
- private static final String CAMERA_ACTIVITY = "com.android.camera.Camera";
- private static final String CAMCORDER_ACTIVITY = "com.android.camera.VideoCamera";
@LargeTest
public void testVideoCaptureIntentFdLeak() throws Exception {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- intent.setClassName(CAMERA_PACKAGE, CAMCORDER_ACTIVITY);
+ intent.setClass(getInstrumentation().getTargetContext(), VideoCamera.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file://"
+ Environment.getExternalStorageDirectory().toString()
@@ -37,15 +37,15 @@ public class CameraTest extends InstrumentationTestCase {
@LargeTest
public void testActivityLeak() throws Exception {
- checkActivityLeak(CAMERA_ACTIVITY);
- checkActivityLeak(CAMCORDER_ACTIVITY);
+ checkActivityLeak(Camera.class);
+ checkActivityLeak(VideoCamera.class);
}
- private void checkActivityLeak(String activityName) throws Exception {
+ private void checkActivityLeak(Class<?> cls) throws Exception {
final int TEST_COUNT = 5;
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName(CAMERA_PACKAGE, activityName);
+ intent.setClass(getInstrumentation().getTargetContext(), cls);
ArrayList<WeakReference<Activity>> refs =
new ArrayList<WeakReference<Activity>>();
for (int i = 0; i < TEST_COUNT; i++) {
diff --git a/tests/src/com/android/camera/power/ImageAndVideoCapture.java b/tests/src/com/android/camera/power/ImageAndVideoCapture.java
index 9892f4d..f814107 100755
--- a/tests/src/com/android/camera/power/ImageAndVideoCapture.java
+++ b/tests/src/com/android/camera/power/ImageAndVideoCapture.java
@@ -17,6 +17,7 @@
package com.android.camera.power;
import com.android.camera.Camera;
+import com.android.camera.VideoCamera;
import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
@@ -45,7 +46,7 @@ public class ImageAndVideoCapture extends ActivityInstrumentationTestCase2 <Came
private static final long WAIT_FOR_STABLE_STATE = 2000; //2 seconds
public ImageAndVideoCapture() {
- super("com.google.android.camera", Camera.class);
+ super(Camera.class);
}
@Override
@@ -97,8 +98,8 @@ public class ImageAndVideoCapture extends ActivityInstrumentationTestCase2 <Came
try {
// Switch to the video mode
Intent intent = new Intent();
- intent.setClassName("com.google.android.camera",
- "com.android.camera.VideoCamera");
+ intent.setClass(getInstrumentation().getTargetContext(),
+ VideoCamera.class);
getActivity().startActivity(intent);
for (int i = 0; i < TOTAL_NUMBER_OF_VIDEOCAPTURE; i++) {
Thread.sleep(WAIT_FOR_PREVIEW);
diff --git a/tests/src/com/android/camera/stress/CameraLatency.java b/tests/src/com/android/camera/stress/CameraLatency.java
index c4cb9ec..1d0daab 100755
--- a/tests/src/com/android/camera/stress/CameraLatency.java
+++ b/tests/src/com/android/camera/stress/CameraLatency.java
@@ -52,7 +52,7 @@ public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> {
private long mAvgJpegCallbackFinishTime;
public CameraLatency() {
- super("com.google.android.camera", Camera.class);
+ super(Camera.class);
}
@Override
diff --git a/tests/src/com/android/camera/stress/CameraStartUp.java b/tests/src/com/android/camera/stress/CameraStartUp.java
index 8aec0a9..90e3892 100644
--- a/tests/src/com/android/camera/stress/CameraStartUp.java
+++ b/tests/src/com/android/camera/stress/CameraStartUp.java
@@ -1,5 +1,8 @@
package com.android.camera.stress;
+import com.android.camera.Camera;
+import com.android.camera.VideoCamera;
+
import android.app.Activity;
import android.app.Instrumentation;
import android.content.Intent;
@@ -22,16 +25,13 @@ public class CameraStartUp extends InstrumentationTestCase {
private String TAG = "CameraStartUp";
private static final String CAMERA_TEST_OUTPUT_FILE =
Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private static final String CAMERA_PACKAGE_NAME = "com.google.android.camera";
- private static final String CAMERA_ACTIVITY_NAME = "com.android.camera.Camera";
- private static final String VIDEORECORDER_ACTIVITY_NAME = "com.android.camera.VideoCamera";
private static int WAIT_TIME_FOR_PREVIEW = 1500; //1.5 second
private long launchCamera() {
long startupTime = 0;
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClassName(CAMERA_PACKAGE_NAME, CAMERA_ACTIVITY_NAME);
+ intent.setClass(getInstrumentation().getTargetContext(), Camera.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
long beforeStart = System.currentTimeMillis();
Instrumentation inst = getInstrumentation();
@@ -53,7 +53,7 @@ public class CameraStartUp extends InstrumentationTestCase {
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClassName(CAMERA_PACKAGE_NAME, VIDEORECORDER_ACTIVITY_NAME);
+ intent.setClass(getInstrumentation().getTargetContext(), VideoCamera.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
long beforeStart = System.currentTimeMillis();
Instrumentation inst = getInstrumentation();
diff --git a/tests/src/com/android/camera/stress/ImageCapture.java b/tests/src/com/android/camera/stress/ImageCapture.java
index 0fafb9d..32500a6 100755
--- a/tests/src/com/android/camera/stress/ImageCapture.java
+++ b/tests/src/com/android/camera/stress/ImageCapture.java
@@ -17,6 +17,7 @@
package com.android.camera.stress;
import com.android.camera.Camera;
+import com.android.camera.VideoCamera;
import android.app.Instrumentation;
import android.content.Intent;
@@ -66,7 +67,7 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
private FileWriter mfstream;
public ImageCapture() {
- super("com.google.android.camera", Camera.class);
+ super(Camera.class);
}
@Override
@@ -255,8 +256,8 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
mOut.write("loop: ");
// Switch to the video mode
Intent intent = new Intent();
- intent.setClassName("com.google.android.camera",
- "com.android.camera.VideoCamera");
+ intent.setClass(getInstrumentation().getTargetContext(),
+ VideoCamera.class);
getActivity().startActivity(intent);
for (int i = 0; i < total_num_of_videos; i++) {
Thread.sleep(WAIT_FOR_PREVIEW);
diff --git a/tests/src/com/android/camera/stress/SwitchPreview.java b/tests/src/com/android/camera/stress/SwitchPreview.java
index 3c4bfaf..0ffe0ac 100755
--- a/tests/src/com/android/camera/stress/SwitchPreview.java
+++ b/tests/src/com/android/camera/stress/SwitchPreview.java
@@ -16,6 +16,7 @@
package com.android.camera.stress;
+import com.android.camera.Camera;
import com.android.camera.VideoCamera;
import android.app.Instrumentation;
@@ -49,7 +50,7 @@ public class SwitchPreview extends ActivityInstrumentationTestCase2 <VideoCamera
private FileWriter mfstream;
public SwitchPreview() {
- super("com.google.android.camera", VideoCamera.class);
+ super(VideoCamera.class);
}
@Override
@@ -96,12 +97,12 @@ public class SwitchPreview extends ActivityInstrumentationTestCase2 <VideoCamera
for (int i=0; i< TOTAL_NUMBER_OF_SWITCHING; i++) {
Thread.sleep(WAIT_FOR_PREVIEW);
Intent intent = new Intent();
- intent.setClassName("com.google.android.camera",
- "com.android.camera.VideoCamera");
+ intent.setClass(getInstrumentation().getTargetContext(),
+ VideoCamera.class);
getActivity().startActivity(intent);
Thread.sleep(WAIT_FOR_PREVIEW);
- intent.setClassName("com.google.android.camera",
- "com.android.camera.Camera");
+ intent.setClass(getInstrumentation().getTargetContext(),
+ Camera.class);
getActivity().startActivity(intent);
mOut.write(" ," + i);
mOut.flush();