MediaRecorderSetOutputFileStateUnitTest.java revision f013e1afd1e68af5e3b868c26a653bbfb39538f8
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 17package com.android.mediaframeworktest.unit; 18 19import android.media.MediaRecorder; 20import android.test.AndroidTestCase; 21import android.test.suitebuilder.annotation.MediumTest; 22import android.test.suitebuilder.annotation.Suppress; 23 24/** 25 * Unit test class to test the set of valid and invalid states that 26 * MediaRecorder.setOutputFile() method can be called. 27 */ 28public class MediaRecorderSetOutputFileStateUnitTest extends AndroidTestCase implements MediaRecorderMethodUnderTest { 29 private MediaRecorderStateUnitTestTemplate mTestTemplate = new MediaRecorderStateUnitTestTemplate(); 30 /** 31 * 1. It is valid to call setOutputFile() in the following states: 32 * {DataSourceConfigured}. 33 * 2. It is invalid to call setOutputFile() in the following states: 34 * {Initial, Initialized, Prepared, Recording, Error} 35 * 36 * @param stateErrors the MediaRecorderStateErrors to check against. 37 */ 38 public void checkStateErrors(MediaRecorderStateErrors stateErrors) { 39 // Valid states. 40 assertTrue(!stateErrors.errorInDataSourceConfiguredState); 41 42 // Invalid states. 43 assertTrue(stateErrors.errorInPreparedState); 44 assertTrue(stateErrors.errorInRecordingState); 45 assertTrue(stateErrors.errorInErrorState); 46 assertTrue(stateErrors.errorInInitialState); 47 assertTrue(stateErrors.errorInInitialStateAfterReset); 48 assertTrue(stateErrors.errorInInitialStateAfterStop); 49 assertTrue(stateErrors.errorInInitializedState); 50 } 51 52 public void invokeMethodUnderTest(MediaRecorder recorder) { 53 recorder.setOutputFile(MediaRecorderStateUnitTestTemplate.RECORD_OUTPUT_PATH); 54 } 55 56 //TODO(elaurent) 57 //reactivate the test until bug#1495237 fix 58 @Suppress 59 @MediumTest 60 public void testSetOutputFile() { 61 mTestTemplate.runTestOnMethod(this); 62 } 63 64 @Override 65 public String toString() { 66 return "setOutputFile()"; 67 } 68} 69