summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt43
1 files changed, 43 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt
new file mode 100644
index 0000000000..7c126c7832
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt
@@ -0,0 +1,43 @@
+package com.mapbox.mapboxsdk.location
+
+import android.animation.ValueAnimator
+import io.mockk.every
+import io.mockk.mockk
+import io.mockk.verify
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
+
+@RunWith(RobolectricTestRunner::class)
+class MapboxAnimatorTest {
+
+ @Test
+ fun fps_unlimited() {
+ val valueAnimator = mockk<ValueAnimator>()
+ every { valueAnimator.animatedValue } answers { 5f }
+ val listener = mockk<MapboxAnimator.AnimationsValueChangeListener<Float>>()
+ every { listener.onNewAnimationValue(any()) } answers {}
+ val mapboxAnimator = MapboxFloatAnimator(0f, 10f, listener, Int.MAX_VALUE)
+
+ for (i in 0 until 5)
+ mapboxAnimator.onAnimationUpdate(valueAnimator)
+
+ verify(exactly = 5) { listener.onNewAnimationValue(5f) }
+ }
+
+ @Test
+ fun fps_limited() {
+ val valueAnimator = mockk<ValueAnimator>()
+ every { valueAnimator.animatedValue } answers { 5f }
+ val listener = mockk<MapboxAnimator.AnimationsValueChangeListener<Float>>()
+ every { listener.onNewAnimationValue(any()) } answers {}
+ val mapboxAnimator = MapboxFloatAnimator(0f, 10f, listener, 5)
+
+ for (i in 0 until 5) {
+ mapboxAnimator.onAnimationUpdate(valueAnimator)
+ Thread.sleep(150)
+ }
+
+ verify(exactly = 3) { listener.onNewAnimationValue(5f) }
+ }
+} \ No newline at end of file