@Test
public void testHideSearch() throws Exception {
mListFragment.hideSearch(); //<--- animation launched here
sleep(1000);
View searchEditText = mListFragment.getView().findViewById(R.id.filterEditText);
assertFalse(searchEditText.getVisibility() == View.VISIBLE);
}
--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Robolectric" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robolectric/HQpA1IafnZk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robolectric...@googlegroups.com.
public void hideSearch() {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_top);
mSearchEditTextContainer.startAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mSearchEditTextContainer.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="200"
android:fromYDelta="0%"
android:toYDelta="-100%" />
<alpha
android:duration="200"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
shadowOf(view.getAnimation()).invokeEnd();
@Test
public void testAnimation() {
final boolean[] hasRun = {false};
Animation animation = AnimationUtils.makeOutAnimation(Robolectric.application, true);
animation.setDuration(200);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
hasRun[0] = true;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
View view = new View(Robolectric.application);
view.startAnimation(animation);
shadowOf(view.getAnimation()).invokeEnd();
assertThat(hasRun[0]).isTrue();
}
@Test
public void testAnimator() {
final boolean[] hasRun = {false};
View view = new View(Robolectric.application);
ValueAnimator animator = ObjectAnimator.ofFloat(view, "alpha", 0, 1)
.setDuration(200);
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
hasRun[0] = true;
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
animator.start();
Robolectric.getUiThreadScheduler().advanceBy(200);
assertThat(hasRun[0]).isTrue();
}
Cheers :)
To unsubscribe from this group and stop receiving emails from it, send an email to robol...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Robolectric" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robolectric/HQpA1IafnZk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robol...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robol...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Robolectric" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robolectric/HQpA1IafnZk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robol...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robol...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Robolectric" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robolectric/HQpA1IafnZk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robol...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robol...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
shadowOf(loadingIndicator!!.animation).invokeEnd()However, since animation object cannot be a shadow I'm unable to do that and I'm stuck on this and no other approaches seem to work for me.
assertThat(loadingIndicator!!.alpha).isEqualTo(1f)
and
Robolectric.getForegroundThreadScheduler().advanceBy(1000, TimeUnit.MILLISECONDS)
Robolectric.flushBackgroundThreadScheduler()
getShadowMainLooper().idle(1, TimeUnit.SECONDS)
ObjectAnimator.ofFloat(ins_loading_view, "alpha", 1f).apply {
duration = INS_LOADING_APPEAR_DUR
start()
}
shadowOf(Looper.getMainLooper()).idle(1, TimeUnit.SECONDS)