modules/graphics/src/test/java/test/javafx/animation/RotateTransitionTest.java
Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:
@@ -21,12 +21,17 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package javafx.animation;
+package test.javafx.animation;
+import javafx.animation.AnimationShim;
+import javafx.animation.Interpolator;
+import javafx.animation.ParallelTransition;
+import javafx.animation.RotateTransition;
+import javafx.animation.TransitionShim;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import javafx.geometry.Point3D;
@@ -130,39 +135,39 @@
public void testInterpolate() {
final RotateTransition t0 = new RotateTransition(ONE_SEC, node);
t0.setFromAngle(0.5);
t0.setToAngle(1.0);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(0.5, node.getRotate(), EPSILON);
- t0.interpolate(0.4);
+ TransitionShim.interpolate(t0,0.4);
assertEquals(0.7, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(1.0, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
}
@Test
public void testAxis() {
final Point3D defaultAxis = new Point3D(0.0, 0.0, 1.0);
final Point3D axis = new Point3D(1.0, 0.0, 0.0);
final RotateTransition t0 = new RotateTransition(ONE_SEC, node);
t0.setAxis(axis);
node.setRotationAxis(defaultAxis);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
assertEquals(axis, node.getRotationAxis());
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
t0.setAxis(null);
node.setRotationAxis(defaultAxis);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
assertEquals(defaultAxis, node.getRotationAxis());
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
}
@Test
public void testValueCombinations() {
final RotateTransition t0 = new RotateTransition(ONE_SEC, node);
@@ -174,108 +179,108 @@
// no value set
node.setRotate(originalAngle);
t0.setFromAngle(Double.NaN);
t0.setToAngle(Double.NaN);
t0.setByAngle(0.0);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(originalAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(originalAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// only from-value set
node.setRotate(originalAngle);
t0.setFromAngle(fromAngle);
t0.setToAngle(Double.NaN);
t0.setByAngle(0.0);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(fromAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(fromAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// only to-value set
node.setRotate(originalAngle);
t0.setFromAngle(Double.NaN);
t0.setToAngle(toAngle);
t0.setByAngle(0.0);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(originalAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(toAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// only by-value set
node.setRotate(originalAngle);
t0.setFromAngle(Double.NaN);
t0.setToAngle(Double.NaN);
t0.setByAngle(byAngle);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(originalAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(originalAngle + byAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// from- and to-values set
node.setRotate(originalAngle);
t0.setFromAngle(fromAngle);
t0.setToAngle(toAngle);
t0.setByAngle(0.0);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(fromAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(toAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// from- and by-values set
node.setRotate(originalAngle);
t0.setFromAngle(fromAngle);
t0.setToAngle(Double.NaN);
t0.setByAngle(byAngle);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(fromAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(fromAngle + byAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// to- and by-values set
node.setRotate(originalAngle);
t0.setFromAngle(Double.NaN);
t0.setToAngle(toAngle);
t0.setByAngle(byAngle);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(originalAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(toAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// all values set
node.setRotate(originalAngle);
t0.setFromAngle(fromAngle);
t0.setToAngle(toAngle);
t0.setByAngle(byAngle);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
- t0.interpolate(0.0);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(fromAngle, node.getRotate(), EPSILON);
- t0.interpolate(1.0);
+ TransitionShim.interpolate(t0,1.0);
assertEquals(toAngle, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
}
@Test
public void testGetTargetNode() {
final RotateTransition rt = new RotateTransition(ONE_SEC, node);
@@ -286,118 +291,118 @@
final ParallelTransition pt = new ParallelTransition();
pt.getChildren().add(rt);
pt.setNode(node2);
// node set, parent set
- assertTrue(rt.impl_startable(true));
- rt.impl_start(true);
- rt.interpolate(0.5);
+ assertTrue(AnimationShim.impl_startable(rt,true));
+ AnimationShim.impl_start(rt,true);
+ TransitionShim.interpolate(rt,0.5);
assertEquals(0.75, node.getRotate(), EPSILON);
assertEquals(0.0, node2.getRotate(), EPSILON);
- rt.impl_finished();
+ AnimationShim.impl_finished(rt);
// node null, parent set
rt.setNode(null);
- assertTrue(rt.impl_startable(true));
- rt.impl_start(true);
- rt.interpolate(0.4);
+ assertTrue(AnimationShim.impl_startable(rt,true));
+ AnimationShim.impl_start(rt,true);
+ TransitionShim.interpolate(rt,0.4);
assertEquals(0.75, node.getRotate(), EPSILON);
assertEquals(0.7, node2.getRotate(), EPSILON);
- rt.impl_finished();
+ AnimationShim.impl_finished(rt);
// node null, parent null
pt.setNode(null);
- assertFalse(rt.impl_startable(true));
+ assertFalse(AnimationShim.impl_startable(rt,true));
}
@Test
public void testCachedValues() {
final RotateTransition rt = new RotateTransition(ONE_SEC, node);
rt.setInterpolator(Interpolator.LINEAR);
rt.setFromAngle(0.5);
rt.setToAngle(1.0);
// start
- assertTrue(rt.impl_startable(true));
- rt.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(rt,true));
+ AnimationShim.impl_start(rt,true);
rt.setFromAngle(0.0);
- rt.interpolate(0.5);
+ TransitionShim.interpolate(rt,0.5);
assertEquals(0.75, node.getRotate(), EPSILON);
- rt.impl_finished();
+ AnimationShim.impl_finished(rt);
rt.setFromAngle(0.5);
// end
- assertTrue(rt.impl_startable(true));
- rt.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(rt,true));
+ AnimationShim.impl_start(rt,true);
rt.setToAngle(0.0);
- rt.interpolate(0.2);
+ TransitionShim.interpolate(rt,0.2);
assertEquals(0.6, node.getRotate(), EPSILON);
- rt.impl_finished();
+ AnimationShim.impl_finished(rt);
rt.setToAngle(1.0);
// node
- assertTrue(rt.impl_startable(true));
- rt.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(rt,true));
+ AnimationShim.impl_start(rt,true);
rt.setNode(null);
- rt.interpolate(0.7);
+ TransitionShim.interpolate(rt,0.7);
assertEquals(0.85, node.getRotate(), EPSILON);
- rt.impl_finished();
+ AnimationShim.impl_finished(rt);
rt.setNode(node);
// interpolator
- assertTrue(rt.impl_startable(true));
- rt.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(rt,true));
+ AnimationShim.impl_start(rt,true);
rt.setInterpolator(null);
- rt.interpolate(0.1);
+ TransitionShim.interpolate(rt,0.1);
assertEquals(0.55, node.getRotate(), EPSILON);
- rt.impl_finished();
+ AnimationShim.impl_finished(rt);
rt.setInterpolator(Interpolator.LINEAR);
}
@Test
public void testStartable() {
final RotateTransition t0 = new RotateTransition(Duration.ONE, node);
- assertTrue(t0.impl_startable(true));
+ assertTrue(AnimationShim.impl_startable(t0,true));
// duration is 0
t0.setDuration(Duration.ZERO);
- assertFalse(t0.impl_startable(true));
+ assertFalse(AnimationShim.impl_startable(t0,true));
t0.setDuration(Duration.ONE);
- assertTrue(t0.impl_startable(true));
+ assertTrue(AnimationShim.impl_startable(t0,true));
// node is null
t0.setNode(null);
- assertFalse(t0.impl_startable(true));
+ assertFalse(AnimationShim.impl_startable(t0,true));
t0.setNode(node);
- assertTrue(t0.impl_startable(true));
+ assertTrue(AnimationShim.impl_startable(t0,true));
// interpolator is null
t0.setInterpolator(null);
- assertFalse(t0.impl_startable(true));
+ assertFalse(AnimationShim.impl_startable(t0,true));
t0.setInterpolator(Interpolator.LINEAR);
- assertTrue(t0.impl_startable(true));
+ assertTrue(AnimationShim.impl_startable(t0,true));
}
@Test
public void testEvaluateStartValue() {
final RotateTransition t0 = new RotateTransition(Duration.INDEFINITE, node);
// first run
node.setRotate(0.6);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
node.setRotate(0.8);
- t0.interpolate(0.0);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(0.6, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
// second run
node.setRotate(0.2);
- assertTrue(t0.impl_startable(true));
- t0.impl_start(true);
+ assertTrue(AnimationShim.impl_startable(t0,true));
+ AnimationShim.impl_start(t0,true);
node.setRotate(0.8);
- t0.interpolate(0.0);
+ TransitionShim.interpolate(t0,0.0);
assertEquals(0.2, node.getRotate(), EPSILON);
- t0.impl_finished();
+ AnimationShim.impl_finished(t0);
}
}