Skip to content

Commit

Permalink
#4: Testing startAction & endAction in TeamScoreBindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Entreco committed Jan 5, 2018
1 parent 2737e02 commit 4fdbacf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ abstract class TeamScoreBindings {
@JvmStatic
@BindingAdapter("special")
fun showSpecials(view: TextView, oldScore: Int, score: Int) {
Log.w("REMCO", "showSpecial: $score")
val diff = oldScore - score
when (diff) {
180 -> handle180(view)
0 -> {
}
0 -> { }
else -> {
clear(view)
}
Expand Down Expand Up @@ -67,9 +65,8 @@ abstract class TeamScoreBindings {
view.pivotY = 0F
}
.withEndAction({
val howLong = 1200L
animateColor(view, R.attr.colorOneEighty, R.attr.scoreText, howLong)
clear(view, howLong)
animateColor(view, R.attr.colorOneEighty, R.attr.scoreText, 1200L)
clear(view, 1200L)
}).start()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TeamScoreBindingsTest {
@Mock private lateinit var mockTextView: TextView
@Mock private lateinit var mockImageView: ImageView
@Mock private lateinit var mockAnimator: ViewPropertyAnimator
private val runnable = argumentCaptor<Runnable>()

@Test
fun `it should setTarget() on CounterTextView (ScorePts TextView)`() {
Expand Down Expand Up @@ -148,6 +149,9 @@ class TeamScoreBindingsTest {
private fun then180AnimationIsShown() {
verify(mockTextView).setText(R.string.score_180)
verify(mockTextView, times(1)).animate()
verify(mockAnimator).withStartAction(runnable.capture())
verify(mockAnimator).withEndAction(runnable.capture())
runnable.allValues.forEach { it.run() }
}

private fun thenNoAnimationIsShown() {
Expand All @@ -158,6 +162,9 @@ class TeamScoreBindingsTest {
private fun thenClearAnimationIsShown() {
verify(mockTextView, never()).setText(R.string.score_180)
verify(mockTextView, times(1)).animate()
verify(mockAnimator).withStartAction(runnable.capture())
verify(mockAnimator).withEndAction(runnable.capture())
runnable.allValues.forEach { it.run() }
}

private fun thenShowCurrentAnimationIsDone() {
Expand Down

0 comments on commit 4fdbacf

Please sign in to comment.