@@ -152,8 +152,8 @@ internal class LivenessStateTest {
152
152
}
153
153
154
154
@Test
155
- fun `beginning state is running ` () {
156
- assertTrue(livenessState.livenessCheckState is LivenessCheckState .Running )
155
+ fun `beginning state is initial ` () {
156
+ assertTrue(livenessState.livenessCheckState is LivenessCheckState .Initial )
157
157
}
158
158
159
159
@Test
@@ -263,9 +263,26 @@ internal class LivenessStateTest {
263
263
}
264
264
265
265
@Test
266
- fun `challenge runs after retrieving session info` () {
267
- val faceLivenessSession = mockk<FaceLivenessSession >(relaxed = true )
266
+ fun `challenge runs after retrieving session info and detected face far enough away` () {
267
+ val faceTargetChallenge = mockk<FaceTargetChallenge >(relaxed = true )
268
+ val challenges = listOf<FaceLivenessSessionChallenge >(faceTargetChallenge)
269
+ every { faceTargetChallenge.faceTargetMatching.faceDistanceThresholdMin } returns 1f
270
+ val faceLivenessSession = FaceLivenessSession (
271
+ challengeId = " 12345" ,
272
+ challengeType = FaceLivenessChallengeType .FaceMovementAndLightChallenge ,
273
+ challenges = challenges,
274
+ onVideoEvent = { },
275
+ onChallengeResponseEvent = { },
276
+ stopLivenessSession = { }
277
+ )
268
278
livenessState.onLivenessSessionReady(faceLivenessSession)
279
+
280
+ val faceRect = RectF (20f , 20f , 100f , 100f )
281
+ val leftEye = FaceDetector .Landmark (25f , 40f )
282
+ val rightEye = FaceDetector .Landmark (75f , 40f )
283
+ val mouth = FaceDetector .Landmark (40f , 80f )
284
+ livenessState.onFrameFaceUpdate(faceRect, leftEye, rightEye, mouth)
285
+
269
286
assertTrue(livenessState.livenessCheckState is LivenessCheckState .Running )
270
287
assertTrue(livenessState.readyForOval)
271
288
}
@@ -392,7 +409,7 @@ internal class LivenessStateTest {
392
409
val rightEye = FaceDetector .Landmark (75f , 40f )
393
410
val mouth = FaceDetector .Landmark (40f , 80f )
394
411
livenessState.onFrameFaceUpdate(faceRect, leftEye, rightEye, mouth)
395
- assertTrue(livenessState.livenessCheckState is LivenessCheckState .Running )
412
+ assertTrue(livenessState.livenessCheckState is LivenessCheckState .Initial )
396
413
}
397
414
398
415
@Test
0 commit comments