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.Glow; 37 import javafx.scene.effect.Shadow; 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 Shadow_properties_Test extends PropertiesTestBase { 50 51 @Parameters 52 public static Collection data() { 53 ArrayList array = new ArrayList(); 54 55 // simple property tests 56 final Shadow testShadow = new Shadow(); 57 58 array.add(config(testShadow, "input", null, new BoxBlur())); 59 array.add(config(testShadow, "radius", 20.0, 40.0)); 60 array.add(config(testShadow, "width", 100.0, 200.0)); 61 array.add(config(testShadow, "height", 100.0, 200.0)); 62 array.add(config(testShadow, "blurType", 63 BlurType.GAUSSIAN, BlurType.THREE_PASS_BOX)); 64 array.add(config(testShadow, "color", Color.BLACK, Color.RED)); 65 66 // bounding box calculation tests 67 68 Node testNode = createTestNode(); 69 array.add(config(testNode.getEffect(), 70 "radius", 10.0, 21.0, 71 testNode, 72 "boundsInLocal", 73 box(-9.0, -9.0, 118.0, 118.0), 74 box(-20.0, -20.0, 140.0, 140.0), 75 new BBoxComparator(0.01))); 76 77 testNode = createTestNode(); 78 array.add(config(testNode.getEffect(), 79 "width", 10.0, 21.0, 80 testNode, 81 "boundsInLocal", 82 box(-3.0, -9.0, 106.0, 118.0), 83 box(-9.0, -9.0, 118.0, 118.0), 84 new BBoxComparator(0.01))); 85 86 testNode = createTestNode(); 87 array.add(config(testNode.getEffect(), 88 "height", 10.0, 21.0, 89 testNode, 90 "boundsInLocal", 91 box(-9.0, -3.0, 118.0, 106.0), 92 box(-9.0, -9.0, 118.0, 118.0), 93 new BBoxComparator(0.01))); 94 95 testNode = createTestNode(); 96 array.add(config(testNode.getEffect(), 97 "blurType", BlurType.ONE_PASS_BOX, BlurType.THREE_PASS_BOX, 98 testNode, 99 "boundsInLocal", 100 box(-3.0, -3.0, 106.0, 106.0), 101 box(-9.0, -9.0, 118.0, 118.0), 102 new BBoxComparator(0.01))); 103 104 testNode = createTestNode(); 105 array.add(config(testNode.getEffect(), 106 "blurType", BlurType.TWO_PASS_BOX, BlurType.GAUSSIAN, 107 testNode, 108 "boundsInLocal", 109 box(-6.0, -6.0, 112.0, 112.0), 110 box(-10.0, -10.0, 120.0, 120.0), 111 new BBoxComparator(0.01))); 112 113 testNode = createTestNode(); 114 array.add(config(testNode.getEffect(), 115 "input", null, new BoxBlur(), 116 testNode, 117 "boundsInLocal", 118 box(-9.0, -9.0, 118.0, 118.0), 119 box(-11.0, -11.0, 122.0, 122.0), 120 new BBoxComparator(0.01))); 121 122 testNode = createTestNodeWithChainedEffect(); 123 array.add(config(((Glow)testNode.getEffect()).getInput(), 124 "radius", 10.0, 21.0, 125 testNode, 126 "boundsInLocal", 127 box(-9.0, -9.0, 118.0, 118.0), 128 box(-20.0, -20.0, 140.0, 140.0), 129 new BBoxComparator(0.01))); 130 131 testNode = createTestNodeWithChainedEffect(); 132 array.add(config(((Glow)testNode.getEffect()).getInput(), 133 "width", 10.0, 21.0, 134 testNode, 135 "boundsInLocal", 136 box(-3.0, -9.0, 106.0, 118.0), 137 box(-9.0, -9.0, 118.0, 118.0), 138 new BBoxComparator(0.01))); 139 140 testNode = createTestNodeWithChainedEffect(); 141 array.add(config(((Glow)testNode.getEffect()).getInput(), 142 "height", 10.0, 21.0, 143 testNode, 144 "boundsInLocal", 145 box(-9.0, -3.0, 118.0, 106.0), 146 box(-9.0, -9.0, 118.0, 118.0), 147 new BBoxComparator(0.01))); 148 149 testNode = createTestNodeWithChainedEffect(); 150 array.add(config(((Glow)testNode.getEffect()).getInput(), 151 "blurType", BlurType.ONE_PASS_BOX, BlurType.THREE_PASS_BOX, 152 testNode, 153 "boundsInLocal", 154 box(-3.0, -3.0, 106.0, 106.0), 155 box(-9.0, -9.0, 118.0, 118.0), 156 new BBoxComparator(0.01))); 157 158 testNode = createTestNodeWithChainedEffect(); 159 array.add(config(((Glow)testNode.getEffect()).getInput(), 160 "blurType", BlurType.TWO_PASS_BOX, BlurType.GAUSSIAN, 161 testNode, 162 "boundsInLocal", 163 box(-6.0, -6.0, 112.0, 112.0), 164 box(-10.0, -10.0, 120.0, 120.0), 165 new BBoxComparator(0.01))); 166 167 testNode = createTestNodeWithChainedEffect(); 168 array.add(config(((Glow)testNode.getEffect()).getInput(), 169 "input", null, new BoxBlur(), 170 testNode, 171 "boundsInLocal", 172 box(-9.0, -9.0, 118.0, 118.0), 173 box(-11.0, -11.0, 122.0, 122.0), 174 new BBoxComparator(0.01))); 175 176 return array; 177 } 178 179 public Shadow_properties_Test(final Configuration configuration) { 180 super(configuration); 181 } 182 183 private static Rectangle createTestNode() { 184 Rectangle r = new Rectangle(100, 100); 185 r.setEffect(new Shadow()); 186 return r; 187 } 188 189 private static Rectangle createTestNodeWithChainedEffect() { 190 Rectangle r = new Rectangle(100, 100); 191 Glow g = new Glow(); 192 g.setInput(new Shadow()); 193 r.setEffect(g); 194 return r; 195 } 196 }