Skip to content

Commit 9ae37f1

Browse files
committed
8236753: Animations do not play backwards after being stopped
Reviewed-by: kcr, arapte
1 parent 16cea41 commit 9ae37f1

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

modules/javafx.graphics/src/main/java/javafx/animation/Animation.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private void set(T value) {
256256
/* Package-private for testing purposes */
257257
ClipEnvelope clipEnvelope;
258258

259-
private boolean lastPlayedFinished = false;
259+
private boolean lastPlayedFinished = true;
260260

261261
private boolean lastPlayedForward = true;
262262
/**
@@ -978,6 +978,7 @@ public void stop() {
978978
clipEnvelope.abortCurrentPulse();
979979
doStop();
980980
jumpTo(Duration.ZERO);
981+
lastPlayedFinished = true;
981982
}
982983
}
983984

modules/javafx.graphics/src/test/java/test/javafx/animation/AnimationTest.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,19 @@ public void testPlay() {
322322
assertFalse(listener.wasCalled);
323323
assertFalse(timer.containsPulseReceiver(animation.shim_pulseReceiver()));
324324
animation.stop();
325-
animation.setRate(1.0);
325+
326+
// stopped timeline, rate = -1
327+
listener.wasCalled = false;
328+
animation.setRate(-1.0);
329+
animation.play();
330+
assertEquals(ONE_SEC.toMillis(), animation.getCurrentTime().toMillis(), EPSILON);
331+
assertFalse(listener.wasCalled);
332+
assertTrue(timer.containsPulseReceiver(animation.shim_pulseReceiver()));
333+
animation.stop();
326334

327335
// stopped timeline, cycleDuration = 0
328336
listener.wasCalled = false;
337+
animation.setRate(1.0);
329338
animation.shim_setCycleDuration(Duration.ZERO);
330339
animation.play();
331340
assertEquals(Status.STOPPED, animation.getStatus());

modules/javafx.graphics/src/test/java/test/javafx/animation/SequentialTransitionPlayTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ public void testCycleReverse() {
637637
st.play();
638638

639639
assertEquals(Status.RUNNING, st.getStatus());
640-
assertEquals(Status.RUNNING, child1X.getStatus());
641-
assertEquals(Status.STOPPED, child1Y.getStatus());
642-
assertEquals(0, xProperty.get());
643-
assertEquals(0, yProperty.get());
640+
assertEquals(Status.STOPPED, child1X.getStatus());
641+
assertEquals(Status.RUNNING, child1Y.getStatus());
642+
assertEquals(60000, xProperty.get());
643+
assertTrue(0 < yProperty.get() && yProperty.get() < 10000);
644644

645645
st.jumpTo(TickCalculation.toDuration(100));
646646

0 commit comments

Comments
 (0)