Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 627f445a authored by Gloria Wang's avatar Gloria Wang
Browse files

Wait for some time before stopping the media recorder.

Fix for bug 5239001.

Change-Id: Ifa18a404e8568cced88a93b8d1a7125875aadb15
parent 1c6ac4eb
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.media.MediaRecorder;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;

/**
 * Unit test class to test the set of valid and invalid states that
@@ -27,6 +28,8 @@ import android.test.suitebuilder.annotation.Suppress;
 */          
public class MediaRecorderStopStateUnitTest extends AndroidTestCase implements MediaRecorderMethodUnderTest {
    private MediaRecorderStateUnitTestTemplate mTestTemplate = new MediaRecorderStateUnitTestTemplate();
    private static final String TAG = "MediaRecorderStopStateUnitTest";
    private static final int SLEEP_TIME_BEFORE_STOP = 1000;

    /**
     * 1. It is valid to call stop() in the following states:
@@ -51,6 +54,15 @@ public class MediaRecorderStopStateUnitTest extends AndroidTestCase implements M
    }

    public void invokeMethodUnderTest(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();
    }