modules/graphics/src/test/java/test/com/sun/scenario/animation/shared/SimpleClipInterpolatorTest.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 import com.sun.javafx.animation.TickCalculation;

  29 import static org.junit.Assert.assertEquals;
  30 import static org.junit.Assert.assertNotSame;
  31 import static org.junit.Assert.assertSame;
  32 import static org.junit.Assert.assertTrue;
  33 import javafx.animation.KeyFrame;
  34 import javafx.animation.KeyValue;
  35 import javafx.beans.property.IntegerProperty;
  36 import javafx.beans.property.SimpleIntegerProperty;
  37 import javafx.util.Duration;
  38 
  39 import org.junit.Test;
  40 
  41 public class SimpleClipInterpolatorTest {
  42         
  43         @Test
  44         public void testSetKeyFrame() {
  45         final KeyFrame kf1 = new KeyFrame(Duration.ZERO);
  46         final KeyFrame kf2 = new KeyFrame(Duration.millis(1000));
  47         final KeyFrame kf3 = new KeyFrame(Duration.millis(2000));
  48         final SimpleClipInterpolator sci = new SimpleClipInterpolator(kf1, kf2,  6000);
  49         
  50         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{kf1, kf2, kf3}, new long[] {0, 6000, 12000}));
  51         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{kf1, kf2     }, new long[] {0, 6000,      }));
  52         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{kf1,      kf3}, new long[] {0,       12000}));
  53         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{kf1          }, new long[] {0,            }));
  54         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{     kf2, kf3}, new long[] {   6000, 12000}));
  55         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{     kf2     }, new long[] {   6000       }));
  56         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{          kf3}, new long[] {         12000}));
  57         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{             }, new long[] {              }));
  58         }
  59     
  60     @Test
  61     public void test_NoKeyValues() {
  62         final KeyFrame start = new KeyFrame(Duration.ZERO);
  63         final KeyFrame end1 = new KeyFrame(Duration.millis(1000));
  64         final KeyFrame end2 = new KeyFrame(Duration.millis(2000));
  65         
  66         // two key frames
  67         final SimpleClipInterpolator sci1 = new SimpleClipInterpolator (start, end1, 6000);
  68         sci1.validate(true);
  69         sci1.interpolate(TickCalculation.fromMillis(300));
  70         
  71         sci1.validate(true);
  72         sci1.interpolate(TickCalculation.fromMillis(800));
  73         
  74         sci1.setKeyFrames(new KeyFrame[]{start, end2}, new long[] {0, 12000});
  75         sci1.interpolate(TickCalculation.fromMillis(400));
  76         
  77         sci1.validate(true);
  78         sci1.interpolate(TickCalculation.fromMillis(600));
  79         
  80         // one key frame
  81         final SimpleClipInterpolator sci2 = new SimpleClipInterpolator (end1, 6000);
  82         sci2.validate(true);
  83         sci2.interpolate(TickCalculation.fromMillis(300));
  84         
  85         sci2.validate(true);
  86         sci2.interpolate(TickCalculation.fromMillis(800));
  87         
  88         sci2.setKeyFrames(new KeyFrame[]{end2}, new long[] {12000});
  89         sci2.interpolate(TickCalculation.fromMillis(400));
  90         
  91         sci2.validate(true);
  92         sci2.interpolate(TickCalculation.fromMillis(600));
  93     }
  94 
  95     @Test
  96     public void test_TwoKeyFrames_OneKeyValue() {
  97         final IntegerProperty v = new SimpleIntegerProperty();
  98         final KeyFrame start1 = new KeyFrame(Duration.ZERO, new KeyValue(v, 30));
  99         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v, 40));
 100         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v, 60));
 101         
 102         final SimpleClipInterpolator sci1 = new SimpleClipInterpolator (start1, end1, 6000);
 103         v.set(0);
 104         sci1.validate(true);
 105         sci1.interpolate(TickCalculation.fromMillis(0));
 106         assertEquals(30, v.get());
 107         sci1.interpolate(TickCalculation.fromMillis(300));
 108         assertEquals(33, v.get());
 109         sci1.interpolate(TickCalculation.fromMillis(1000));
 110         assertEquals(40, v.get());
 111         
 112         // re-validate
 113         v.set(20);
 114         sci1.validate(true);
 115         sci1.interpolate(TickCalculation.fromMillis(0));
 116         assertEquals(30, v.get());
 117         sci1.interpolate(TickCalculation.fromMillis(800));
 118         assertEquals(38, v.get());
 119         sci1.interpolate(TickCalculation.fromMillis(1000));
 120         assertEquals(40, v.get());
 121         
 122         // set new key frames


 129         sci1.interpolate(TickCalculation.fromMillis(1000));
 130         assertEquals(40, v.get());
 131         
 132         // validate new key frames
 133         sci1.validate(true);
 134         sci1.interpolate(TickCalculation.fromMillis(0));
 135         assertEquals(30, v.get());
 136         sci1.interpolate(TickCalculation.fromMillis(600));
 137         assertEquals(39, v.get());
 138         sci1.interpolate(TickCalculation.fromMillis(2000));
 139         assertEquals(60, v.get());
 140         
 141     }
 142 
 143     @Test
 144     public void test_OneKeyFrame_OneKeyValue() {
 145         final IntegerProperty v = new SimpleIntegerProperty();
 146         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v, 40));
 147         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v, 60));
 148 
 149         final SimpleClipInterpolator sci3 = new SimpleClipInterpolator (end1, 6000);
 150         v.set(0);
 151         sci3.validate(true);
 152         sci3.interpolate(TickCalculation.fromMillis(0));
 153         assertEquals(0, v.get());
 154         sci3.interpolate(TickCalculation.fromMillis(300));
 155         assertEquals(12, v.get());
 156         sci3.interpolate(TickCalculation.fromMillis(1000));
 157         assertEquals(40, v.get());
 158         
 159         // re-validate
 160         v.set(20);
 161         sci3.validate(true);
 162         sci3.interpolate(TickCalculation.fromMillis(0));
 163         assertEquals(20, v.get());
 164         sci3.interpolate(TickCalculation.fromMillis(800));
 165         assertEquals(36, v.get());
 166         sci3.interpolate(TickCalculation.fromMillis(1000));
 167         assertEquals(40, v.get());
 168         
 169         // set new key frames


 179         // validate new key frames
 180         v.set(20);
 181         sci3.validate(true);
 182         sci3.interpolate(TickCalculation.fromMillis(0));
 183         assertEquals(20, v.get());
 184         sci3.interpolate(TickCalculation.fromMillis(600));
 185         assertEquals(32, v.get());
 186         sci3.interpolate(TickCalculation.fromMillis(2000));
 187         assertEquals(60, v.get());
 188     }
 189 
 190     @Test
 191     public void test_TwoKeyFrames_ThreeKeyValues() {
 192         final IntegerProperty v1 = new SimpleIntegerProperty();
 193         final IntegerProperty v2 = new SimpleIntegerProperty();
 194         final IntegerProperty v3 = new SimpleIntegerProperty();
 195         final KeyFrame start1 = new KeyFrame(Duration.ZERO, new KeyValue(v2, 130), new KeyValue(v3, 230));
 196         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v2, 140));
 197         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v1, 60), new KeyValue(v2, 160));
 198         
 199         final SimpleClipInterpolator sci1 = new SimpleClipInterpolator (start1, end1, 6000);
 200         v1.set(  0);
 201         v2.set(100);
 202         v3.set(200);
 203         sci1.validate(true);
 204         sci1.interpolate(TickCalculation.fromMillis(0));
 205         assertEquals(  0, v1.get());
 206         assertEquals(130, v2.get());
 207         assertEquals(200, v3.get());
 208         sci1.interpolate(TickCalculation.fromMillis(300));
 209         assertEquals( 12, v1.get());
 210         assertEquals(133, v2.get());
 211         assertEquals(200, v3.get());
 212         sci1.interpolate(TickCalculation.fromMillis(1000));
 213         assertEquals( 40, v1.get());
 214         assertEquals(140, v2.get());
 215         assertEquals(200, v3.get());
 216         
 217         // re-validate
 218         v1.set( 20);
 219         v2.set(120);


 261         assertEquals(220, v3.get());
 262         sci1.interpolate(TickCalculation.fromMillis(600));
 263         assertEquals( 32, v1.get());
 264         assertEquals(139, v2.get());
 265         assertEquals(220, v3.get());
 266         sci1.interpolate(TickCalculation.fromMillis(2000));
 267         assertEquals( 60, v1.get());
 268         assertEquals(160, v2.get());
 269         assertEquals(220, v3.get());
 270         
 271     }
 272 
 273     @Test
 274     public void test_OneKeyFrames_ThreeKeyValues() {
 275         final IntegerProperty v1 = new SimpleIntegerProperty();
 276         final IntegerProperty v2 = new SimpleIntegerProperty();
 277         final IntegerProperty v3 = new SimpleIntegerProperty();
 278         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v2, 140), new KeyValue(v3, 240));
 279         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v1, 60), new KeyValue(v2, 160), new KeyValue(v3, 260));
 280 
 281         final SimpleClipInterpolator sci1 = new SimpleClipInterpolator (end1, 6000);
 282         v1.set(  0);
 283         v2.set(100);
 284         v3.set(200);
 285         sci1.validate(true);
 286         sci1.interpolate(TickCalculation.fromMillis(0));
 287         assertEquals(  0, v1.get());
 288         assertEquals(100, v2.get());
 289         assertEquals(200, v3.get());
 290         sci1.interpolate(TickCalculation.fromMillis(300));
 291         assertEquals( 12, v1.get());
 292         assertEquals(112, v2.get());
 293         assertEquals(212, v3.get());
 294         sci1.interpolate(TickCalculation.fromMillis(1000));
 295         assertEquals( 40, v1.get());
 296         assertEquals(140, v2.get());
 297         assertEquals(240, v3.get());
 298         
 299         // re-validate
 300         v1.set( 20);
 301         v2.set(120);


 344         sci1.interpolate(TickCalculation.fromMillis(600));
 345         assertEquals( 32, v1.get());
 346         assertEquals(132, v2.get());
 347         assertEquals(232, v3.get());
 348         sci1.interpolate(TickCalculation.fromMillis(2000));
 349         assertEquals( 60, v1.get());
 350         assertEquals(160, v2.get());
 351         assertEquals(260, v3.get());
 352     }
 353 
 354     @Test
 355     public void test_DuplicateKeyValue() {
 356         final IntegerProperty v1 = new SimpleIntegerProperty();
 357         final IntegerProperty v2 = new SimpleIntegerProperty();
 358         final KeyFrame start1 = new KeyFrame(Duration.ZERO, new KeyValue(v1, 30), new KeyValue(v2, 0));
 359         final KeyFrame start2 = new KeyFrame(Duration.ZERO, new KeyValue(v1, 30), new KeyValue(v1, -30), new KeyValue(v2, 0));
 360         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v2, 100));
 361         final KeyFrame end2 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v1, -40), new KeyValue(v2, 100));
 362 
 363         // single value in start, duplicate value in end
 364         final SimpleClipInterpolator sci1 = new SimpleClipInterpolator (start1, end2, 6000);
 365         v1.set(0);
 366         v2.set(0);
 367         sci1.validate(true);
 368         sci1.interpolate(TickCalculation.fromMillis(0));
 369         assertEquals(30, v1.get());
 370         assertEquals(0, v2.get());
 371         sci1.interpolate(TickCalculation.fromMillis(300));
 372         assertTrue("v1.get(): " + v1.get(), (33 == v1.get()) || (9 == v1.get()));
 373         assertEquals(30, v2.get());
 374         sci1.interpolate(TickCalculation.fromMillis(1000));
 375         assertTrue("v1.get(): " + v1.get(), (40 == v1.get()) || (-40 == v1.get()));
 376         assertEquals(100, v2.get());
 377 
 378         // duplicate value in start, single value in end
 379         final SimpleClipInterpolator sci2 = new SimpleClipInterpolator (start2, end1, 6000);
 380         v1.set(0);
 381         v2.set(0);
 382         sci2.validate(true);
 383         sci2.interpolate(TickCalculation.fromMillis(0));
 384         assertTrue("v1.get(): " + v1.get(), (30 == v1.get()) || (-30 == v1.get()));
 385         assertEquals(0, v2.get());
 386         sci2.interpolate(TickCalculation.fromMillis(300));
 387         assertTrue("v1.get(): " + v1.get(), (33 == v1.get()) || (-9 == v1.get()));
 388         assertEquals(30, v2.get());
 389         sci2.interpolate(TickCalculation.fromMillis(1000));
 390         assertEquals(40, v1.get());
 391         assertEquals(100, v2.get());
 392 
 393         // duplicate value in start, duplicate value in end
 394         final SimpleClipInterpolator sci3 = new SimpleClipInterpolator (start2, end2, 6000);
 395         v1.set(0);
 396         v2.set(0);
 397         sci3.validate(true);
 398         sci3.interpolate(TickCalculation.fromMillis(0));
 399         assertTrue("v1.get(): " + v1.get(), (30 == v1.get()) || (-30 == v1.get()));
 400         assertEquals(0, v2.get());
 401         sci3.interpolate(TickCalculation.fromMillis(300));
 402         assertTrue("v1.get(): " + v1.get(), (33 == v1.get()) || (9 == v1.get()) || (-9 == v1.get()) || (-33 == v1.get()));
 403         assertEquals(30, v2.get());
 404         sci3.interpolate(TickCalculation.fromMillis(1000));
 405         assertTrue("v1.get(): " + v1.get(), (40 == v1.get()) || (-40 == v1.get()));
 406         assertEquals(100, v2.get());
 407 
 408         // no value in start, duplicate value in end
 409         final SimpleClipInterpolator sci4 = new SimpleClipInterpolator (end2, 6000);
 410         v1.set(0);
 411         v2.set(0);
 412         sci4.validate(true);
 413         sci4.interpolate(TickCalculation.fromMillis(0));
 414         assertEquals(0, v1.get());
 415         assertEquals(0, v2.get());
 416         sci4.interpolate(TickCalculation.fromMillis(400));
 417         assertTrue("v1.get(): " + v1.get(), (16 == v1.get()) || (-16 == v1.get()));
 418         assertEquals(40, v2.get());
 419         sci4.interpolate(TickCalculation.fromMillis(1000));
 420         assertTrue("v1.get(): " + v1.get(), (40 == v1.get()) || (-40 == v1.get()));
 421         assertEquals(100, v2.get());
 422     }
 423 
 424 }


   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 import com.sun.javafx.animation.TickCalculation;
  29 import com.sun.scenario.animation.shared.SimpleClipInterpolatorShim;
  30 import static org.junit.Assert.assertEquals;
  31 import static org.junit.Assert.assertNotSame;
  32 import static org.junit.Assert.assertSame;
  33 import static org.junit.Assert.assertTrue;
  34 import javafx.animation.KeyFrame;
  35 import javafx.animation.KeyValue;
  36 import javafx.beans.property.IntegerProperty;
  37 import javafx.beans.property.SimpleIntegerProperty;
  38 import javafx.util.Duration;
  39 
  40 import org.junit.Test;
  41 
  42 public class SimpleClipInterpolatorTest {
  43         
  44         @Test
  45         public void testSetKeyFrame() {
  46         final KeyFrame kf1 = new KeyFrame(Duration.ZERO);
  47         final KeyFrame kf2 = new KeyFrame(Duration.millis(1000));
  48         final KeyFrame kf3 = new KeyFrame(Duration.millis(2000));
  49         final SimpleClipInterpolatorShim sci = new SimpleClipInterpolatorShim(kf1, kf2,  6000);
  50         
  51         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{kf1, kf2, kf3}, new long[] {0, 6000, 12000}));
  52         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{kf1, kf2     }, new long[] {0, 6000,      }));
  53         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{kf1,      kf3}, new long[] {0,       12000}));
  54         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{kf1          }, new long[] {0,            }));
  55         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{     kf2, kf3}, new long[] {   6000, 12000}));
  56         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{     kf2     }, new long[] {   6000       }));
  57         assertSame   (sci, sci.setKeyFrames(new KeyFrame[]{          kf3}, new long[] {         12000}));
  58         assertNotSame(sci, sci.setKeyFrames(new KeyFrame[]{             }, new long[] {              }));
  59         }
  60     
  61     @Test
  62     public void test_NoKeyValues() {
  63         final KeyFrame start = new KeyFrame(Duration.ZERO);
  64         final KeyFrame end1 = new KeyFrame(Duration.millis(1000));
  65         final KeyFrame end2 = new KeyFrame(Duration.millis(2000));
  66         
  67         // two key frames
  68         final SimpleClipInterpolatorShim sci1 = new SimpleClipInterpolatorShim(start, end1, 6000);
  69         sci1.validate(true);
  70         sci1.interpolate(TickCalculation.fromMillis(300));
  71         
  72         sci1.validate(true);
  73         sci1.interpolate(TickCalculation.fromMillis(800));
  74         
  75         sci1.setKeyFrames(new KeyFrame[]{start, end2}, new long[] {0, 12000});
  76         sci1.interpolate(TickCalculation.fromMillis(400));
  77         
  78         sci1.validate(true);
  79         sci1.interpolate(TickCalculation.fromMillis(600));
  80         
  81         // one key frame
  82         final SimpleClipInterpolatorShim sci2 = new SimpleClipInterpolatorShim(end1, 6000);
  83         sci2.validate(true);
  84         sci2.interpolate(TickCalculation.fromMillis(300));
  85         
  86         sci2.validate(true);
  87         sci2.interpolate(TickCalculation.fromMillis(800));
  88         
  89         sci2.setKeyFrames(new KeyFrame[]{end2}, new long[] {12000});
  90         sci2.interpolate(TickCalculation.fromMillis(400));
  91         
  92         sci2.validate(true);
  93         sci2.interpolate(TickCalculation.fromMillis(600));
  94     }
  95 
  96     @Test
  97     public void test_TwoKeyFrames_OneKeyValue() {
  98         final IntegerProperty v = new SimpleIntegerProperty();
  99         final KeyFrame start1 = new KeyFrame(Duration.ZERO, new KeyValue(v, 30));
 100         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v, 40));
 101         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v, 60));
 102         
 103         final SimpleClipInterpolatorShim sci1 = new SimpleClipInterpolatorShim(start1, end1, 6000);
 104         v.set(0);
 105         sci1.validate(true);
 106         sci1.interpolate(TickCalculation.fromMillis(0));
 107         assertEquals(30, v.get());
 108         sci1.interpolate(TickCalculation.fromMillis(300));
 109         assertEquals(33, v.get());
 110         sci1.interpolate(TickCalculation.fromMillis(1000));
 111         assertEquals(40, v.get());
 112         
 113         // re-validate
 114         v.set(20);
 115         sci1.validate(true);
 116         sci1.interpolate(TickCalculation.fromMillis(0));
 117         assertEquals(30, v.get());
 118         sci1.interpolate(TickCalculation.fromMillis(800));
 119         assertEquals(38, v.get());
 120         sci1.interpolate(TickCalculation.fromMillis(1000));
 121         assertEquals(40, v.get());
 122         
 123         // set new key frames


 130         sci1.interpolate(TickCalculation.fromMillis(1000));
 131         assertEquals(40, v.get());
 132         
 133         // validate new key frames
 134         sci1.validate(true);
 135         sci1.interpolate(TickCalculation.fromMillis(0));
 136         assertEquals(30, v.get());
 137         sci1.interpolate(TickCalculation.fromMillis(600));
 138         assertEquals(39, v.get());
 139         sci1.interpolate(TickCalculation.fromMillis(2000));
 140         assertEquals(60, v.get());
 141         
 142     }
 143 
 144     @Test
 145     public void test_OneKeyFrame_OneKeyValue() {
 146         final IntegerProperty v = new SimpleIntegerProperty();
 147         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v, 40));
 148         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v, 60));
 149 
 150         final SimpleClipInterpolatorShim sci3 = new SimpleClipInterpolatorShim(end1, 6000);
 151         v.set(0);
 152         sci3.validate(true);
 153         sci3.interpolate(TickCalculation.fromMillis(0));
 154         assertEquals(0, v.get());
 155         sci3.interpolate(TickCalculation.fromMillis(300));
 156         assertEquals(12, v.get());
 157         sci3.interpolate(TickCalculation.fromMillis(1000));
 158         assertEquals(40, v.get());
 159         
 160         // re-validate
 161         v.set(20);
 162         sci3.validate(true);
 163         sci3.interpolate(TickCalculation.fromMillis(0));
 164         assertEquals(20, v.get());
 165         sci3.interpolate(TickCalculation.fromMillis(800));
 166         assertEquals(36, v.get());
 167         sci3.interpolate(TickCalculation.fromMillis(1000));
 168         assertEquals(40, v.get());
 169         
 170         // set new key frames


 180         // validate new key frames
 181         v.set(20);
 182         sci3.validate(true);
 183         sci3.interpolate(TickCalculation.fromMillis(0));
 184         assertEquals(20, v.get());
 185         sci3.interpolate(TickCalculation.fromMillis(600));
 186         assertEquals(32, v.get());
 187         sci3.interpolate(TickCalculation.fromMillis(2000));
 188         assertEquals(60, v.get());
 189     }
 190 
 191     @Test
 192     public void test_TwoKeyFrames_ThreeKeyValues() {
 193         final IntegerProperty v1 = new SimpleIntegerProperty();
 194         final IntegerProperty v2 = new SimpleIntegerProperty();
 195         final IntegerProperty v3 = new SimpleIntegerProperty();
 196         final KeyFrame start1 = new KeyFrame(Duration.ZERO, new KeyValue(v2, 130), new KeyValue(v3, 230));
 197         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v2, 140));
 198         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v1, 60), new KeyValue(v2, 160));
 199         
 200         final SimpleClipInterpolatorShim sci1 = new SimpleClipInterpolatorShim(start1, end1, 6000);
 201         v1.set(  0);
 202         v2.set(100);
 203         v3.set(200);
 204         sci1.validate(true);
 205         sci1.interpolate(TickCalculation.fromMillis(0));
 206         assertEquals(  0, v1.get());
 207         assertEquals(130, v2.get());
 208         assertEquals(200, v3.get());
 209         sci1.interpolate(TickCalculation.fromMillis(300));
 210         assertEquals( 12, v1.get());
 211         assertEquals(133, v2.get());
 212         assertEquals(200, v3.get());
 213         sci1.interpolate(TickCalculation.fromMillis(1000));
 214         assertEquals( 40, v1.get());
 215         assertEquals(140, v2.get());
 216         assertEquals(200, v3.get());
 217         
 218         // re-validate
 219         v1.set( 20);
 220         v2.set(120);


 262         assertEquals(220, v3.get());
 263         sci1.interpolate(TickCalculation.fromMillis(600));
 264         assertEquals( 32, v1.get());
 265         assertEquals(139, v2.get());
 266         assertEquals(220, v3.get());
 267         sci1.interpolate(TickCalculation.fromMillis(2000));
 268         assertEquals( 60, v1.get());
 269         assertEquals(160, v2.get());
 270         assertEquals(220, v3.get());
 271         
 272     }
 273 
 274     @Test
 275     public void test_OneKeyFrames_ThreeKeyValues() {
 276         final IntegerProperty v1 = new SimpleIntegerProperty();
 277         final IntegerProperty v2 = new SimpleIntegerProperty();
 278         final IntegerProperty v3 = new SimpleIntegerProperty();
 279         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v2, 140), new KeyValue(v3, 240));
 280         final KeyFrame end2 = new KeyFrame(Duration.millis(2000), new KeyValue(v1, 60), new KeyValue(v2, 160), new KeyValue(v3, 260));
 281 
 282         final SimpleClipInterpolatorShim sci1 = new SimpleClipInterpolatorShim(end1, 6000);
 283         v1.set(  0);
 284         v2.set(100);
 285         v3.set(200);
 286         sci1.validate(true);
 287         sci1.interpolate(TickCalculation.fromMillis(0));
 288         assertEquals(  0, v1.get());
 289         assertEquals(100, v2.get());
 290         assertEquals(200, v3.get());
 291         sci1.interpolate(TickCalculation.fromMillis(300));
 292         assertEquals( 12, v1.get());
 293         assertEquals(112, v2.get());
 294         assertEquals(212, v3.get());
 295         sci1.interpolate(TickCalculation.fromMillis(1000));
 296         assertEquals( 40, v1.get());
 297         assertEquals(140, v2.get());
 298         assertEquals(240, v3.get());
 299         
 300         // re-validate
 301         v1.set( 20);
 302         v2.set(120);


 345         sci1.interpolate(TickCalculation.fromMillis(600));
 346         assertEquals( 32, v1.get());
 347         assertEquals(132, v2.get());
 348         assertEquals(232, v3.get());
 349         sci1.interpolate(TickCalculation.fromMillis(2000));
 350         assertEquals( 60, v1.get());
 351         assertEquals(160, v2.get());
 352         assertEquals(260, v3.get());
 353     }
 354 
 355     @Test
 356     public void test_DuplicateKeyValue() {
 357         final IntegerProperty v1 = new SimpleIntegerProperty();
 358         final IntegerProperty v2 = new SimpleIntegerProperty();
 359         final KeyFrame start1 = new KeyFrame(Duration.ZERO, new KeyValue(v1, 30), new KeyValue(v2, 0));
 360         final KeyFrame start2 = new KeyFrame(Duration.ZERO, new KeyValue(v1, 30), new KeyValue(v1, -30), new KeyValue(v2, 0));
 361         final KeyFrame end1 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v2, 100));
 362         final KeyFrame end2 = new KeyFrame(Duration.millis(1000), new KeyValue(v1, 40), new KeyValue(v1, -40), new KeyValue(v2, 100));
 363 
 364         // single value in start, duplicate value in end
 365         final SimpleClipInterpolatorShim sci1 = new SimpleClipInterpolatorShim(start1, end2, 6000);
 366         v1.set(0);
 367         v2.set(0);
 368         sci1.validate(true);
 369         sci1.interpolate(TickCalculation.fromMillis(0));
 370         assertEquals(30, v1.get());
 371         assertEquals(0, v2.get());
 372         sci1.interpolate(TickCalculation.fromMillis(300));
 373         assertTrue("v1.get(): " + v1.get(), (33 == v1.get()) || (9 == v1.get()));
 374         assertEquals(30, v2.get());
 375         sci1.interpolate(TickCalculation.fromMillis(1000));
 376         assertTrue("v1.get(): " + v1.get(), (40 == v1.get()) || (-40 == v1.get()));
 377         assertEquals(100, v2.get());
 378 
 379         // duplicate value in start, single value in end
 380         final SimpleClipInterpolatorShim sci2 = new SimpleClipInterpolatorShim(start2, end1, 6000);
 381         v1.set(0);
 382         v2.set(0);
 383         sci2.validate(true);
 384         sci2.interpolate(TickCalculation.fromMillis(0));
 385         assertTrue("v1.get(): " + v1.get(), (30 == v1.get()) || (-30 == v1.get()));
 386         assertEquals(0, v2.get());
 387         sci2.interpolate(TickCalculation.fromMillis(300));
 388         assertTrue("v1.get(): " + v1.get(), (33 == v1.get()) || (-9 == v1.get()));
 389         assertEquals(30, v2.get());
 390         sci2.interpolate(TickCalculation.fromMillis(1000));
 391         assertEquals(40, v1.get());
 392         assertEquals(100, v2.get());
 393 
 394         // duplicate value in start, duplicate value in end
 395         final SimpleClipInterpolatorShim sci3 = new SimpleClipInterpolatorShim(start2, end2, 6000);
 396         v1.set(0);
 397         v2.set(0);
 398         sci3.validate(true);
 399         sci3.interpolate(TickCalculation.fromMillis(0));
 400         assertTrue("v1.get(): " + v1.get(), (30 == v1.get()) || (-30 == v1.get()));
 401         assertEquals(0, v2.get());
 402         sci3.interpolate(TickCalculation.fromMillis(300));
 403         assertTrue("v1.get(): " + v1.get(), (33 == v1.get()) || (9 == v1.get()) || (-9 == v1.get()) || (-33 == v1.get()));
 404         assertEquals(30, v2.get());
 405         sci3.interpolate(TickCalculation.fromMillis(1000));
 406         assertTrue("v1.get(): " + v1.get(), (40 == v1.get()) || (-40 == v1.get()));
 407         assertEquals(100, v2.get());
 408 
 409         // no value in start, duplicate value in end
 410         final SimpleClipInterpolatorShim sci4 = new SimpleClipInterpolatorShim(end2, 6000);
 411         v1.set(0);
 412         v2.set(0);
 413         sci4.validate(true);
 414         sci4.interpolate(TickCalculation.fromMillis(0));
 415         assertEquals(0, v1.get());
 416         assertEquals(0, v2.get());
 417         sci4.interpolate(TickCalculation.fromMillis(400));
 418         assertTrue("v1.get(): " + v1.get(), (16 == v1.get()) || (-16 == v1.get()));
 419         assertEquals(40, v2.get());
 420         sci4.interpolate(TickCalculation.fromMillis(1000));
 421         assertTrue("v1.get(): " + v1.get(), (40 == v1.get()) || (-40 == v1.get()));
 422         assertEquals(100, v2.get());
 423     }
 424 
 425 }