MediaRecorderStressTestRunner.java revision c9b9cbc76e22615886bf91596badef7f4a3d32a5
1/*
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
19import android.media.CamcorderProfile;
20import android.media.MediaRecorder;
21import android.os.Bundle;
22import android.test.InstrumentationTestRunner;
23import android.test.InstrumentationTestSuite;
24import com.android.mediaframeworktest.stress.MediaRecorderStressTest;
25
26import java.util.List;
27import junit.framework.TestSuite;
28
29public class MediaRecorderStressTestRunner extends InstrumentationTestRunner {
30
31    // 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);
38
39    public static int mIterations = 100;
40    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;
46    public static boolean mRemoveVideo = true;
47    public static int mDuration = 10000;
48
49    @Override
50    public TestSuite getAllTests() {
51        TestSuite suite = new InstrumentationTestSuite(this);
52        suite.addTestSuite(MediaRecorderStressTest.class);
53        return suite;
54    }
55
56    @Override
57    public ClassLoader getLoader() {
58        return MediaRecorderStressTestRunner.class.getClassLoader();
59    }
60
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    }
106}
107