modules/graphics/src/test/java/test/com/sun/scenario/animation/shared/FiniteClipEnvelopeTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:


   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 com.sun.scenario.animation.shared;
  27 
  28 
  29 import com.sun.javafx.tk.Toolkit;




  30 import javafx.animation.Animation;
  31 import javafx.animation.Animation.Status;
  32 import javafx.animation.AnimationMock;
  33 import javafx.animation.AnimationMock.Command;
  34 import javafx.util.Duration;
  35 import org.junit.Before;
  36 import org.junit.Test;
  37 
  38 import static org.junit.Assert.*;
  39 
  40 public class FiniteClipEnvelopeTest {
  41 
  42     private final long CYCLE_TICKS = Math.round(6.0 * AnimationMock.DEFAULT_DURATION.toMillis());
  43 
  44     private ClipEnvelope clip;
  45     private AnimationMock animation;
  46     
  47     @Before
  48     public void setUp() {
  49         animation = new AnimationMock(Toolkit.getToolkit().getMasterTimer(), AnimationMock.DEFAULT_DURATION, AnimationMock.DEFAULT_RATE, 9, AnimationMock.DEFAULT_AUTOREVERSE);
  50         clip = new FiniteClipEnvelope(animation);
  51     }
  52     
  53     @Test
  54     public void testSetValues() {
  55         ClipEnvelope c;
  56         
  57         // Setting cycleCount to 1
  58         animation.setCycleCount(1);
  59         animation.mockCycleDuration(AnimationMock.DEFAULT_DURATION);
  60         c = clip.setCycleCount(1);
  61         assertNotSame(clip, c);
  62         assertTrue(c instanceof SingleLoopClipEnvelope);
  63         
  64         // Setting cycleCount to INDEFINITE
  65         animation.setCycleCount(Animation.INDEFINITE);
  66         animation.mockCycleDuration(AnimationMock.DEFAULT_DURATION);
  67         c = clip.setCycleCount(Animation.INDEFINITE);
  68         assertNotSame(clip, c);
  69         assertTrue(c instanceof InfiniteClipEnvelope);
  70         




   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.com.sun.scenario.animation.shared;
  27 
  28 
  29 import com.sun.javafx.tk.Toolkit;
  30 import com.sun.scenario.animation.shared.ClipEnvelope;
  31 import com.sun.scenario.animation.shared.FiniteClipEnvelopeShim;
  32 import com.sun.scenario.animation.shared.InfiniteClipEnvelope;
  33 import com.sun.scenario.animation.shared.SingleLoopClipEnvelope;
  34 import javafx.animation.Animation;
  35 import javafx.animation.Animation.Status;
  36 import test.javafx.animation.AnimationMock;
  37 import test.javafx.animation.AnimationMock.Command;
  38 import javafx.util.Duration;
  39 import org.junit.Before;
  40 import org.junit.Test;
  41 
  42 import static org.junit.Assert.*;
  43 
  44 public class FiniteClipEnvelopeTest {
  45 
  46     private final long CYCLE_TICKS = Math.round(6.0 * AnimationMock.DEFAULT_DURATION.toMillis());
  47 
  48     private ClipEnvelope clip;
  49     private AnimationMock animation;
  50     
  51     @Before
  52     public void setUp() {
  53         animation = new AnimationMock(Toolkit.getToolkit().getMasterTimer(), AnimationMock.DEFAULT_DURATION, AnimationMock.DEFAULT_RATE, 9, AnimationMock.DEFAULT_AUTOREVERSE);
  54         clip = new FiniteClipEnvelopeShim(animation);
  55     }
  56     
  57     @Test
  58     public void testSetValues() {
  59         ClipEnvelope c;
  60         
  61         // Setting cycleCount to 1
  62         animation.setCycleCount(1);
  63         animation.mockCycleDuration(AnimationMock.DEFAULT_DURATION);
  64         c = clip.setCycleCount(1);
  65         assertNotSame(clip, c);
  66         assertTrue(c instanceof SingleLoopClipEnvelope);
  67         
  68         // Setting cycleCount to INDEFINITE
  69         animation.setCycleCount(Animation.INDEFINITE);
  70         animation.mockCycleDuration(AnimationMock.DEFAULT_DURATION);
  71         c = clip.setCycleCount(Animation.INDEFINITE);
  72         assertNotSame(clip, c);
  73         assertTrue(c instanceof InfiniteClipEnvelope);
  74