PauseResumeAudioRecorder { public void resumeRecording(){ if (currentAudioState.get()==PAUSED_STATE){ recordingStartTimeMillis=System.currentTimeMillis(); currentAudioState.getAndSet(RECORDING_STATE); onTimeCompletedTimer=new Timer(true); onTimeCompletionTimerTask=new MaxTimeTimerTask(); onTimeCompletedTimer.schedule(onTimeCompletionTimerTask,remainingMaxTimeInMillis); } else { Log.w(TAG,"Audio recording is not paused"); } } PauseResumeAudioRecorder(); void setOnFileSizeReachedListener(final OnFileSizeReachedListener onFileSizeReachedListener); void setMaxFileSizeInBytes(final long maxFileSizeInBytes); void setOnTimeCompletionListener(final OnTimeCompletionListener onTimeCompletionListener); void setMaxTimeInMillis(final long maxTimeInMillis); void setAudioEncoding(final int audioEncoding); void setAudioFile(final String audioFilePath); void setSampleRate(final int sampleRateInHertz); void setChannel(final int channelConfig); int getCurrentState(); void startRecording(); void pauseRecording(); void resumeRecording(); void stopRecording(); static final int STOPPED_STATE; static final int INITIALIZED_STATE; static final int PREPARED_STATE; static final int RECORDING_STATE; static final int PAUSED_STATE; static final int ERROR_STATE; }
@Test public void testResumeRecording()throws IllegalAccessException{ PauseResumeAudioRecorder pauseResumeAudioRecorder=new PauseResumeAudioRecorder(); currentAudioStateField.set(pauseResumeAudioRecorder, new AtomicInteger(PauseResumeAudioRecorder.PAUSED_STATE)); pauseResumeAudioRecorder.resumeRecording(); Assert.assertEquals("Wrong state was set", PauseResumeAudioRecorder.RECORDING_STATE, pauseResumeAudioRecorder.getCurrentState()); }