use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class AudioRecorderRecordingStatusHandlerTest method onIsRecordingChangedBlocked_listensToCurrentSession.
@Test
public void onIsRecordingChangedBlocked_listensToCurrentSession() {
MutableLiveData<RecordingSession> liveData = new MutableLiveData<>(null);
when(audioRecorder.getCurrentSession()).thenReturn(liveData);
Consumer<Boolean> listener = mock(Consumer.class);
provider.onBlockedStatusChange(listener);
verify(listener).accept(false);
liveData.setValue(new RecordingSession("blah", null, 0, 0, false));
verify(listener).accept(true);
}
use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class RecordingHandlerTest method whenBackgroundRecordingM4A_andRecordingAlreadySavedForReference_appendsAudioFiles.
@Test
public void whenBackgroundRecordingM4A_andRecordingAlreadySavedForReference_appendsAudioFiles() throws Exception {
File recording = File.createTempFile("existing", ".m4a");
File existingRecording = questionMediaManager.createAnswerFile(recording).getValue().getOrNull();
assertThat(existingRecording, not(nullValue()));
TreeReference treeReference = new TreeReference();
when(formController.getAnswer(treeReference)).thenReturn(new StringData(existingRecording.getName()));
File newRecording = File.createTempFile("new", ".m4a");
RecordingSession recordingSession = new RecordingSession(new HashSet<TreeReference>() {
{
add(treeReference);
}
}, newRecording, 0, 0, false);
recordingHandler.handle(formController, recordingSession, success -> {
});
verify(m4aAppender).append(existingRecording, questionMediaManager.getAnswerFile(newRecording.getName()));
}
use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class RecordingHandlerTest method whenBackgroundRecording_andRecordingAlreadySavedForReference_deletesNewFile.
@Test
public void whenBackgroundRecording_andRecordingAlreadySavedForReference_deletesNewFile() throws Exception {
File recording = File.createTempFile("existing", ".m4a");
File existingRecording = questionMediaManager.createAnswerFile(recording).getValue().getOrNull();
assertThat(existingRecording, not(nullValue()));
TreeReference treeReference = new TreeReference();
when(formController.getAnswer(treeReference)).thenReturn(new StringData(existingRecording.getName()));
File newRecording = File.createTempFile("new", ".m4a");
RecordingSession recordingSession = new RecordingSession(new HashSet<TreeReference>() {
{
add(treeReference);
}
}, newRecording, 0, 0, false);
recordingHandler.handle(formController, recordingSession, success -> {
});
assertThat(questionMediaManager.getAnswerFile(newRecording.getName()).exists(), is(false));
}
use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class RecordingHandlerTest method whenBackgroundRecordinAMR_andRecordingAlreadySavedForReference_appendsAudioFiles.
@Test
public void whenBackgroundRecordinAMR_andRecordingAlreadySavedForReference_appendsAudioFiles() throws Exception {
File recording = File.createTempFile("existing", ".amr");
File existingRecording = questionMediaManager.createAnswerFile(recording).getValue().getOrNull();
assertThat(existingRecording, not(nullValue()));
TreeReference treeReference = new TreeReference();
when(formController.getAnswer(treeReference)).thenReturn(new StringData(existingRecording.getName()));
File newRecording = File.createTempFile("new", ".amr");
RecordingSession recordingSession = new RecordingSession(new HashSet<TreeReference>() {
{
add(treeReference);
}
}, newRecording, 0, 0, false);
recordingHandler.handle(formController, recordingSession, success -> {
});
verify(amrAppender).append(existingRecording, questionMediaManager.getAnswerFile(newRecording.getName()));
}
use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class AudioRecorderRecordingStatusHandlerTest method whenViewModelSessionUpdates_callsInProgressListener.
@Test
public void whenViewModelSessionUpdates_callsInProgressListener() {
FormEntryPrompt prompt = promptWithAnswer(null);
MutableLiveData<RecordingSession> sessionLiveData = new MutableLiveData<>(null);
when(audioRecorder.getCurrentSession()).thenReturn(sessionLiveData);
Consumer<Pair<Long, Integer>> listener = mock(Consumer.class);
provider.onRecordingStatusChange(prompt, listener);
verify(listener).accept(null);
sessionLiveData.setValue(new RecordingSession(prompt.getIndex(), null, 1200L, 25, false));
verify(listener).accept(new Pair<>(1200L, 25));
}
Aggregations