1 /* 2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 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.scene.effect; 27 28 import static test.com.sun.javafx.test.TestHelper.box; 29 30 import java.util.ArrayList; 31 import java.util.Collection; 32 33 import javafx.scene.Node; 34 import javafx.scene.effect.BoxBlur; 35 import javafx.scene.effect.ColorAdjust; 36 import javafx.scene.effect.MotionBlur; 37 import javafx.scene.shape.Rectangle; 38 39 import org.junit.runner.RunWith; 40 import org.junit.runners.Parameterized; 41 import org.junit.runners.Parameterized.Parameters; 42 43 import test.com.sun.javafx.test.BBoxComparator; 44 import test.com.sun.javafx.test.PropertiesTestBase; 45 46 @RunWith(Parameterized.class) 47 public final class MotionBlur_properties_Test extends PropertiesTestBase { 48 49 @Parameters 50 public static Collection data() { 51 ArrayList array = new ArrayList(); 52 53 // simple property tests 54 final MotionBlur testMotionBlur = new MotionBlur(); 55 56 array.add(config(testMotionBlur, "input", null, new BoxBlur())); 57 array.add(config(testMotionBlur, "radius", 20.0, 40.0)); 58 array.add(config(testMotionBlur, "angle", 0.0, 45.0)); 59 60 // bounding box calculation tests 61 62 Node testNode = createTestNode(); 63 array.add(config(testNode.getEffect(), 64 "radius", 10.0, 20.0, 65 testNode, 66 "boundsInLocal", 67 box(-10.0, 0.0, 120.0, 100.0), 68 box(-20.0, 0.0, 140.0, 100.0), 69 new BBoxComparator(0.01))); 70 71 testNode = createTestNode(); 72 array.add(config(testNode.getEffect(), 73 "angle", 0.0, 45.0, 74 testNode, 75 "boundsInLocal", 76 box(-10.0, 0.0, 120.0, 100.0), 77 box(-8.0, -8.0, 116.0, 116.0), 78 new BBoxComparator(0.01))); 79 80 testNode = createTestNode(); 81 array.add(config(testNode.getEffect(), 82 "input", null, new BoxBlur(), 83 testNode, 84 "boundsInLocal", 85 box(-10.0, -0.0, 120.0, 100.0), 86 box(-12.0, -2.0, 124.0, 104.0), 87 new BBoxComparator(0.01))); 88 89 testNode = createTestNodeWithChainedEffect(); 90 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 91 "radius", 10.0, 20.0, 92 testNode, 93 "boundsInLocal", 94 box(-10.0, 0.0, 120.0, 100.0), 95 box(-20.0, 0.0, 140.0, 100.0), 96 new BBoxComparator(0.01))); 97 98 testNode = createTestNodeWithChainedEffect(); 99 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 100 "angle", 0.0, 45.0, 101 testNode, 102 "boundsInLocal", 103 box(-10.0, 0.0, 120.0, 100.0), 104 box(-8.0, -8.0, 116.0, 116.0), 105 new BBoxComparator(0.01))); 106 107 testNode = createTestNodeWithChainedEffect(); 108 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 109 "input", null, new BoxBlur(), 110 testNode, 111 "boundsInLocal", 112 box(-10.0, -0.0, 120.0, 100.0), 113 box(-12.0, -2.0, 124.0, 104.0), 114 new BBoxComparator(0.01))); 115 116 return array; 117 } 118 119 public MotionBlur_properties_Test(final Configuration configuration) { 120 super(configuration); 121 } 122 123 private static Rectangle createTestNode() { 124 Rectangle r = new Rectangle(100, 100); 125 r.setEffect(new MotionBlur()); 126 return r; 127 } 128 129 private static Rectangle createTestNodeWithChainedEffect() { 130 Rectangle r = new Rectangle(100, 100); 131 ColorAdjust c = new ColorAdjust(); 132 c.setInput(new MotionBlur()); 133 r.setEffect(c); 134 return r; 135 } 136 }