blob: 95e7b5e0b61fcbd504c4c91e2825508d49a35c6e [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.mediaframeworktest;
18
James Dongc9b9cbc2011-08-15 17:12:55 -070019import android.media.CamcorderProfile;
Yu Shan Emily Lau48584d72010-05-25 14:13:10 -070020import android.media.MediaRecorder;
21import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.test.InstrumentationTestRunner;
23import android.test.InstrumentationTestSuite;
Yu Shan Emily Lau5d386a12011-02-07 21:18:00 -080024import com.android.mediaframeworktest.stress.MediaRecorderStressTest;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025
Yu Shan Emily Lau55c1ad92011-08-01 23:52:47 -070026import java.util.List;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import junit.framework.TestSuite;
28
29public class MediaRecorderStressTestRunner extends InstrumentationTestRunner {
30
James Dongc9b9cbc2011-08-15 17:12:55 -070031 // MediaRecorder stress test sets one of the cameras as the video source. As
32 // a result, we should make sure that the encoding parameters as input to
33 // the test must be supported by the corresponding camera.
34 public static int mCameraId = 0;
35 public static int mProfileQuality = CamcorderProfile.QUALITY_HIGH;
36 public static CamcorderProfile profile =
37 CamcorderProfile.get(mCameraId, mProfileQuality);
Yu Shan Emily Lau55c1ad92011-08-01 23:52:47 -070038
Yu Shan Emily Lau48584d72010-05-25 14:13:10 -070039 public static int mIterations = 100;
James Dongc9b9cbc2011-08-15 17:12:55 -070040 public static int mVideoEncoder = profile.videoCodec;
41 public static int mAudioEncdoer = profile.audioCodec;
42 public static int mFrameRate = profile.videoFrameRate;
43 public static int mVideoWidth = profile.videoFrameWidth;
44 public static int mVideoHeight = profile.videoFrameHeight;
45 public static int mBitRate = profile.videoBitRate;
Yu Shan Emily Lau48584d72010-05-25 14:13:10 -070046 public static boolean mRemoveVideo = true;
Jason Noguchi27c8d9b2012-02-17 15:23:00 -080047 public static int mDuration = 10 * 1000; // 10 seconds
48 public static int mTimeLapseDuration = 180 * 1000; // 3 minutes
49 public static double mCaptureRate = 0.5; // 2 sec timelapse interval
Yu Shan Emily Lau48584d72010-05-25 14:13:10 -070050
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 @Override
52 public TestSuite getAllTests() {
53 TestSuite suite = new InstrumentationTestSuite(this);
54 suite.addTestSuite(MediaRecorderStressTest.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 return suite;
56 }
57
58 @Override
59 public ClassLoader getLoader() {
60 return MediaRecorderStressTestRunner.class.getClassLoader();
61 }
Yu Shan Emily Lau48584d72010-05-25 14:13:10 -070062
63 @Override
64 public void onCreate(Bundle icicle) {
65 super.onCreate(icicle);
66 String iterations = (String) icicle.get("iterations");
67 String video_encoder = (String) icicle.get("video_encoder");
68 String audio_encoder = (String) icicle.get("audio_encoder");
69 String frame_rate = (String) icicle.get("frame_rate");
70 String video_width = (String) icicle.get("video_width");
71 String video_height = (String) icicle.get("video_height");
72 String bit_rate = (String) icicle.get("bit_rate");
73 String record_duration = (String) icicle.get("record_duration");
74 String remove_videos = (String) icicle.get("remove_videos");
75
76 if (iterations != null ) {
77 mIterations = Integer.parseInt(iterations);
78 }
79 if ( video_encoder != null) {
80 mVideoEncoder = Integer.parseInt(video_encoder);
81 }
82 if ( audio_encoder != null) {
83 mAudioEncdoer = Integer.parseInt(audio_encoder);
84 }
85 if (frame_rate != null) {
86 mFrameRate = Integer.parseInt(frame_rate);
87 }
88 if (video_width != null) {
89 mVideoWidth = Integer.parseInt(video_width);
90 }
91 if (video_height != null) {
92 mVideoHeight = Integer.parseInt(video_height);
93 }
94 if (bit_rate != null) {
95 mBitRate = Integer.parseInt(bit_rate);
96 }
97 if (record_duration != null) {
98 mDuration = Integer.parseInt(record_duration);
99 }
100 if (remove_videos != null) {
101 if (remove_videos.compareTo("true") == 0) {
102 mRemoveVideo = true;
103 } else {
104 mRemoveVideo = false;
105 }
106 }
107 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108}