< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 234,244 **** final Duration duration = Duration.millis(0.01); animation.shim_setCycleDuration(duration); assertTrue(animation.getCycleDuration().greaterThan(Duration.ZERO)); // should not be startable ! assertFalse(animation.impl_startable(true)); // jump animation.jumpTo(Duration.ZERO); assertEquals(Duration.ZERO, animation.getCurrentTime()); assertEquals(0, clipEnvelope.getLastJumpTo()); --- 234,244 ---- final Duration duration = Duration.millis(0.01); animation.shim_setCycleDuration(duration); assertTrue(animation.getCycleDuration().greaterThan(Duration.ZERO)); // should not be startable ! assertFalse(animation.startable(true)); // jump animation.jumpTo(Duration.ZERO); assertEquals(Duration.ZERO, animation.getCurrentTime()); assertEquals(0, clipEnvelope.getLastJumpTo());
*** 409,457 **** } @Test public void testStart() { // cycleDuration = 1000ms ! assertTrue(animation.impl_startable(true)); ! animation.impl_start(true); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(1.0, animation.getCurrentRate(), EPSILON); assertEquals(6000, clipEnvelope.getTimelineTicks()); assertEquals(1.0, clipEnvelope.getRate(), EPSILON); assertEquals(false, clipEnvelope.getAutoReverse()); assertEquals(1, clipEnvelope.getCycleCount()); ! animation.shim_impl_finished(); // change all values and try again animation.shim_setCycleDuration(TWO_SECS); animation.setRate(-2.0); animation.setAutoReverse(true); animation.setCycleCount(Animation.INDEFINITE); ! assertTrue(animation.impl_startable(true)); ! animation.impl_start(true); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(-2.0, animation.getCurrentRate(), EPSILON); assertEquals(12000, clipEnvelope.getTimelineTicks()); assertEquals(-2.0, clipEnvelope.getRate(), EPSILON); assertEquals(true, clipEnvelope.getAutoReverse()); assertEquals(Animation.INDEFINITE, clipEnvelope.getCycleCount()); ! animation.shim_impl_finished(); // cycleDuration = 0 animation.shim_setCycleDuration(Duration.ZERO); ! assertFalse(animation.impl_startable(true)); } @Test public void testChangeCycleDurationAfterFinish_RT32657() { animation.shim_setCycleDuration(TWO_SECS); animation.play(); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(Duration.ZERO, animation.getCurrentTime()); ! animation.impl_setCurrentTicks(12000); assertEquals(TWO_SECS, animation.getCurrentTime()); ! animation.shim_impl_finished(); animation.shim_setCycleDuration(ONE_SEC); animation.play(); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(Duration.ZERO, animation.getCurrentTime()); --- 409,457 ---- } @Test public void testStart() { // cycleDuration = 1000ms ! assertTrue(animation.startable(true)); ! animation.doStart(true); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(1.0, animation.getCurrentRate(), EPSILON); assertEquals(6000, clipEnvelope.getTimelineTicks()); assertEquals(1.0, clipEnvelope.getRate(), EPSILON); assertEquals(false, clipEnvelope.getAutoReverse()); assertEquals(1, clipEnvelope.getCycleCount()); ! animation.shim_finished(); // change all values and try again animation.shim_setCycleDuration(TWO_SECS); animation.setRate(-2.0); animation.setAutoReverse(true); animation.setCycleCount(Animation.INDEFINITE); ! assertTrue(animation.startable(true)); ! animation.doStart(true); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(-2.0, animation.getCurrentRate(), EPSILON); assertEquals(12000, clipEnvelope.getTimelineTicks()); assertEquals(-2.0, clipEnvelope.getRate(), EPSILON); assertEquals(true, clipEnvelope.getAutoReverse()); assertEquals(Animation.INDEFINITE, clipEnvelope.getCycleCount()); ! animation.shim_finished(); // cycleDuration = 0 animation.shim_setCycleDuration(Duration.ZERO); ! assertFalse(animation.startable(true)); } @Test public void testChangeCycleDurationAfterFinish_RT32657() { animation.shim_setCycleDuration(TWO_SECS); animation.play(); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(Duration.ZERO, animation.getCurrentTime()); ! animation.setCurrentTicks(12000); assertEquals(TWO_SECS, animation.getCurrentTime()); ! animation.shim_finished(); animation.shim_setCycleDuration(ONE_SEC); animation.play(); assertEquals(Status.RUNNING, animation.getStatus()); assertEquals(Duration.ZERO, animation.getCurrentTime());
*** 461,486 **** public void testFinished() { final OnFinishedListener listener = new OnFinishedListener(); animation.setOnFinished(listener); // stopped timeline ! animation.shim_impl_finished(); assertEquals(Status.STOPPED, animation.getStatus()); assertEquals(0.0, animation.getCurrentRate(), EPSILON); assertTrue(listener.wasCalled); // playing timeline animation.play(); ! animation.shim_impl_finished(); assertEquals(Status.STOPPED, animation.getStatus()); assertEquals(0.0, animation.getCurrentRate(), EPSILON); assertTrue(listener.wasCalled); // paused timeline animation.play(); animation.pause(); ! animation.shim_impl_finished(); assertEquals(Status.STOPPED, animation.getStatus()); assertEquals(0.0, animation.getCurrentRate(), EPSILON); assertTrue(listener.wasCalled); } --- 461,486 ---- public void testFinished() { final OnFinishedListener listener = new OnFinishedListener(); animation.setOnFinished(listener); // stopped timeline ! animation.shim_finished(); assertEquals(Status.STOPPED, animation.getStatus()); assertEquals(0.0, animation.getCurrentRate(), EPSILON); assertTrue(listener.wasCalled); // playing timeline animation.play(); ! animation.shim_finished(); assertEquals(Status.STOPPED, animation.getStatus()); assertEquals(0.0, animation.getCurrentRate(), EPSILON); assertTrue(listener.wasCalled); // paused timeline animation.play(); animation.pause(); ! animation.shim_finished(); assertEquals(Status.STOPPED, animation.getStatus()); assertEquals(0.0, animation.getCurrentRate(), EPSILON); assertTrue(listener.wasCalled); }
*** 499,509 **** try { System.setErr(nirvana); } catch (SecurityException ex) { // ignore } ! animation.shim_impl_finished(); try { System.setErr(defaultErrorStream); } catch (SecurityException ex) { // ignore } --- 499,509 ---- try { System.setErr(nirvana); } catch (SecurityException ex) { // ignore } ! animation.shim_finished(); try { System.setErr(defaultErrorStream); } catch (SecurityException ex) { // ignore }
*** 516,526 **** try { System.setErr(nirvana); } catch (SecurityException ex) { // ignore } ! animation.shim_impl_finished(); try { System.setErr(defaultErrorStream); } catch (SecurityException ex) { // ignore } --- 516,526 ---- try { System.setErr(nirvana); } catch (SecurityException ex) { // ignore } ! animation.shim_finished(); try { System.setErr(defaultErrorStream); } catch (SecurityException ex) { // ignore }
*** 534,544 **** try { System.setErr(nirvana); } catch (SecurityException ex) { // ignore } ! animation.shim_impl_finished(); try { System.setErr(defaultErrorStream); } catch (SecurityException ex) { // ignore } --- 534,544 ---- try { System.setErr(nirvana); } catch (SecurityException ex) { // ignore } ! animation.shim_finished(); try { System.setErr(defaultErrorStream); } catch (SecurityException ex) { // ignore }
*** 550,595 **** @Test public void testFullSpeedResolution() { final int resolution = Toolkit.getToolkit().getMasterTimer().getDefaultResolution(); // send pulse ! animation.impl_timePulse(4 * resolution); assertEquals(4 * resolution, clipEnvelope.getLastTimePulse()); // send half pulse ! animation.impl_timePulse(Math.round(4.5 * resolution)); assertEquals(Math.round(4.5 * resolution), clipEnvelope.getLastTimePulse()); // send full pulse ! animation.impl_timePulse(Math.round(5.5 * resolution)); assertEquals(Math.round(5.5 * resolution), clipEnvelope.getLastTimePulse()); // send half pulse ! animation.impl_timePulse(6 * resolution); assertEquals(6 * resolution, clipEnvelope.getLastTimePulse()); } @Test public void testCustomResolution() { final int resolution = 100; animation = new AnimationImpl(timer, clipEnvelope, resolution); // send pulse ! animation.impl_timePulse(4 * resolution); assertEquals(4 * resolution, clipEnvelope.getLastTimePulse()); // send half pulse ! animation.impl_timePulse(Math.round(4.5 * resolution)); assertEquals(0, clipEnvelope.getLastTimePulse()); // send full pulse ! animation.impl_timePulse(Math.round(5.5 * resolution)); assertEquals(Math.round(5.5 * resolution), clipEnvelope.getLastTimePulse()); // send half pulse, this time it should trigger a pulse ! animation.impl_timePulse(6 * resolution); assertEquals(6 * resolution, clipEnvelope.getLastTimePulse()); } private static class OnFinishedListener implements EventHandler<ActionEvent> { --- 550,595 ---- @Test public void testFullSpeedResolution() { final int resolution = Toolkit.getToolkit().getMasterTimer().getDefaultResolution(); // send pulse ! animation.doTimePulse(4 * resolution); assertEquals(4 * resolution, clipEnvelope.getLastTimePulse()); // send half pulse ! animation.doTimePulse(Math.round(4.5 * resolution)); assertEquals(Math.round(4.5 * resolution), clipEnvelope.getLastTimePulse()); // send full pulse ! animation.doTimePulse(Math.round(5.5 * resolution)); assertEquals(Math.round(5.5 * resolution), clipEnvelope.getLastTimePulse()); // send half pulse ! animation.doTimePulse(6 * resolution); assertEquals(6 * resolution, clipEnvelope.getLastTimePulse()); } @Test public void testCustomResolution() { final int resolution = 100; animation = new AnimationImpl(timer, clipEnvelope, resolution); // send pulse ! animation.doTimePulse(4 * resolution); assertEquals(4 * resolution, clipEnvelope.getLastTimePulse()); // send half pulse ! animation.doTimePulse(Math.round(4.5 * resolution)); assertEquals(0, clipEnvelope.getLastTimePulse()); // send full pulse ! animation.doTimePulse(Math.round(5.5 * resolution)); assertEquals(Math.round(5.5 * resolution), clipEnvelope.getLastTimePulse()); // send half pulse, this time it should trigger a pulse ! animation.doTimePulse(6 * resolution); assertEquals(6 * resolution, clipEnvelope.getLastTimePulse()); } private static class OnFinishedListener implements EventHandler<ActionEvent> {
< prev index next >