import com.gorios.lanvoice.expression.* fun main() { cameraPixelsCheck() val fence=CameraCallbackFence() val initial=fence.nextBinding() check(fence.accepts(initial)) fence.invalidate();check(!fence.accepts(initial)) val recovered=fence.nextBinding() check(fence.accepts(recovered) && !fence.accepts(initial)) fence.close();check(!fence.accepts(recovered)) check(runCatching { fence.nextBinding() }.isFailure) val boot=CameraAnalysisDiagnostics() boot.stage(CameraStage.MODEL_LOADING,100) check(cameraTimeout(boot.snapshot(),15099)==CameraFailure.NONE) check(cameraTimeout(boot.snapshot(),15100)==CameraFailure.MODEL_TIMEOUT) boot.stage(CameraStage.PROVIDER_WAIT,20000) check(cameraTimeout(boot.snapshot(),28000)==CameraFailure.PROVIDER_TIMEOUT) boot.stage(CameraStage.WAITING_FRAME,30000) check(cameraTimeout(boot.snapshot(),34999)==CameraFailure.NONE) check(canRecoverFirstFrame(boot.snapshot(),cameraTimeout(boot.snapshot(),35000))) check(canRecoverFirstFrame(boot.snapshot(),CameraFailure.STREAM_CONFIG)) boot.recovering();check(boot.snapshot().profile==CameraProfile.YUV_320) check(!canRecoverFirstFrame(boot.snapshot(),CameraFailure.STREAM_CONFIG)) boot.stage(CameraStage.WAITING_FRAME,35000) check(!canRecoverFirstFrame(boot.snapshot(),cameraTimeout(boot.snapshot(),40000))) boot.received(39000) check(boot.snapshot().stage==CameraStage.WAITING_RESULT) check(cameraTimeout(boot.snapshot(),44000)==CameraFailure.RESULT_TIMEOUT) boot.processed(0,FaceCueObservation(reason=FaceCueReason.NO_FACE),10,40000) check(boot.snapshot().stage==CameraStage.READY && boot.snapshot().processed==1) check(cameraTimeout(boot.snapshot(),44000)==CameraFailure.FRAME_TIMEOUT) boot.received(44500) check(cameraTimeout(boot.snapshot(),45000)==CameraFailure.RESULT_TIMEOUT) boot.stage(CameraStage.OFF,45000) check(cameraTimeout(boot.snapshot(),100000)==CameraFailure.NONE) boot.failed(CameraFailure.FRAME_TIMEOUT) check(cameraTimeout(boot.snapshot(),100000)==CameraFailure.NONE) val camera = CameraAnalysisDiagnostics() check(camera.snapshot().reason == FaceCueReason.NO_FRAME) var summaries = 0 for (time in 0L..600_000L step 100) { camera.received() camera.processed(0, FaceCueObservation(reason = FaceCueReason.NO_FACE), 8) if (camera.summary(time) != null) summaries++ } check(summaries == 61) // 10Hz samples, <=1 summary/10s including first. check(camera.snapshot().received == 6001 && camera.snapshot().processed == 6001) check(camera.snapshot().faceCount == 0 && camera.snapshot().reason == FaceCueReason.NO_FACE) camera.processed(1, FaceCueObservation(FaceCue.SMILING, .9f, 900, 0, FaceCueReason.STABLE), 12) camera.failed(CameraFailure.ANALYSIS) check(camera.snapshot().cue == FaceCue.SMILING && camera.snapshot().failures == 1) check(camera.summary(600_001) == null) val final = checkNotNull(camera.summary(600_001, force = true)) check("failure=analysis" in final && "cue=smiling" in final) check(listOf("landmark", "blendshape", "image", "prompt", "reply").none { it in final }) val send = FaceTransmissionDiagnostics() check(send.snapshot().reason == FaceSendReason.SHARING_OFF) send.record(FaceSendReason.NO_STABLE_CUE) check(send.snapshot().attempts == 0) send.record(FaceSendReason.SENT, FaceCue.SMILING) send.record(FaceSendReason.CLEARED) send.record(FaceSendReason.SEND_FAILED) send.record(FaceSendReason.STALE) check(send.snapshot().attempts == 3 && send.snapshot().sent == 1 && send.snapshot().clears == 1 && send.snapshot().failures == 1) check(send.summary(0) != null && send.summary(9999) == null && send.summary(10000) != null) println("PASS: production camera readiness deadlines/one bounded first-frame recovery/no-frame vs no-result/stale/stop; enum-only counters and 10s summaries") }