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.BlurType; 35 import javafx.scene.effect.BoxBlur; 36 import javafx.scene.effect.ColorAdjust; 37 import javafx.scene.effect.DropShadow; 38 import javafx.scene.paint.Color; 39 import javafx.scene.shape.Rectangle; 40 41 import org.junit.runner.RunWith; 42 import org.junit.runners.Parameterized; 43 import org.junit.runners.Parameterized.Parameters; 44 45 import test.com.sun.javafx.test.BBoxComparator; 46 import test.com.sun.javafx.test.PropertiesTestBase; 47 48 @RunWith(Parameterized.class) 49 public final class DropShadow_properties_Test extends PropertiesTestBase { 50 51 @Parameters 52 public static Collection data() { 53 ArrayList array = new ArrayList(); 54 55 // simple property tests 56 final DropShadow testDropShadow = new DropShadow(); 57 58 array.add(config(testDropShadow, "input", null, new BoxBlur())); 59 array.add(config(testDropShadow, "radius", 50.0, 100.0)); 60 array.add(config(testDropShadow, "width", 100.0, 200.0)); 61 array.add(config(testDropShadow, "height", 100.0, 200.0)); 62 array.add(config(testDropShadow, "blurType", 63 BlurType.GAUSSIAN, BlurType.THREE_PASS_BOX)); 64 array.add(config(testDropShadow, "spread", 0.0, 0.5)); 65 array.add(config(testDropShadow, "color", Color.BLACK, Color.RED)); 66 array.add(config(testDropShadow, "offsetX", 0.0, 50.0)); 67 array.add(config(testDropShadow, "offsetY", 0.0, 50.0)); 68 69 // bounding box calculation tests 70 71 Node testNode = createTestNode(); 72 array.add(config(testNode.getEffect(), 73 "radius", 10.0, 21.0, 74 testNode, 75 "boundsInLocal", 76 box(-9.0, -9.0, 118.0, 118.0), 77 box(-20.0, -20.0, 140.0, 140.0), 78 new BBoxComparator(0.01))); 79 80 testNode = createTestNode(); 81 array.add(config(testNode.getEffect(), 82 "width", 10.0, 21.0, 83 testNode, 84 "boundsInLocal", 85 box(-3.0, -9.0, 106.0, 118.0), 86 box(-9.0, -9.0, 118.0, 118.0), 87 new BBoxComparator(0.01))); 88 89 testNode = createTestNode(); 90 array.add(config(testNode.getEffect(), 91 "height", 10.0, 21.0, 92 testNode, 93 "boundsInLocal", 94 box(-9.0, -3.0, 118.0, 106.0), 95 box(-9.0, -9.0, 118.0, 118.0), 96 new BBoxComparator(0.01))); 97 98 testNode = createTestNode(); 99 array.add(config(testNode.getEffect(), 100 "offsetX", 10.0, 21.0, 101 testNode, 102 "boundsInLocal", 103 box(0.0, -9.0, 119.0, 118.0), 104 box(0.0, -9.0, 130.0, 118.0), 105 new BBoxComparator(0.01))); 106 107 testNode = createTestNode(); 108 array.add(config(testNode.getEffect(), 109 "offsetY", 10.0, 21.0, 110 testNode, 111 "boundsInLocal", 112 box(-9.0, 0.0, 118.0, 119.0), 113 box(-9.0, 0.0, 118.0, 130.0), 114 new BBoxComparator(0.01))); 115 116 testNode = createTestNode(); 117 array.add(config(testNode.getEffect(), 118 "blurType", BlurType.ONE_PASS_BOX, BlurType.THREE_PASS_BOX, 119 testNode, 120 "boundsInLocal", 121 box(-3.0, -3.0, 106.0, 106.0), 122 box(-9.0, -9.0, 118.0, 118.0), 123 new BBoxComparator(0.01))); 124 125 testNode = createTestNode(); 126 array.add(config(testNode.getEffect(), 127 "blurType", BlurType.TWO_PASS_BOX, BlurType.GAUSSIAN, 128 testNode, 129 "boundsInLocal", 130 box(-6.0, -6.0, 112.0, 112.0), 131 box(-10.0, -10.0, 120.0, 120.0), 132 new BBoxComparator(0.01))); 133 134 testNode = createTestNode(); 135 array.add(config(testNode.getEffect(), 136 "input", null, new BoxBlur(), 137 testNode, 138 "boundsInLocal", 139 box(-9.0, -9.0, 118.0, 118.0), 140 box(-11.0, -11.0, 122.0, 122.0), 141 new BBoxComparator(0.01))); 142 143 // DropShadow chained to another effect 144 testNode = createTestNodeWithChainedEffect(); 145 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 146 "radius", 10.0, 21.0, 147 testNode, 148 "boundsInLocal", 149 box(-9.0, -9.0, 118.0, 118.0), 150 box(-20.0, -20.0, 140.0, 140.0), 151 new BBoxComparator(0.01))); 152 153 testNode = createTestNodeWithChainedEffect(); 154 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 155 "width", 10.0, 21.0, 156 testNode, 157 "boundsInLocal", 158 box(-3.0, -9.0, 106.0, 118.0), 159 box(-9.0, -9.0, 118.0, 118.0), 160 new BBoxComparator(0.01))); 161 162 testNode = createTestNodeWithChainedEffect(); 163 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 164 "height", 10.0, 21.0, 165 testNode, 166 "boundsInLocal", 167 box(-9.0, -3.0, 118.0, 106.0), 168 box(-9.0, -9.0, 118.0, 118.0), 169 new BBoxComparator(0.01))); 170 171 testNode = createTestNodeWithChainedEffect(); 172 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 173 "offsetX", 10.0, 21.0, 174 testNode, 175 "boundsInLocal", 176 box(0.0, -9.0, 119.0, 118.0), 177 box(0.0, -9.0, 130.0, 118.0), 178 new BBoxComparator(0.01))); 179 180 testNode = createTestNodeWithChainedEffect(); 181 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 182 "offsetY", 10.0, 21.0, 183 testNode, 184 "boundsInLocal", 185 box(-9.0, 0.0, 118.0, 119.0), 186 box(-9.0, 0.0, 118.0, 130.0), 187 new BBoxComparator(0.01))); 188 189 testNode = createTestNodeWithChainedEffect(); 190 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 191 "blurType", BlurType.ONE_PASS_BOX, BlurType.THREE_PASS_BOX, 192 testNode, 193 "boundsInLocal", 194 box(-3.0, -3.0, 106.0, 106.0), 195 box(-9.0, -9.0, 118.0, 118.0), 196 new BBoxComparator(0.01))); 197 198 testNode = createTestNodeWithChainedEffect(); 199 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 200 "blurType", BlurType.TWO_PASS_BOX, BlurType.GAUSSIAN, 201 testNode, 202 "boundsInLocal", 203 box(-6.0, -6.0, 112.0, 112.0), 204 box(-10.0, -10.0, 120.0, 120.0), 205 new BBoxComparator(0.01))); 206 207 testNode = createTestNodeWithChainedEffect(); 208 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 209 "input", null, new BoxBlur(), 210 testNode, 211 "boundsInLocal", 212 box(-9.0, -9.0, 118.0, 118.0), 213 box(-11.0, -11.0, 122.0, 122.0), 214 new BBoxComparator(0.01))); 215 216 return array; 217 } 218 219 public DropShadow_properties_Test(final Configuration configuration) { 220 super(configuration); 221 } 222 223 private static Rectangle createTestNode() { 224 Rectangle r = new Rectangle(100, 100); 225 r.setEffect(new DropShadow()); 226 return r; 227 } 228 229 private static Rectangle createTestNodeWithChainedEffect() { 230 Rectangle r = new Rectangle(100, 100); 231 ColorAdjust c = new ColorAdjust(); 232 c.setInput(new DropShadow()); 233 r.setEffect(c); 234 return r; 235 } 236 }