modules/graphics/src/test/java/test/javafx/animation/FadeTransitionTest.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.FadeTransition;
+import javafx.animation.Interpolator;
+import javafx.animation.ParallelTransition;
+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.scene.Node;

@@ -123,19 +128,19 @@
         public void testInterpolate() {
                 final FadeTransition t0 = new FadeTransition(ONE_SEC, node);
                 t0.setFromValue(0.5);
                 t0.setToValue(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.getOpacity(), EPSILON);
-                t0.interpolate(0.4);
+                TransitionShim.interpolate(t0,0.4);
                 assertEquals(0.7, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(1.0, node.getOpacity(), EPSILON);
-        t0.impl_finished();
+                AnimationShim.impl_finished(t0);
         }
         
         @Test
         public void testValueCombinations() {
                 final FadeTransition t0 = new FadeTransition(ONE_SEC, node);

@@ -147,166 +152,166 @@
                 // no value set
                 node.setOpacity(originalValue);
                 t0.setFromValue(Double.NaN);
                 t0.setToValue(Double.NaN);
                 t0.setByValue(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(originalValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(originalValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // only from-value set
                 node.setOpacity(originalValue);
                 t0.setFromValue(fromValue);
                 t0.setToValue(Double.NaN);
                 t0.setByValue(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(fromValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(fromValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // only to-value set
                 node.setOpacity(originalValue);
                 t0.setFromValue(Double.NaN);
                 t0.setToValue(toValue);
                 t0.setByValue(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(originalValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(toValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // only by-value set
                 node.setOpacity(originalValue);
                 t0.setFromValue(Double.NaN);
                 t0.setToValue(Double.NaN);
                 t0.setByValue(byValue);
-                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(originalValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(originalValue + byValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // from- and to-values set
                 node.setOpacity(originalValue);
                 t0.setFromValue(fromValue);
                 t0.setToValue(toValue);
                 t0.setByValue(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(fromValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(toValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // from- and by-values set
                 node.setOpacity(originalValue);
                 t0.setFromValue(fromValue);
                 t0.setToValue(Double.NaN);
                 t0.setByValue(byValue);
-                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(fromValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(fromValue + byValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // to- and by-values set
                 node.setOpacity(originalValue);
                 t0.setFromValue(Double.NaN);
                 t0.setToValue(toValue);
                 t0.setByValue(byValue);
-                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(originalValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(toValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // all values set
                 node.setOpacity(originalValue);
                 t0.setFromValue(fromValue);
                 t0.setToValue(toValue);
                 t0.setByValue(byValue);
-                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(fromValue, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(toValue, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
         }
         
         @Test
         public void testOutOfBoundValues() {
                 final FadeTransition t0 = new FadeTransition(ONE_SEC, node);
                 t0.setInterpolator(Interpolator.LINEAR);
                 
                 // start < 0.0
                 t0.setFromValue(-0.4);
                 t0.setToValue(0.6);
-                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.0, node.getOpacity(), EPSILON);
-                t0.interpolate(0.5);
+                TransitionShim.interpolate(t0,0.5);
                 assertEquals(0.3, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(0.6, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // start > 1.0
                 t0.setFromValue(1.3);
                 t0.setToValue(0.3);
-                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(1.0, node.getOpacity(), EPSILON);
-                t0.interpolate(0.5);
+                TransitionShim.interpolate(t0,0.5);
                 assertEquals(0.65, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(0.3, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // end < 0.0
                 t0.setFromValue(0.2);
                 t0.setToValue(-1.2);
-                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.2, node.getOpacity(), EPSILON);
-                t0.interpolate(0.5);
+                TransitionShim.interpolate(t0,0.5);
                 assertEquals(0.1, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(0.0, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // end > 1.0
                 t0.setFromValue(0.9);
                 t0.setToValue(1.9);
-                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.9, node.getOpacity(), EPSILON);
-                t0.interpolate(0.5);
+                TransitionShim.interpolate(t0,0.5);
                 assertEquals(0.95, node.getOpacity(), EPSILON);
-                t0.interpolate(1.0);
+                TransitionShim.interpolate(t0,1.0);
                 assertEquals(1.0, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
         }
 
     @Test
     public void testGetTargetNode() {
         final FadeTransition ft = new FadeTransition(ONE_SEC, node);

@@ -317,118 +322,118 @@
         final ParallelTransition pt = new ParallelTransition();
         pt.getChildren().add(ft);
         pt.setNode(node2);
 
         // node set, parent set
-        assertTrue(ft.impl_startable(true));
-        ft.impl_start(true);
-        ft.interpolate(0.5);
+        assertTrue(AnimationShim.impl_startable(ft,true));
+        AnimationShim.impl_start(ft,true);
+        TransitionShim.interpolate(ft,0.5);
         assertEquals(0.75, node.getOpacity(), EPSILON);
         assertEquals(1.0, node2.getOpacity(), EPSILON);
-        ft.impl_finished();
+        AnimationShim.impl_finished(ft);
 
         // node null, parent set
         ft.setNode(null);
-        assertTrue(ft.impl_startable(true));
-        ft.impl_start(true);
-        ft.interpolate(0.4);
+        assertTrue(AnimationShim.impl_startable(ft,true));
+        AnimationShim.impl_start(ft,true);
+        TransitionShim.interpolate(ft,0.4);
         assertEquals(0.75, node.getOpacity(), EPSILON);
         assertEquals(0.7, node2.getOpacity(), EPSILON);
-        ft.impl_finished();
+        AnimationShim.impl_finished(ft);
 
         // node null, parent null
         pt.setNode(null);
-        assertFalse(ft.impl_startable(true));
+        assertFalse(AnimationShim.impl_startable(ft,true));
     }
 
     @Test
     public void testCachedValues() {
         final FadeTransition ft = new FadeTransition(ONE_SEC, node);
         ft.setInterpolator(Interpolator.LINEAR);
                 ft.setFromValue(0.5);
                 ft.setToValue(1.0);
 
         // start
-        assertTrue(ft.impl_startable(true));
-        ft.impl_start(true);
+        assertTrue(AnimationShim.impl_startable(ft,true));
+        AnimationShim.impl_start(ft,true);
         ft.setFromValue(0.0);
-        ft.interpolate(0.5);
+        TransitionShim.interpolate(ft,0.5);
         assertEquals(0.75, node.getOpacity(), EPSILON);
-        ft.impl_finished();
+        AnimationShim.impl_finished(ft);
         ft.setFromValue(0.5);
 
         // end
-        assertTrue(ft.impl_startable(true));
-        ft.impl_start(true);
+        assertTrue(AnimationShim.impl_startable(ft,true));
+        AnimationShim.impl_start(ft,true);
         ft.setToValue(0.0);
-        ft.interpolate(0.2);
+        TransitionShim.interpolate(ft,0.2);
         assertEquals(0.6, node.getOpacity(), EPSILON);
-        ft.impl_finished();
+        AnimationShim.impl_finished(ft);
         ft.setToValue(1.0);
 
         // node
-        assertTrue(ft.impl_startable(true));
-        ft.impl_start(true);
+        assertTrue(AnimationShim.impl_startable(ft,true));
+        AnimationShim.impl_start(ft,true);
         ft.setNode(null);
-        ft.interpolate(0.7);
+        TransitionShim.interpolate(ft,0.7);
         assertEquals(0.85, node.getOpacity(), EPSILON);
-        ft.impl_finished();
+        AnimationShim.impl_finished(ft);
         ft.setNode(node);
 
         // interpolator
-        assertTrue(ft.impl_startable(true));
-        ft.impl_start(true);
+        assertTrue(AnimationShim.impl_startable(ft,true));
+        AnimationShim.impl_start(ft,true);
         ft.setInterpolator(null);
-        ft.interpolate(0.1);
+        TransitionShim.interpolate(ft,0.1);
         assertEquals(0.55, node.getOpacity(), EPSILON);
-        ft.impl_finished();
+        AnimationShim.impl_finished(ft);
         ft.setInterpolator(Interpolator.LINEAR);
     }
 
         @Test
         public void testStartable() {
                 final FadeTransition t0 = new FadeTransition(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 FadeTransition t0 = new FadeTransition(Duration.INDEFINITE, node);
                 
                 // first run
                 node.setOpacity(0.6);
-                assertTrue(t0.impl_startable(true));
-                t0.impl_start(true);
+                assertTrue(AnimationShim.impl_startable(t0,true));
+                AnimationShim.impl_start(t0,true);
                 node.setOpacity(0.8);
-                t0.interpolate(0.0);
+                TransitionShim.interpolate(t0,0.0);
                 assertEquals(0.6, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
                 
                 // second run
                 node.setOpacity(0.2);
-                assertTrue(t0.impl_startable(true));
-                t0.impl_start(true);
+                assertTrue(AnimationShim.impl_startable(t0,true));
+                AnimationShim.impl_start(t0,true);
                 node.setOpacity(0.8);
-                t0.interpolate(0.0);
+                TransitionShim.interpolate(t0,0.0);
                 assertEquals(0.2, node.getOpacity(), EPSILON);
-                t0.impl_finished();
+                AnimationShim.impl_finished(t0);
         }
 
 }