PauseResumeAudioRecorder { public void setMaxFileSizeInBytes(final long maxFileSizeInBytes){ if (maxFileSizeInBytes<1000 || maxFileSizeInBytes> PcmWavConverter.MAX_SIZE_WAV_FILE_BYTES){ throw new IllegalArgumentException("Invalid max file size given"); } if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Cannot modify max file size during a non-prepared and non-initialized state"); } this.maxFileSizeInBytes=maxFileSizeInBytes; } 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 testSetMaxFileSizeInBytes()throws IllegalAccessException{ PauseResumeAudioRecorder pauseResumeAudioRecorder=new PauseResumeAudioRecorder(); pauseResumeAudioRecorder.setMaxFileSizeInBytes(2000L); Assert.assertEquals("remainingMaxTime incorrect", 2000L, (long) maxFileSizeInBytesField.get(pauseResumeAudioRecorder)); }
@Test(expected=IllegalArgumentException.class) public void testSetMaxFileSizeInBytesMin(){new PauseResumeAudioRecorder().setMaxFileSizeInBytes(999);}
@Test(expected=IllegalArgumentException.class) public void testSetMaxFileSizeInBytesMax(){new PauseResumeAudioRecorder().setMaxFileSizeInBytes(PcmWavConverter.MAX_SIZE_WAV_FILE_BYTES + 1);}
@Test(expected=IllegalStateException.class) public void testSetMaxFileSizeInBytesBadState()throws IllegalAccessException{ PauseResumeAudioRecorder pauseResumeAudioRecorder=new PauseResumeAudioRecorder(); currentAudioStateField.set(pauseResumeAudioRecorder, new AtomicInteger(PauseResumeAudioRecorder.RECORDING_STATE)); pauseResumeAudioRecorder.setMaxFileSizeInBytes(1000L); }