use of org.odk.collect.audiorecorder.recording.AudioRecorder in project collect by opendatakit.
the class FormEntryMenuDelegateTest method setup.
@Before
public void setup() {
activity = RobolectricHelpers.createThemedActivity(AppCompatActivity.class, R.style.Theme_MaterialComponents);
FormController formController = mock(FormController.class);
answersProvider = mock(AnswersProvider.class);
formSaveViewModel = mock(FormSaveViewModel.class);
audioRecorder = mock(AudioRecorder.class);
when(audioRecorder.isRecording()).thenReturn(false);
formEntryViewModel = mock(FormEntryViewModel.class);
when(formEntryViewModel.hasBackgroundRecording()).thenReturn(new MutableNonNullLiveData<>(false));
BackgroundLocationViewModel backgroundLocationViewModel = mock(BackgroundLocationViewModel.class);
backgroundAudioViewModel = mock(BackgroundAudioViewModel.class);
when(backgroundAudioViewModel.isBackgroundRecordingEnabled()).thenReturn(new MutableNonNullLiveData<>(true));
formEntryMenuDelegate = new FormEntryMenuDelegate(activity, answersProvider, mock(FormIndexAnimationHandler.class), formSaveViewModel, formEntryViewModel, audioRecorder, backgroundLocationViewModel, backgroundAudioViewModel, TestSettingsProvider.getSettingsProvider());
formEntryMenuDelegate.formLoaded(formController);
}
use of org.odk.collect.audiorecorder.recording.AudioRecorder in project collect by opendatakit.
the class FormSaveViewModelTest method setup.
@Before
public void setup() {
// Useful given some methods will execute AsyncTasks
Robolectric.getBackgroundThreadScheduler().pause();
formController = mock(FormController.class);
logger = mock(AuditEventLogger.class);
mediaUtils = mock(MediaUtils.class);
Analytics analytics = mock(Analytics.class);
when(formController.getAuditEventLogger()).thenReturn(logger);
when(logger.isChangeReasonRequired()).thenReturn(false);
audioRecorder = mock(AudioRecorder.class);
currentProjectProvider = mock(CurrentProjectProvider.class);
when(currentProjectProvider.getCurrentProject()).thenReturn(Project.Companion.getDEMO_PROJECT());
viewModel = new FormSaveViewModel(savedStateHandle, () -> CURRENT_TIME, formSaver, mediaUtils, analytics, scheduler, audioRecorder, currentProjectProvider);
viewModel.formLoaded(formController);
}
use of org.odk.collect.audiorecorder.recording.AudioRecorder in project collect by opendatakit.
the class BackgroundAudioPermissionDialogFragmentTest method setup.
@Before
public void setup() {
backgroundAudioViewModel = mock(BackgroundAudioViewModel.class);
fakePermissionsProvider = new FakePermissionsProvider();
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public BackgroundAudioViewModel.Factory providesBackgroundAudioViewModelFactory(AudioRecorder audioRecorder, SettingsProvider settingsProvider, PermissionsChecker permissionsChecker, Analytics analytics) {
return new BackgroundAudioViewModel.Factory(audioRecorder, settingsProvider.getUnprotectedSettings(), permissionsChecker, System::currentTimeMillis) {
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) backgroundAudioViewModel;
}
};
}
@Override
public PermissionsProvider providesPermissionsProvider(PermissionsChecker permissionsChecker) {
return fakePermissionsProvider;
}
});
}
use of org.odk.collect.audiorecorder.recording.AudioRecorder in project collect by opendatakit.
the class AudioRecordingControllerFragmentTest method setup.
@Before
public void setup() throws IOException {
File stubRecording = File.createTempFile("test", ".m4a");
stubRecording.deleteOnExit();
audioRecorder = new StubAudioRecorder(stubRecording.getAbsolutePath());
backgroundAudioViewModel = mock(BackgroundAudioViewModel.class);
formEntryViewModel = mock(FormEntryViewModel.class);
hasBackgroundRecording = new MutableNonNullLiveData<>(false);
when(formEntryViewModel.hasBackgroundRecording()).thenReturn(hasBackgroundRecording);
isBackgroundRecordingEnabled = new MutableNonNullLiveData<>(false);
when(backgroundAudioViewModel.isBackgroundRecordingEnabled()).thenReturn(isBackgroundRecordingEnabled);
externalWebPageHelper = mock(ExternalWebPageHelper.class);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public BackgroundAudioViewModel.Factory providesBackgroundAudioViewModelFactory(AudioRecorder audioRecorder, SettingsProvider settingsProvider, PermissionsChecker permissionsChecker, Analytics analytics) {
return new BackgroundAudioViewModel.Factory(audioRecorder, settingsProvider.getUnprotectedSettings(), permissionsChecker, System::currentTimeMillis) {
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) backgroundAudioViewModel;
}
};
}
@Override
public FormEntryViewModel.Factory providesFormEntryViewModelFactory(Analytics analytics) {
return new FormEntryViewModel.Factory(System::currentTimeMillis) {
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) formEntryViewModel;
}
};
}
@Override
public AudioRecorder providesAudioRecorder(Application application) {
return audioRecorder;
}
@Override
public ExternalWebPageHelper providesExternalWebPageHelper() {
return externalWebPageHelper;
}
});
}
use of org.odk.collect.audiorecorder.recording.AudioRecorder in project collect by opendatakit.
the class AudioRecordingFormErrorDialogFragmentTest method setup.
@Before
public void setup() throws Exception {
File stubRecording = File.createTempFile("test", ".m4a");
stubRecording.deleteOnExit();
audioRecorder = new StubAudioRecorder(stubRecording.getAbsolutePath());
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public AudioRecorder providesAudioRecorder(Application application) {
return audioRecorder;
}
});
}
Aggregations