OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / media / tests / MediaFrameworkTest / src / com / android / mediaframeworktest / unit / MediaRecorderSetAudioEncoderStateUnitTest.java
1 /*
2  * Copyright (C) 2008 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
17 package com.android.mediaframeworktest.unit;
18
19 import android.media.MediaRecorder;
20 import android.test.AndroidTestCase;
21 import android.test.suitebuilder.annotation.MediumTest;
22 import android.test.suitebuilder.annotation.Suppress;
23
24 /**
25  * Unit test class to test the set of valid and invalid states that
26  * MediaRecorder.setAudioEncoder() method can be called.
27  */
28 public class MediaRecorderSetAudioEncoderStateUnitTest extends AndroidTestCase implements MediaRecorderMethodUnderTest {
29     private MediaRecorderStateUnitTestTemplate mTestTemplate = new MediaRecorderStateUnitTestTemplate();
30     
31     /**
32      * 1. It is valid to call setAudioEncoder() in the following states:
33      *    {DataSourceConfigured}.
34      * 2. It is invalid to call setAudioEncoder() in the following states:
35      *    {Initial, Initialized, Prepared, Recording, Error}
36      *    
37      * @param stateErrors the MediaRecorderStateErrors to check against.
38      */
39     public void checkStateErrors(MediaRecorderStateErrors stateErrors) {
40         // Valid states.
41         assertTrue(!stateErrors.errorInDataSourceConfiguredState);
42         
43         // Invalid states.
44         assertTrue(stateErrors.errorInPreparedState);
45         assertTrue(stateErrors.errorInRecordingState);
46         assertTrue(stateErrors.errorInErrorState);
47         assertTrue(stateErrors.errorInInitialState);
48         assertTrue(stateErrors.errorInInitialStateAfterReset);
49         assertTrue(stateErrors.errorInInitialStateAfterStop);
50         assertTrue(stateErrors.errorInInitializedState);
51     }
52
53     public void invokeMethodUnderTest(MediaRecorder recorder) {
54         recorder.setAudioEncoder(MediaRecorderStateUnitTestTemplate.AUDIO_ENCODER);
55     }
56
57     @MediumTest
58     public void testSetAudioEncoder() {
59         mTestTemplate.runTestOnMethod(this);
60     }
61     
62     @Override
63     public String toString() {
64         return "setAudioEncoder()";
65     }
66 }