use of android.hardware.camera2.CaptureRequest in project android_frameworks_base by AOSPA.
the class CameraDeviceBinderTest method testFlush.
@SmallTest
public void testFlush() throws Exception {
int status;
// Initial flush should work
long lastFrameNumber = mCameraUser.flush();
// Then set up a stream
CaptureRequest request = createDefaultBuilder(/* needStream */
true).build();
// Flush should still be a no-op, really
lastFrameNumber = mCameraUser.flush();
// Submit a few capture requests
SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
false);
SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
false);
SubmitInfo requestInfo3 = submitCameraRequest(request, /* streaming */
false);
SubmitInfo requestInfo4 = submitCameraRequest(request, /* streaming */
false);
SubmitInfo requestInfo5 = submitCameraRequest(request, /* streaming */
false);
// Then flush and wait for idle
lastFrameNumber = mCameraUser.flush();
verify(mMockCb, timeout(WAIT_FOR_FLUSH_TIMEOUT_MS).times(1)).onDeviceIdle();
// Now a streaming request
SubmitInfo streamingInfo = submitCameraRequest(request, /* streaming */
true);
// Wait a bit to fill up the queue
SystemClock.sleep(WAIT_FOR_WORK_MS);
// Then flush and wait for the idle callback
lastFrameNumber = mCameraUser.flush();
verify(mMockCb, timeout(WAIT_FOR_FLUSH_TIMEOUT_MS).times(2)).onDeviceIdle();
// TODO: When errors are hooked up, count that errors + successful
// requests equal to 5.
}
use of android.hardware.camera2.CaptureRequest in project android_frameworks_base by AOSPA.
the class CameraDeviceBinderTest method testSubmitBadRequest.
@SmallTest
public void testSubmitBadRequest() throws Exception {
CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
false);
CaptureRequest request1 = builder.build();
try {
SubmitInfo requestInfo = mCameraUser.submitRequest(request1, /* streaming */
false);
fail("Exception expected");
} catch (ServiceSpecificException e) {
assertEquals("Expected submitRequest to throw ServiceSpecificException with BAD_VALUE " + "since we had 0 surface targets set.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
}
builder.addTarget(mSurface);
CaptureRequest request2 = builder.build();
try {
SubmitInfo requestInfo = mCameraUser.submitRequest(request2, /* streaming */
false);
fail("Exception expected");
} catch (ServiceSpecificException e) {
assertEquals("Expected submitRequest to throw ILLEGAL_ARGUMENT " + "ServiceSpecificException since the target wasn't registered with createStream.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
}
}
use of android.hardware.camera2.CaptureRequest in project android_frameworks_base by AOSPA.
the class CameraDeviceBinderTest method testSubmitStreamingRequest.
@SmallTest
public void testSubmitStreamingRequest() throws Exception {
CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
true);
CaptureRequest request = builder.build();
// Submit valid request once (non-streaming), and another time
// (streaming)
SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
false);
SubmitInfo requestInfoStreaming = submitCameraRequest(request, /* streaming */
true);
assertNotSame("Request IDs should be unique for multiple requests", requestInfo1.getRequestId(), requestInfoStreaming.getRequestId());
try {
long lastFrameNumber = mCameraUser.cancelRequest(-1);
fail("Expected exception");
} catch (ServiceSpecificException e) {
assertEquals("Invalid request IDs should not be cancellable", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
}
try {
long lastFrameNumber = mCameraUser.cancelRequest(requestInfo1.getRequestId());
fail("Expected exception");
} catch (ServiceSpecificException e) {
assertEquals("Non-streaming request IDs should not be cancellable", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
}
long lastFrameNumber = mCameraUser.cancelRequest(requestInfoStreaming.getRequestId());
}
use of android.hardware.camera2.CaptureRequest in project android_frameworks_base by AOSPA.
the class CameraDeviceBinderTest method testSubmitGoodRequest.
@SmallTest
public void testSubmitGoodRequest() throws Exception {
CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
true);
CaptureRequest request = builder.build();
// Submit valid request twice.
SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
false);
SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
false);
assertNotSame("Request IDs should be unique for multiple requests", requestInfo1.getRequestId(), requestInfo2.getRequestId());
}
use of android.hardware.camera2.CaptureRequest in project android_frameworks_base by AOSPA.
the class CameraDeviceBinderTest method testCaptureResultCallbacks.
@SmallTest
public void testCaptureResultCallbacks() throws Exception {
IsMetadataNotEmpty matcher = new IsMetadataNotEmpty();
CaptureRequest request = createDefaultBuilder(/* needStream */
true).build();
// Test both single request and streaming request.
verify(mMockCb, timeout(WAIT_FOR_COMPLETE_TIMEOUT_MS).times(1)).onResultReceived(argThat(matcher), any(CaptureResultExtras.class));
verify(mMockCb, timeout(WAIT_FOR_COMPLETE_TIMEOUT_MS).atLeast(NUM_CALLBACKS_CHECKED)).onResultReceived(argThat(matcher), any(CaptureResultExtras.class));
}
Aggregations