Skip to content

Commit 0573ae8

Browse files
author
Adam Miskiewicz
committed
Add Android native tests
1 parent 200fc1e commit 0573ae8

File tree

1 file changed

+97
-29
lines changed

1 file changed

+97
-29
lines changed

ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java

Lines changed: 97 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -261,31 +261,14 @@ public void testNodeValueListenerIfListening() {
261261
verifyNoMoreInteractions(valueListener);
262262
}
263263

264-
@Test
265-
public void testSpringAnimation() {
264+
public void performSpringAnimationTestWithConfig(JavaOnlyMap config) {
266265
createSimpleAnimatedViewWithOpacity(1000, 0d);
267266

268267
Callback animationCallback = mock(Callback.class);
269268
mNativeAnimatedNodesManager.startAnimatingNode(
270269
1,
271270
1,
272-
JavaOnlyMap.of(
273-
"type",
274-
"spring",
275-
"friction",
276-
7d,
277-
"tension",
278-
40.0d,
279-
"initialVelocity",
280-
0d,
281-
"toValue",
282-
1d,
283-
"restSpeedThreshold",
284-
0.001d,
285-
"restDisplacementThreshold",
286-
0.001d,
287-
"overshootClamping",
288-
false),
271+
config,
289272
animationCallback);
290273

291274
ArgumentCaptor<ReactStylesDiffMap> stylesCaptor =
@@ -322,13 +305,8 @@ public void testSpringAnimation() {
322305
}
323306

324307
@Test
325-
public void testSpringAnimationLoopsFiveTimes() {
326-
createSimpleAnimatedViewWithOpacity(1000, 0d);
327-
328-
Callback animationCallback = mock(Callback.class);
329-
mNativeAnimatedNodesManager.startAnimatingNode(
330-
1,
331-
1,
308+
public void testRK4SpringAnimation() {
309+
performSpringAnimationTestWithConfig(
332310
JavaOnlyMap.of(
333311
"type",
334312
"spring",
@@ -345,9 +323,45 @@ public void testSpringAnimationLoopsFiveTimes() {
345323
"restDisplacementThreshold",
346324
0.001d,
347325
"overshootClamping",
348-
false,
349-
"iterations",
350-
5),
326+
false
327+
)
328+
);
329+
}
330+
331+
@Test
332+
public void testDHOSpringAnimation() {
333+
performSpringAnimationTestWithConfig(
334+
JavaOnlyMap.of(
335+
"type",
336+
"spring",
337+
"stiffness",
338+
100d,
339+
"damping",
340+
10.0d,
341+
"mass",
342+
1.0d,
343+
"initialVelocity",
344+
0d,
345+
"toValue",
346+
1d,
347+
"restSpeedThreshold",
348+
0.001d,
349+
"restDisplacementThreshold",
350+
0.001d,
351+
"overshootClamping",
352+
false
353+
)
354+
);
355+
}
356+
357+
public void performSpringAnimationLoopsFiveTimesTest(JavaOnlyMap config) {
358+
createSimpleAnimatedViewWithOpacity(1000, 0d);
359+
360+
Callback animationCallback = mock(Callback.class);
361+
mNativeAnimatedNodesManager.startAnimatingNode(
362+
1,
363+
1,
364+
config,
351365
animationCallback);
352366

353367
ArgumentCaptor<ReactStylesDiffMap> stylesCaptor =
@@ -399,6 +413,60 @@ public void testSpringAnimationLoopsFiveTimes() {
399413
verifyNoMoreInteractions(mUIImplementationMock);
400414
}
401415

416+
@Test
417+
public void testRK4SpringAnimationLoopsFiveTimes() {
418+
performSpringAnimationLoopsFiveTimesTest(
419+
JavaOnlyMap.of(
420+
"type",
421+
"spring",
422+
"friction",
423+
7d,
424+
"tension",
425+
40.0d,
426+
"initialVelocity",
427+
0d,
428+
"toValue",
429+
1d,
430+
"restSpeedThreshold",
431+
0.001d,
432+
"restDisplacementThreshold",
433+
0.001d,
434+
"overshootClamping",
435+
false,
436+
"iterations",
437+
5
438+
)
439+
);
440+
}
441+
442+
@Test
443+
public void testDHOSpringAnimationLoopsFiveTimes() {
444+
performSpringAnimationLoopsFiveTimesTest(
445+
JavaOnlyMap.of(
446+
"type",
447+
"spring",
448+
"stiffness",
449+
100d,
450+
"damping",
451+
10.0d,
452+
"mass",
453+
1.0d,
454+
"initialVelocity",
455+
0d,
456+
"toValue",
457+
1d,
458+
"restSpeedThreshold",
459+
0.001d,
460+
"restDisplacementThreshold",
461+
0.001d,
462+
"overshootClamping",
463+
false,
464+
"iterations",
465+
5
466+
)
467+
);
468+
}
469+
402470
@Test
403471
public void testDecayAnimation() {
404472
createSimpleAnimatedViewWithOpacity(1000, 0d);

0 commit comments

Comments
 (0)