forked from nhaarman/ListViewAnimations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...ore/src/androidTest/java/com/nhaarman/listviewanimations/appearance/ViewAnimatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.nhaarman.listviewanimations.appearance; | ||
|
||
import android.test.InstrumentationTestCase; | ||
import android.view.View; | ||
|
||
import com.nhaarman.listviewanimations.util.ListViewWrapper; | ||
import com.nineoldandroids.animation.Animator; | ||
|
||
import org.mockito.Mock; | ||
|
||
import static org.mockito.Mockito.*; | ||
import static org.mockito.MockitoAnnotations.*; | ||
|
||
@SuppressWarnings({"MagicNumber", "AnonymousInnerClass"}) | ||
public class ViewAnimatorTest extends InstrumentationTestCase { | ||
|
||
private ViewAnimator mViewAnimator; | ||
|
||
@Mock | ||
private ListViewWrapper mListViewWrapper; | ||
|
||
@Mock | ||
private View mView; | ||
|
||
@Mock | ||
private Animator mAnimator; | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
initMocks(this); | ||
|
||
mViewAnimator = new ViewAnimator(mListViewWrapper); | ||
} | ||
|
||
public void testFirstViewAnimated() { | ||
getInstrumentation().runOnMainSync( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
mViewAnimator.animateViewIfNecessary(0, mView, new Animator[]{mAnimator}); | ||
} | ||
} | ||
); | ||
|
||
verify(mAnimator, timeout(500)).start(); | ||
} | ||
|
||
public void testSecondViewAnimated() throws InterruptedException { | ||
mViewAnimator.setAnimationDelayMillis(500); | ||
|
||
getInstrumentation().runOnMainSync( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
mViewAnimator.animateViewIfNecessary(0, mView, new Animator[]{mAnimator}); | ||
mViewAnimator.animateViewIfNecessary(1, mView, new Animator[]{mAnimator}); | ||
} | ||
} | ||
); | ||
|
||
verify(mAnimator, timeout(500)).start(); | ||
reset(mAnimator); | ||
Thread.sleep(100); | ||
verify(mAnimator, never()).start(); | ||
verify(mAnimator, timeout(500)).start(); | ||
} | ||
|
||
public void testDisabledAnimations() throws InterruptedException { | ||
mViewAnimator.disableAnimations(); | ||
getInstrumentation().runOnMainSync( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
mViewAnimator.animateViewIfNecessary(0, mView, new Animator[]{mAnimator}); | ||
mViewAnimator.animateViewIfNecessary(1, mView, new Animator[]{mAnimator}); | ||
} | ||
} | ||
); | ||
|
||
Thread.sleep(10000); | ||
|
||
verify(mAnimator, never()).start(); | ||
} | ||
|
||
public void testSetAnimationDuration() { | ||
mViewAnimator.setAnimationDurationMillis(500); | ||
getInstrumentation().runOnMainSync( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
mViewAnimator.animateViewIfNecessary(0, mView, new Animator[]{mAnimator}); | ||
} | ||
} | ||
); | ||
|
||
verify(mAnimator, timeout(1000)).setDuration(500); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters