Search in sources :

Example 1 with SessionConfiguration

use of android.hardware.camera2.params.SessionConfiguration in project robolectric by robolectric.

the class ShadowCameraDeviceImpl method createCaptureSession.

@Implementation(minSdk = VERSION_CODES.P)
protected void createCaptureSession(SessionConfiguration config) throws CameraAccessException {
    checkIfCameraClosedOrInError();
    CameraCaptureSession session = createCameraCaptureSession(config.getStateCallback());
    config.getExecutor().execute(() -> config.getStateCallback().onConfigured(session));
}
Also used : CameraCaptureSession(android.hardware.camera2.CameraCaptureSession) Implementation(org.robolectric.annotation.Implementation)

Example 2 with SessionConfiguration

use of android.hardware.camera2.params.SessionConfiguration in project robolectric by robolectric.

the class ShadowCameraDeviceImplTest method createCaptureSession_configuration_throwsIllegalStateExceptionAfterClose.

@Test
@Config(sdk = VERSION_CODES.P)
public void createCaptureSession_configuration_throwsIllegalStateExceptionAfterClose() throws CameraAccessException {
    cameraDevice.close();
    SessionConfiguration configuration = new SessionConfiguration(SessionConfiguration.SESSION_REGULAR, Collections.singletonList(new OutputConfiguration(mock(Surface.class))), MoreExecutors.directExecutor(), new CaptureSessionCallback(/*useExecutor=*/
    true));
    IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> cameraDevice.createCaptureSession(configuration));
    assertThat(thrown).hasMessageThat().contains("CameraDevice was already closed");
}
Also used : OutputConfiguration(android.hardware.camera2.params.OutputConfiguration) SessionConfiguration(android.hardware.camera2.params.SessionConfiguration) Surface(android.view.Surface) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 3 with SessionConfiguration

use of android.hardware.camera2.params.SessionConfiguration in project robolectric by robolectric.

the class ShadowCameraDeviceImplTest method createCaptureSession_configuration.

@Test
@Config(sdk = VERSION_CODES.P)
public void createCaptureSession_configuration() throws CameraAccessException {
    Surface mockSurface = mock(Surface.class);
    builder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
    builder.addTarget(mockSurface);
    SessionConfiguration configuration = new SessionConfiguration(SessionConfiguration.SESSION_REGULAR, Collections.singletonList(new OutputConfiguration(mockSurface)), MoreExecutors.directExecutor(), new CaptureSessionCallback(/*useExecutor=*/
    true));
    cameraDevice.createCaptureSession(configuration);
}
Also used : OutputConfiguration(android.hardware.camera2.params.OutputConfiguration) SessionConfiguration(android.hardware.camera2.params.SessionConfiguration) Surface(android.view.Surface) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)2 SessionConfiguration (android.hardware.camera2.params.SessionConfiguration)2 Surface (android.view.Surface)2 Test (org.junit.Test)2 Config (org.robolectric.annotation.Config)2 CameraCaptureSession (android.hardware.camera2.CameraCaptureSession)1 Implementation (org.robolectric.annotation.Implementation)1