/
WalkthroughAnimationTest.kt
46 lines (38 loc) · 1.43 KB
/
WalkthroughAnimationTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.airbnb.lottie.samples
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.sample.compose.ComposeActivity
import com.airbnb.lottie.sample.compose.R
import org.junit.Rule
import org.junit.Test
class WalkthroughAnimationTest {
@get:Rule
val composeTestRule = createAndroidComposeRule(ComposeActivity::class.java)
@Test
fun testWalkthroughCompletes() {
val composition = LottieCompositionFactory.fromRawResSync(composeTestRule.activity, R.raw.walkthrough).value!!
var animationCompleted = true
composeTestRule.setContent {
val progress by animateLottieCompositionAsState(composition, iterations = 1)
Box(
modifier = Modifier
.fillMaxSize()
) {
LottieAnimation(
composition,
{ progress },
)
}
if (progress == 1f) {
animationCompleted = true
}
}
composeTestRule.mainClock.advanceTimeUntil { animationCompleted }
}
}