|
|
|
@ -1,7 +1,12 @@ |
|
|
|
|
package com.otaliastudios.cameraview.engine; |
|
|
|
|
|
|
|
|
|
import android.hardware.camera2.CaptureRequest; |
|
|
|
|
import android.hardware.camera2.TotalCaptureResult; |
|
|
|
|
|
|
|
|
|
import com.otaliastudios.cameraview.DoNotRunOnTravis; |
|
|
|
|
import com.otaliastudios.cameraview.controls.Engine; |
|
|
|
|
import com.otaliastudios.cameraview.engine.action.ActionHolder; |
|
|
|
|
import com.otaliastudios.cameraview.engine.action.BaseAction; |
|
|
|
|
|
|
|
|
|
import org.junit.Ignore; |
|
|
|
|
import org.junit.Test; |
|
|
|
@ -11,6 +16,8 @@ import androidx.annotation.NonNull; |
|
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4; |
|
|
|
|
import androidx.test.filters.LargeTest; |
|
|
|
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* These tests work great on real devices, and are the only way to test actual CameraEngine |
|
|
|
|
* implementation - we really need to open the camera device. |
|
|
|
@ -29,7 +36,23 @@ public class CameraIntegration2Test extends CameraIntegrationTest { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void testFrameProcessing_afterVideo() throws Exception { |
|
|
|
|
super.testFrameProcessing_afterVideo(); |
|
|
|
|
protected void onOpenSync() { |
|
|
|
|
super.onOpenSync(); |
|
|
|
|
// Extra wait for the first frame to be dispatched.
|
|
|
|
|
// This is because various classes require getLastResult to be non-null
|
|
|
|
|
// and that's typically the case in a real app.
|
|
|
|
|
Camera2Engine engine = (Camera2Engine) controller; |
|
|
|
|
final CountDownLatch latch = new CountDownLatch(1); |
|
|
|
|
new BaseAction() { |
|
|
|
|
@Override |
|
|
|
|
public void onCaptureCompleted(@NonNull ActionHolder holder, |
|
|
|
|
@NonNull CaptureRequest request, |
|
|
|
|
@NonNull TotalCaptureResult result) { |
|
|
|
|
super.onCaptureCompleted(holder, request, result); |
|
|
|
|
latch.countDown(); |
|
|
|
|
setState(STATE_COMPLETED); |
|
|
|
|
} |
|
|
|
|
}.start(engine); |
|
|
|
|
try { latch.await(); } catch (InterruptedException ignore) {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|