summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYu Shan Emily Lau <yslau@google.com>2010-07-19 17:05:09 -0700
committerYu Shan Emily Lau <yslau@google.com>2010-07-20 15:17:35 -0700
commite4b210af3f11ecb3e1556a2edc95bc06119bcecb (patch)
tree4d5f84c2fd00e091ff9b7cce1a2f76a30660d531 /tests
parentb13acb76f5b86f46dfe07830648ec14524e83d39 (diff)
downloadLegacyCamera-e4b210af3f11ecb3e1556a2edc95bc06119bcecb.zip
LegacyCamera-e4b210af3f11ecb3e1556a2edc95bc06119bcecb.tar.gz
LegacyCamera-e4b210af3f11ecb3e1556a2edc95bc06119bcecb.tar.bz2
Expose the camera stress test parameters.
Change-Id: Iff20081e8e49da744f4ee36925167bbeb6a2a87c
Diffstat (limited to 'tests')
-rw-r--r--tests/AndroidManifest.xml5
-rwxr-xr-xtests/src/com/android/camera/CameraStressTestRunner.java62
-rwxr-xr-xtests/src/com/android/camera/stress/ImageCapture.java26
3 files changed, 83 insertions, 10 deletions
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index d31bb6a..7a0e9a8 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -26,6 +26,11 @@
android:label="Camera Launch Performance">
</instrumentation>
+ <instrumentation android:name="com.android.camera.stress.CameraStressTestRunner"
+ android:targetPackage="com.android.camera"
+ android:label="Camera stress test runner">
+ </instrumentation>
+
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.android.camera"
android:label="Tests for Camera application."/>
diff --git a/tests/src/com/android/camera/CameraStressTestRunner.java b/tests/src/com/android/camera/CameraStressTestRunner.java
new file mode 100755
index 0000000..5c61c9b
--- /dev/null
+++ b/tests/src/com/android/camera/CameraStressTestRunner.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.stress;
+
+
+import android.os.Bundle;
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+import android.util.Log;
+import junit.framework.TestSuite;
+
+public class CameraStressTestRunner extends InstrumentationTestRunner {
+
+ // Default recorder settings
+ public static int mVideoDuration = 20000; // set default to 20 seconds
+ public static int mVideoIterations = 100; // set default to 100 videos
+ public static int mImageIterations = 100; // set default to 100 images
+
+ @Override
+ public TestSuite getAllTests() {
+ TestSuite suite = new InstrumentationTestSuite(this);
+ suite.addTestSuite(ImageCapture.class);
+ return suite;
+ }
+
+ @Override
+ public ClassLoader getLoader() {
+ return CameraStressTestRunner.class.getClassLoader();
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ String video_iterations = (String) icicle.get("video_iterations");
+ String image_iterations = (String) icicle.get("image_iterations");
+ String video_duration = (String) icicle.get("video_duration");
+
+ if ( video_iterations != null ) {
+ mVideoIterations = Integer.parseInt(video_iterations);
+ }
+ if ( image_iterations != null) {
+ mImageIterations = Integer.parseInt(image_iterations);
+ }
+ if ( video_duration != null) {
+ mVideoDuration = Integer.parseInt(video_duration);
+ }
+ }
+}
diff --git a/tests/src/com/android/camera/stress/ImageCapture.java b/tests/src/com/android/camera/stress/ImageCapture.java
index 8c20d37..42a7b54 100755
--- a/tests/src/com/android/camera/stress/ImageCapture.java
+++ b/tests/src/com/android/camera/stress/ImageCapture.java
@@ -53,8 +53,8 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
private static final long WAIT_FOR_PREVIEW = 1500; //1.5 seconds
private static final long WAIT_FOR_STABLE_STATE = 2000; //2 seconds
private static final int NO_OF_LOOPS_TAKE_MEMORY_SNAPSHOT = 10;
- private static final String CAMERA_MEM_OUTPUTFILE =
- Environment.getExternalStorageDirectory().toString() + "/ImageCaptureMemOut.txt";
+ private static final String CAMERA_MEM_OUTPUTFILE =
+ Environment.getExternalStorageDirectory().toString() + "/ImageCaptureMemOut.txt";
//the tolerant memory leak
private static final int MAX_ACCEPTED_MEMORY_LEAK_KB = 150;
@@ -64,7 +64,8 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
private static int mStartPid = 0;
private static int mEndPid = 0;
- private static final String CAMERA_TEST_OUTPUT_FILE = "/sdcard/mediaStressOut.txt";
+ private static final String CAMERA_TEST_OUTPUT_FILE =
+ Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
private BufferedWriter mOut;
private FileWriter mfstream;
@@ -181,6 +182,8 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
@LargeTest
public void testImageCapture() {
+ int total_num_of_images = CameraStressTestRunner.mImageIterations;
+
//TODO(yslau): Need to integrate the outoput with the central dashboard,
//write to a txt file as a temp solution
boolean memoryResult = false;
@@ -193,14 +196,14 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
try {
Writer output = new BufferedWriter(new FileWriter(imageCaptureMemFile, true));
output.write("Camera Image capture\n");
- output.write("No of loops : " + TOTAL_NUMBER_OF_VIDEOCAPTURE + "\n");
+ output.write("No of loops : " + total_num_of_images + "\n");
getMemoryWriteToLog(output);
mOut.write("Camera Image Capture\n");
- mOut.write("No of loops :" + TOTAL_NUMBER_OF_VIDEOCAPTURE + "\n");
+ mOut.write("No of loops :" + total_num_of_images + "\n");
mOut.write("loop: ");
- for (int i = 0; i < TOTAL_NUMBER_OF_IMAGECAPTURE; i++) {
+ for (int i = 0; i < total_num_of_images; i++) {
Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
@@ -237,6 +240,9 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
//TODO(yslau): Need to integrate the output with the central dashboard,
//write to a txt file as a temp solution
boolean memoryResult = false;
+ int total_num_of_videos = CameraStressTestRunner.mVideoIterations;
+ int video_duration = CameraStressTestRunner.mVideoDuration;
+
Instrumentation inst = getInstrumentation();
File imageCaptureMemFile = new File(CAMERA_MEM_OUTPUTFILE);
mStartPid = getMediaserverPid();
@@ -246,21 +252,21 @@ public class ImageCapture extends ActivityInstrumentationTestCase2 <Camera> {
try {
Writer output = new BufferedWriter(new FileWriter(imageCaptureMemFile, true));
output.write("Camera Video capture\n");
- output.write("No of loops : " + TOTAL_NUMBER_OF_VIDEOCAPTURE + "\n");
+ output.write("No of loops : " + total_num_of_videos + "\n");
getMemoryWriteToLog(output);
mOut.write("Camera Video Capture\n");
- mOut.write("No of loops :" + TOTAL_NUMBER_OF_VIDEOCAPTURE + "\n");
+ mOut.write("No of loops :" + total_num_of_videos + "\n");
mOut.write("loop: ");
// Switch to the video mode
Intent intent = new Intent();
intent.setClassName("com.google.android.camera",
"com.android.camera.VideoCamera");
getActivity().startActivity(intent);
- for (int i = 0; i < TOTAL_NUMBER_OF_VIDEOCAPTURE; i++) {
+ for (int i = 0; i < total_num_of_videos; i++) {
Thread.sleep(WAIT_FOR_PREVIEW);
// record a video
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- Thread.sleep(WAIT_FOR_VIDEO_CAPTURE_TO_BE_TAKEN);
+ Thread.sleep(video_duration);
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
Thread.sleep(WAIT_FOR_PREVIEW);
mOut.write(" ," + i);