6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.animation;
27
28 import com.sun.javafx.animation.TickCalculation;
29 import javafx.animation.Animation.Status;
30 import javafx.beans.property.LongProperty;
31 import javafx.beans.property.SimpleLongProperty;
32 import javafx.util.Duration;
33 import static org.junit.Assert.assertEquals;
34 import org.junit.Before;
35 import org.junit.Test;
36
37 public class ParallelTransitionPlayTest {
38 public static final double TICK_MILLIS = TickCalculation.toMillis(100);
39 public static final long TICK_STEP = Math.round(TICK_MILLIS);
40
41 LongProperty xProperty = new SimpleLongProperty();
42 LongProperty yProperty = new SimpleLongProperty();
43
44 AbstractMasterTimerMock amt;
45 ParallelTransition pt;
46
47 Transition child1X;
48 Transition child2X;
49 Transition child1Y;
50 Transition childByX;
51
52 @Before
53 public void setUp() {
54 amt = new AbstractMasterTimerMock();
55 pt = new ParallelTransition(amt);
56 child1X = new Transition() {
57
58 {
59 setCycleDuration(Duration.minutes(1));
60 setInterpolator(Interpolator.LINEAR);
61 }
62
63 @Override
64 protected void interpolate(double d) {
65 xProperty.set(Math.round(d * 60000));
66 }
67 };
68 child1Y = new Transition() {
69
70 {
71 setCycleDuration(Duration.seconds(10));
72 setInterpolator(Interpolator.LINEAR);
73 }
74
75 @Override
76 protected void interpolate(double d) {
77 yProperty.set(Math.round(d * 10000));
78 }
79 };
80 childByX = new Transition() {
81 {
82 setCycleDuration(Duration.seconds(1));
83 setInterpolator(Interpolator.LINEAR);
84 }
85
86 long lastX;
87
88 @Override
89 protected void interpolate(double frac) {
90 xProperty.set(Math.round(lastX + frac * 1000));
91 }
92
93 @Override
94 void impl_sync(boolean forceSync) {
95 super.impl_sync(forceSync);
96 if (forceSync) {
97 lastX = xProperty.get();
98 }
99 }
100
101
102 };
103 }
104
105
106 @Test
107 public void testSimplePlay() {
108 pt.getChildren().addAll(child1X, child1Y);
109
110 pt.play();
111 assertEquals(Status.RUNNING, pt.getStatus());
112 assertEquals(Status.STOPPED, child1X.getStatus());
113 assertEquals(Status.STOPPED, child1Y.getStatus());
114
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package test.javafx.animation;
27
28 import com.sun.javafx.animation.TickCalculation;
29 import javafx.animation.Animation.Status;
30 import javafx.animation.Interpolator;
31 import javafx.animation.ParallelTransition;
32 import javafx.animation.ParallelTransitionShim;
33 import javafx.animation.Transition;
34 import javafx.animation.TransitionShim;
35 import javafx.beans.property.LongProperty;
36 import javafx.beans.property.SimpleLongProperty;
37 import javafx.util.Duration;
38 import static org.junit.Assert.assertEquals;
39 import org.junit.Before;
40 import org.junit.Test;
41
42 public class ParallelTransitionPlayTest {
43 public static final double TICK_MILLIS = TickCalculation.toMillis(100);
44 public static final long TICK_STEP = Math.round(TICK_MILLIS);
45
46 LongProperty xProperty = new SimpleLongProperty();
47 LongProperty yProperty = new SimpleLongProperty();
48
49 AbstractMasterTimerMock amt;
50 ParallelTransition pt;
51
52 Transition child1X;
53 Transition child2X;
54 Transition child1Y;
55 Transition childByX;
56
57 @Before
58 public void setUp() {
59 amt = new AbstractMasterTimerMock();
60 pt = ParallelTransitionShim.getParallelTransition(amt);
61 child1X = new TransitionShim() {
62
63 {
64 setCycleDuration(Duration.minutes(1));
65 setInterpolator(Interpolator.LINEAR);
66 }
67
68 @Override
69 protected void interpolate(double d) {
70 xProperty.set(Math.round(d * 60000));
71 }
72 };
73 child1Y = new TransitionShim() {
74
75 {
76 setCycleDuration(Duration.seconds(10));
77 setInterpolator(Interpolator.LINEAR);
78 }
79
80 @Override
81 protected void interpolate(double d) {
82 yProperty.set(Math.round(d * 10000));
83 }
84 };
85 childByX = new TransitionShim() {
86 {
87 setCycleDuration(Duration.seconds(1));
88 setInterpolator(Interpolator.LINEAR);
89 }
90
91 long lastX;
92
93 @Override
94 protected void interpolate(double frac) {
95 xProperty.set(Math.round(lastX + frac * 1000));
96 }
97
98 @Override
99 public void impl_sync(boolean forceSync) {
100 super.impl_sync(forceSync);
101 if (forceSync) {
102 lastX = xProperty.get();
103 }
104 }
105
106
107 };
108 }
109
110
111 @Test
112 public void testSimplePlay() {
113 pt.getChildren().addAll(child1X, child1Y);
114
115 pt.play();
116 assertEquals(Status.RUNNING, pt.getStatus());
117 assertEquals(Status.STOPPED, child1X.getStatus());
118 assertEquals(Status.STOPPED, child1Y.getStatus());
119
|