use of org.odk.collect.settings.SettingsProvider 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.settings.SettingsProvider 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;
}
});
}
Aggregations