@@ -10,7 +10,6 @@ import androidx.compose.ui.test.onNodeWithText
10
10
import androidx.compose.ui.test.performClick
11
11
import androidx.test.platform.app.InstrumentationRegistry
12
12
import androidx.test.rule.GrantPermissionRule
13
- import com.amplifyframework.annotations.InternalAmplifyApi
14
13
import com.amplifyframework.auth.AuthSession
15
14
import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin
16
15
import com.amplifyframework.core.Action
@@ -36,6 +35,7 @@ import io.mockk.OfTypeMatcher
36
35
import io.mockk.Runs
37
36
import io.mockk.every
38
37
import io.mockk.just
38
+ import io.mockk.mockk
39
39
import io.mockk.mockkConstructor
40
40
import io.mockk.mockkObject
41
41
import io.mockk.mockkStatic
@@ -234,7 +234,7 @@ class LivenessFlowInstrumentationTest {
234
234
var completesSuccessfully = false
235
235
composeTestRule.setContent {
236
236
FaceLivenessDetector (sessionId = sessionId, region = " us-east-1" , onComplete = {
237
- completesSuccessfully = true
237
+ completesSuccessfully = true
238
238
}, onError = { assertTrue(false ) })
239
239
}
240
240
@@ -295,38 +295,59 @@ class LivenessFlowInstrumentationTest {
295
295
.fetchSemanticsNodes().size == 1
296
296
}
297
297
298
- @OptIn(InternalAmplifyApi ::class )
299
- val faceTargetChallenge = FaceTargetChallenge (
300
- 422f , 683f , 230f , 292f ,
301
- FaceTargetMatchingParameters (
302
- 0.7f ,
303
- 0.25f ,
304
- 0.25f ,
305
- 0.15f ,
306
- 0.15f
307
- )
298
+ val faceTargetMatchingParameters = mockk<FaceTargetMatchingParameters >()
299
+ every { faceTargetMatchingParameters.targetIouThreshold }.returns(0.7f )
300
+ every { faceTargetMatchingParameters.targetIouWidthThreshold }.returns(0.25f )
301
+ every { faceTargetMatchingParameters.targetIouHeightThreshold }.returns(0.25f )
302
+ every { faceTargetMatchingParameters.faceIouWidthThreshold }.returns(0.15f )
303
+ every { faceTargetMatchingParameters.faceIouHeightThreshold }.returns(0.15f )
304
+
305
+ val faceTargetChallenge = mockk<FaceTargetChallenge >()
306
+ every { faceTargetChallenge.targetWidth }.returns(422f )
307
+ every { faceTargetChallenge.targetHeight }.returns(683f )
308
+ every { faceTargetChallenge.targetCenterX }.returns(230f )
309
+ every { faceTargetChallenge.targetCenterY }.returns(292f )
310
+ every { faceTargetChallenge.faceTargetMatching }.returns(faceTargetMatchingParameters)
311
+
312
+ val colors = listOf (
313
+ RgbColor (0 , 0 , 0 ),
314
+ RgbColor (0 , 255 , 255 ),
315
+ RgbColor (255 , 0 , 0 ),
316
+ RgbColor (0 , 255 , 0 ),
317
+ RgbColor (0 , 0 , 255 ),
318
+ RgbColor (255 , 255 , 0 ),
319
+ RgbColor (0 , 255 , 0 ),
320
+ RgbColor (255 , 0 , 0 ),
308
321
)
309
- val colorChallenge = ColorChallenge (
310
- " id" ,
311
- ColorChallengeType .SEQUENTIAL ,
312
- listOf (
313
- ColorDisplayInformation (RgbColor (0 ,0 ,0 ), 75f , false ),
314
- ColorDisplayInformation (RgbColor (0 ,255 ,255 ), 475f , false ),
315
- ColorDisplayInformation (RgbColor (255 ,0 ,0 ), 475f , false ),
316
- ColorDisplayInformation (RgbColor (0 ,255 ,0 ), 475f , false ),
317
- ColorDisplayInformation (RgbColor (0 ,0 ,255 ), 475f , false ),
318
- ColorDisplayInformation (RgbColor (255 ,255 ,0 ), 475f , false ),
319
- ColorDisplayInformation (RgbColor (0 ,255 ,0 ), 475f , false ),
320
- ColorDisplayInformation (RgbColor (255 ,0 ,0 ), 475f , false ),
321
- )
322
+ val durations = listOf (
323
+ 75f ,
324
+ 475f ,
325
+ 475f ,
326
+ 475f ,
327
+ 475f ,
328
+ 475f ,
329
+ 475f ,
330
+ 475f ,
322
331
)
332
+ val challengeColors = List (colors.size) {
333
+ val colorDisplayInformation = mockk<ColorDisplayInformation >()
334
+ every { colorDisplayInformation.color }.returns(colors[it])
335
+ every { colorDisplayInformation.duration }.returns(durations[it])
336
+ every { colorDisplayInformation.shouldScroll }.returns(false )
337
+ colorDisplayInformation
338
+ }
339
+ val colorChallenge = mockk<ColorChallenge >()
340
+ every { colorChallenge.challengeId }.returns(" id" )
341
+ every { colorChallenge.challengeType }.returns(ColorChallengeType .SEQUENTIAL )
342
+ every { colorChallenge.challengeColors }.returns(challengeColors)
343
+
323
344
onSessionStarted.captured.accept(
324
345
FaceLivenessSession (
325
346
listOf (faceTargetChallenge, colorChallenge),
326
347
{}, // onVideoEvent
327
348
{}, // onChallengeResponseEvent
328
- {} // stopLivenessSession
329
- )
349
+ {}, // stopLivenessSession
350
+ ),
330
351
)
331
352
332
353
composeTestRule.waitUntil(5000 ) {
0 commit comments