blob: e5ecd5cde2eed34e028070381449052d74645f85 [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;
47 public static int mDuration = 10000;
48
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049 @Override
50 public TestSuite getAllTests() {
51 TestSuite suite = new InstrumentationTestSuite(this);
52 suite.addTestSuite(MediaRecorderStressTest.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 return suite;
54 }
55
56 @Override
57 public ClassLoader getLoader() {
58 return MediaRecorderStressTestRunner.class.getClassLoader();
59 }
Yu Shan Emily Lau48584d72010-05-25 14:13:10 -070060
61 @Override
62 public void onCreate(Bundle icicle) {
63 super.onCreate(icicle);
64 String iterations = (String) icicle.get("iterations");
65 String video_encoder = (String) icicle.get("video_encoder");
66 String audio_encoder = (String) icicle.get("audio_encoder");
67 String frame_rate = (String) icicle.get("frame_rate");
68 String video_width = (String) icicle.get("video_width");
69 String video_height = (String) icicle.get("video_height");
70 String bit_rate = (String) icicle.get("bit_rate");
71 String record_duration = (String) icicle.get("record_duration");
72 String remove_videos = (String) icicle.get("remove_videos");
73
74 if (iterations != null ) {
75 mIterations = Integer.parseInt(iterations);
76 }
77 if ( video_encoder != null) {
78 mVideoEncoder = Integer.parseInt(video_encoder);
79 }
80 if ( audio_encoder != null) {
81 mAudioEncdoer = Integer.parseInt(audio_encoder);
82 }
83 if (frame_rate != null) {
84 mFrameRate = Integer.parseInt(frame_rate);
85 }
86 if (video_width != null) {
87 mVideoWidth = Integer.parseInt(video_width);
88 }
89 if (video_height != null) {
90 mVideoHeight = Integer.parseInt(video_height);
91 }
92 if (bit_rate != null) {
93 mBitRate = Integer.parseInt(bit_rate);
94 }
95 if (record_duration != null) {
96 mDuration = Integer.parseInt(record_duration);
97 }
98 if (remove_videos != null) {
99 if (remove_videos.compareTo("true") == 0) {
100 mRemoveVideo = true;
101 } else {
102 mRemoveVideo = false;
103 }
104 }
105 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106}