@@ -3,11 +3,14 @@ package com.github.lcdsmao.springx
33import  android.view.View 
44import  androidx.dynamicanimation.animation.DynamicAnimation 
55import  androidx.dynamicanimation.animation.FloatPropertyCompat 
6+ import  androidx.dynamicanimation.animation.SpringForce 
67import  androidx.test.ext.junit.rules.ActivityScenarioRule 
78import  com.google.common.truth.Truth 
89import  io.mockk.mockk 
910import  io.mockk.verify 
11+ import  io.mockk.verifySequence 
1012import  org.junit.Before 
13+ import  org.junit.Ignore 
1114import  org.junit.Rule 
1215import  org.junit.Test 
1316
@@ -162,6 +165,34 @@ abstract class ViewPropertySpringAnimatorTest : UiTest {
162165 Truth .assertThat(animView.translationX).isEqualTo(100f )
163166 }
164167
168+  @Test
169+  @Ignore(" Fix the implementation of [ViewPropertySpringAnimator] to let this test pass"  )
170+  fun  testDampingRatio () {
171+  val  onEnd =  mockk< (Int ) ->  Unit > (relaxed =  true )
172+  val  anim =  animView.spring()
173+  .defaultDampingRatio(SpringForce .DAMPING_RATIO_NO_BOUNCY )
174+  .rotation(100f ) {
175+  dampingRatio =  SpringForce .DAMPING_RATIO_HIGH_BOUNCY 
176+  onEnd { _, _, _, _ ->  onEnd.invoke(2 ) }
177+  }
178+  .translationY(100f ) {
179+  dampingRatio =  SpringForce .DAMPING_RATIO_LOW_BOUNCY 
180+  onEnd { _, _, _, _ ->  onEnd.invoke(1 ) }
181+  }
182+  .translationX(100f ) {
183+  onEnd { _, _, _, _ ->  onEnd.invoke(0 ) }
184+  }
185+  .setListener(onEnd =  { onEnd.invoke(3 ) })
186+  runOnMainThread { anim.start() }
187+  verify(exactly =  4 , timeout =  1000L ) { onEnd.invoke(any()) }
188+  verifySequence {
189+  onEnd.invoke(0 )
190+  onEnd.invoke(1 )
191+  onEnd.invoke(2 )
192+  onEnd.invoke(3 )
193+  }
194+  }
195+ 165196 private  fun  <T  :  View > ViewPropertySpringAnimator<T>.animate (
166197 property :  DynamicAnimation .ViewProperty ,
167198 value :  Float ,
0 commit comments