changeset 6037:74d25a72690f

RT-35139 [Animation] Regression: Misbehavior of *Transition within ParallelTransition
author Martin Sladecek <martin.sladecek@oracle.com>
date Fri, 03 Jan 2014 09:28:44 +0100
parents c73ad04890cf
children 3e0a4ea8e8f6
files modules/graphics/src/main/java/javafx/animation/ParallelTransition.java modules/graphics/src/main/java/javafx/animation/SequentialTransition.java modules/graphics/src/test/java/javafx/animation/ParallelTransitionPlayTest.java
diffstat 3 files changed, 78 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/javafx/animation/ParallelTransition.java	Fri Jan 03 08:43:56 2014 +0100
+++ b/modules/graphics/src/main/java/javafx/animation/ParallelTransition.java	Fri Jan 03 09:28:44 2014 +0100
@@ -580,12 +580,19 @@
 
     private void jumpToEnd() {
         for (int i = 0 ; i < cachedChildren.length; ++i) {
+            if (forceChildSync[i]) {
+                // See explanation in SequentialTransition#jumpToEnd
+                cachedChildren[i].impl_sync(true);
+            }
             cachedChildren[i].impl_jumpTo(durations[i], durations[i], true);
         }
     }
 
     private void jumpToStart() {
         for (int i = cachedChildren.length - 1 ; i >= 0; --i) {
+            if (forceChildSync[i]) {
+                cachedChildren[i].impl_sync(true);
+            }
             cachedChildren[i].impl_jumpTo(0, durations[i], true);
         }
     }
--- a/modules/graphics/src/main/java/javafx/animation/SequentialTransition.java	Fri Jan 03 08:43:56 2014 +0100
+++ b/modules/graphics/src/main/java/javafx/animation/SequentialTransition.java	Fri Jan 03 09:28:44 2014 +0100
@@ -720,7 +720,7 @@
                 //NOTE: do not clean up forceChildSync[i] here. Another sync will be needed during the play
                 // The reason is we have 2 different use-cases for jumping (1)play from start, (2)play next cycle.
                 // and 2 different types of sub-transitions (A)"by" transitions that need to synchronize on
-                // the current state a move property by certain value and (B)"from-to" transitions that 
+                // the current state and move property by certain value and (B)"from-to" transitions that 
                 // move from one point to another on each play/cycle. We can't query if transition is A or B.
                 //
                 // Now for combination 1A we need to synchronize here, as the subsequent jump would move
--- a/modules/graphics/src/test/java/javafx/animation/ParallelTransitionPlayTest.java	Fri Jan 03 08:43:56 2014 +0100
+++ b/modules/graphics/src/test/java/javafx/animation/ParallelTransitionPlayTest.java	Fri Jan 03 09:28:44 2014 +0100
@@ -47,6 +47,7 @@
     Transition child1X;
     Transition child2X;
     Transition child1Y;
+    Transition childByX;
 
     @Before
     public void setUp() {
@@ -76,7 +77,31 @@
                 yProperty.set(Math.round(d * 10000));
             }
         };
+        childByX = new Transition() {
+            {
+                setCycleDuration(Duration.seconds(1));
+                setInterpolator(Interpolator.LINEAR);
+            }
+
+            long lastX;
+
+            @Override
+            protected void interpolate(double frac) {
+                xProperty.set(Math.round(lastX + frac * 1000));
+            }
+
+            @Override
+            void impl_sync(boolean forceSync) {
+                super.impl_sync(forceSync);
+                if (forceSync) {
+                    lastX = xProperty.get();
+                }
+            }
+
+
+        };
     }
+    
 
     @Test
     public void testSimplePlay() {
@@ -895,5 +920,50 @@
         assertEquals(Status.STOPPED, child1X.getStatus());
         assertEquals(Status.STOPPED, child1Y.getStatus());
     }
+    
+    @Test
+    public void teptPlayFromStartSynchronization() {
+        pt.getChildren().addAll(child1Y, childByX);
+
+        pt.play();
+
+        assertEquals(0, yProperty.get());
+        assertEquals(0, xProperty.get());
+
+        pt.jumpTo(Duration.seconds(10));
+        amt.pulse();
+
+        pt.play();
+        assertEquals(0, yProperty.get());
+        assertEquals(1000, xProperty.get());
+
+        pt.jumpTo(Duration.seconds(10));
+        amt.pulse();
+
+        assertEquals(10000, yProperty.get());
+        assertEquals(2000, xProperty.get());
+
+    }
+    
+    @Test
+    public void teptCycleSynchronization() {
+        pt.setCycleCount(2);
+        pt.getChildren().addAll(childByX);
+
+        pt.play();
+
+        assertEquals(0, xProperty.get());
+
+        pt.jumpTo(Duration.seconds(1));
+        amt.pulse();
+
+        assertEquals(TICK_STEP, xProperty.get());
+
+        pt.jumpTo(Duration.seconds(2));
+        amt.pulse();
+
+        assertEquals(1000, xProperty.get());
+
+    }
 
 }