Add missing metering tests

pull/588/head
Mattia Iavarone 6 years ago
parent 94293978e8
commit dba0a7552c
  1. 5
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration1Test.java
  2. 5
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegration2Test.java
  3. 40
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegrationTest.java
  4. 3
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java

@ -27,4 +27,9 @@ public class CameraIntegration1Test extends CameraIntegrationTest {
protected Engine getEngine() {
return Engine.CAMERA1;
}
@Override
protected long getMeteringTimeoutMillis() {
return Camera1Engine.AUTOFOCUS_END_DELAY_MILLIS;
}
}

@ -55,4 +55,9 @@ public class CameraIntegration2Test extends CameraIntegrationTest {
}.start(engine);
try { latch.await(); } catch (InterruptedException ignore) {}
}
@Override
protected long getMeteringTimeoutMillis() {
return Camera2Engine.METER_TIMEOUT;
}
}

@ -658,8 +658,8 @@ public abstract class CameraIntegrationTest extends BaseTest {
doEndOp(focus, 1).when(listener).onAutoFocusEnd(anyBoolean(), any(PointF.class));
camera.startAutoFocus(1, 1);
// Stop is not guaranteed to be called, we use a delay. So wait at least the delay time.
PointF point = focus.await(1000 + Camera1Engine.AUTOFOCUS_END_DELAY_MILLIS);
// Stop routine can fail, so engines use a timeout. So wait at least the timeout time.
PointF point = focus.await(1000 + getMeteringTimeoutMillis());
if (o.isAutoFocusSupported()) {
assertNotNull(point);
assertEquals(point, new PointF(1, 1));
@ -668,6 +668,8 @@ public abstract class CameraIntegrationTest extends BaseTest {
}
}
protected abstract long getMeteringTimeoutMillis();
//endregion
//region capture
@ -717,6 +719,24 @@ public abstract class CameraIntegrationTest extends BaseTest {
openSync(true);
camera.takePicture();
waitForUiException();
camera.takePicture();
}
@Test
public void testCapturePicture_withMetering() {
openSync(true);
camera.setPictureMetering(true);
camera.takePicture();
waitForPictureResult(true);
}
@Test
public void testCapturePicture_withoutMetering() {
openSync(true);
camera.setPictureMetering(false);
camera.takePicture();
waitForPictureResult(true);
}
@Test
@ -759,6 +779,22 @@ public abstract class CameraIntegrationTest extends BaseTest {
assertTrue(result.isSnapshot());
}
@Test
public void testCaptureSnapshot_withMetering() {
openSync(true);
camera.setPictureSnapshotMetering(true);
camera.takePictureSnapshot();
waitForPictureResult(true);
}
@Test
public void testCaptureSnapshot_withoutMetering() {
openSync(true);
camera.setPictureSnapshotMetering(false);
camera.takePictureSnapshot();
waitForPictureResult(true);
}
//endregion
//region Frame Processing

@ -27,6 +27,7 @@ import android.view.SurfaceHolder;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
import com.google.android.gms.tasks.Task;
@ -81,7 +82,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
private static final int FRAME_PROCESSING_FORMAT = ImageFormat.NV21;
private static final int FRAME_PROCESSING_INPUT_FORMAT = ImageFormat.YUV_420_888;
private static final long METER_TIMEOUT = 2500;
@VisibleForTesting static final long METER_TIMEOUT = 2500;
private final CameraManager mManager;
private String mCameraId;

Loading…
Cancel
Save