use of org.odk.collect.android.utilities.MediaUtils in project collect by opendatakit.
the class ExImageWidgetTest method setup.
@Before
public void setup() {
mediaUtils = mock(MediaUtils.class);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public MediaUtils providesMediaUtils(IntentLauncher intentLauncher) {
return mediaUtils;
}
});
when(mediaUtils.isImageFile(any())).thenReturn(true);
}
use of org.odk.collect.android.utilities.MediaUtils in project collect by opendatakit.
the class VideoWidgetTest method buttonsShouldLaunchCorrectIntents.
@Test
public void buttonsShouldLaunchCorrectIntents() {
MediaUtils mediaUtils = mock(MediaUtils.class);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public MediaUtils providesMediaUtils(IntentLauncher intentLauncher) {
return mediaUtils;
}
});
stubAllRuntimePermissionsGranted(true);
Intent intent = getIntentLaunchedByClick(R.id.capture_video);
assertActionEquals(MediaStore.ACTION_VIDEO_CAPTURE, intent);
intent = getIntentLaunchedByClick(R.id.choose_video);
assertActionEquals(Intent.ACTION_GET_CONTENT, intent);
assertTypeEquals("video/*", intent);
getIntentLaunchedByClick(R.id.play_video);
verify(mediaUtils).openFile(any(), any(), any());
}
use of org.odk.collect.android.utilities.MediaUtils in project collect by opendatakit.
the class ArbitraryFileWidgetTest method setup.
@Before
public void setup() {
mediaUtils = mock(MediaUtils.class);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public MediaUtils providesMediaUtils(IntentLauncher intentLauncher) {
return mediaUtils;
}
});
when(mediaUtils.isAudioFile(any())).thenReturn(true);
}
use of org.odk.collect.android.utilities.MediaUtils 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.android.utilities.MediaUtils in project collect by opendatakit.
the class AudioVideoImageTextLabelTest method whenVideoFileClicked_ShouldMediaUtilsBeCalled.
@Test
public void whenVideoFileClicked_ShouldMediaUtilsBeCalled() {
MediaUtils mediaUtils = mock(MediaUtils.class);
File videoFile = mock(File.class);
when(videoFile.exists()).thenReturn(true);
AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
audioVideoImageTextLabel.setVideo(videoFile);
audioVideoImageTextLabel.setMediaUtils(mediaUtils);
audioVideoImageTextLabel.getVideoButton().performClick();
verify(mediaUtils).openFile(activity, videoFile, "video/*");
}
Aggregations