FileDocCategorySizeDatePackage
MediaRecorderStopStateUnitTest.javaAPI DocAndroid 5.1 API2908Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest.unit

MediaRecorderStopStateUnitTest

public class MediaRecorderStopStateUnitTest extends android.test.AndroidTestCase implements MediaRecorderMethodUnderTest
Unit test class to test the set of valid and invalid states that MediaRecorder.stop() method can be called.

Fields Summary
private MediaRecorderStateUnitTestTemplate
mTestTemplate
private static final String
TAG
private static final int
SLEEP_TIME_BEFORE_STOP
Constructors Summary
Methods Summary
public voidcheckStateErrors(MediaRecorderStateErrors stateErrors)
1. It is valid to call stop() in the following states: {Recording}. 2. It is invalid to call stop() in the following states: {Initial, Initialized, DataSourceConfigured, Prepared, Error}

param
stateErrors the MediaRecorderStateErrors to check against.


                                                      
        
        // Valid states.
        assertTrue(!stateErrors.errorInRecordingState);
        
        // Invalid states.
        assertTrue(stateErrors.errorInInitialState);
        assertTrue(stateErrors.errorInInitialStateAfterReset);
        assertTrue(stateErrors.errorInInitialStateAfterStop);
        assertTrue(stateErrors.errorInInitializedState);
        assertTrue(stateErrors.errorInErrorState);
        assertTrue(stateErrors.errorInDataSourceConfiguredState);
        assertTrue(stateErrors.errorInPreparedState);
    
public voidinvokeMethodUnderTest(android.media.MediaRecorder recorder)

        // Wait for some time before stopping the media recorder.
        // This will fix the assertion caused by stopping it immediatedly
        // after it is started
        try {
            Thread.sleep(SLEEP_TIME_BEFORE_STOP);
        } catch(Exception e) {
            Log.v(TAG, "sleep was interrupted and terminated prematurely");
        }

        recorder.stop();
    
public voidtestStop()

        mTestTemplate.runTestOnMethod(this);
    
public java.lang.StringtoString()

        return "stop()";