Skip to content

Commit

Permalink
Add Android native tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Miskiewicz committed Aug 2, 2017
1 parent 200fc1e commit 0573ae8
Showing 1 changed file with 97 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,31 +261,14 @@ public void testNodeValueListenerIfListening() {
verifyNoMoreInteractions(valueListener);
}

@Test
public void testSpringAnimation() {
public void performSpringAnimationTestWithConfig(JavaOnlyMap config) {
createSimpleAnimatedViewWithOpacity(1000, 0d);

Callback animationCallback = mock(Callback.class);
mNativeAnimatedNodesManager.startAnimatingNode(
1,
1,
JavaOnlyMap.of(
"type",
"spring",
"friction",
7d,
"tension",
40.0d,
"initialVelocity",
0d,
"toValue",
1d,
"restSpeedThreshold",
0.001d,
"restDisplacementThreshold",
0.001d,
"overshootClamping",
false),
config,
animationCallback);

ArgumentCaptor<ReactStylesDiffMap> stylesCaptor =
Expand Down Expand Up @@ -322,13 +305,8 @@ public void testSpringAnimation() {
}

@Test
public void testSpringAnimationLoopsFiveTimes() {
createSimpleAnimatedViewWithOpacity(1000, 0d);

Callback animationCallback = mock(Callback.class);
mNativeAnimatedNodesManager.startAnimatingNode(
1,
1,
public void testRK4SpringAnimation() {
performSpringAnimationTestWithConfig(
JavaOnlyMap.of(
"type",
"spring",
Expand All @@ -345,9 +323,45 @@ public void testSpringAnimationLoopsFiveTimes() {
"restDisplacementThreshold",
0.001d,
"overshootClamping",
false,
"iterations",
5),
false
)
);
}

@Test
public void testDHOSpringAnimation() {
performSpringAnimationTestWithConfig(
JavaOnlyMap.of(
"type",
"spring",
"stiffness",
100d,
"damping",
10.0d,
"mass",
1.0d,
"initialVelocity",
0d,
"toValue",
1d,
"restSpeedThreshold",
0.001d,
"restDisplacementThreshold",
0.001d,
"overshootClamping",
false
)
);
}

public void performSpringAnimationLoopsFiveTimesTest(JavaOnlyMap config) {
createSimpleAnimatedViewWithOpacity(1000, 0d);

Callback animationCallback = mock(Callback.class);
mNativeAnimatedNodesManager.startAnimatingNode(
1,
1,
config,
animationCallback);

ArgumentCaptor<ReactStylesDiffMap> stylesCaptor =
Expand Down Expand Up @@ -399,6 +413,60 @@ public void testSpringAnimationLoopsFiveTimes() {
verifyNoMoreInteractions(mUIImplementationMock);
}

@Test
public void testRK4SpringAnimationLoopsFiveTimes() {
performSpringAnimationLoopsFiveTimesTest(
JavaOnlyMap.of(
"type",
"spring",
"friction",
7d,
"tension",
40.0d,
"initialVelocity",
0d,
"toValue",
1d,
"restSpeedThreshold",
0.001d,
"restDisplacementThreshold",
0.001d,
"overshootClamping",
false,
"iterations",
5
)
);
}

@Test
public void testDHOSpringAnimationLoopsFiveTimes() {
performSpringAnimationLoopsFiveTimesTest(
JavaOnlyMap.of(
"type",
"spring",
"stiffness",
100d,
"damping",
10.0d,
"mass",
1.0d,
"initialVelocity",
0d,
"toValue",
1d,
"restSpeedThreshold",
0.001d,
"restDisplacementThreshold",
0.001d,
"overshootClamping",
false,
"iterations",
5
)
);
}

@Test
public void testDecayAnimation() {
createSimpleAnimatedViewWithOpacity(1000, 0d);
Expand Down

0 comments on commit 0573ae8

Please sign in to comment.