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 javafx.scene.effect; 27 28 import static 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.shape.Rectangle; 35 36 import org.junit.runner.RunWith; 37 import org.junit.runners.Parameterized; 38 import org.junit.runners.Parameterized.Parameters; 39 40 import com.sun.javafx.test.BBoxComparator; 41 import com.sun.javafx.test.PropertiesTestBase; 42 43 @RunWith(Parameterized.class) 44 public final class Reflection_properties_Test extends PropertiesTestBase { 45 46 @Parameters 47 public static Collection data() { 48 ArrayList array = new ArrayList(); 49 50 // simple property tests 51 final Reflection testReflection = new Reflection(); 52 53 array.add(config(testReflection, "input", null, new BoxBlur())); 54 array.add(config(testReflection, "topOffset", 0.0, 50.0)); 55 array.add(config(testReflection, "topOpacity", 0.5, 0.0)); 56 array.add(config(testReflection, "bottomOpacity", 1.0, 0.8)); 57 array.add(config(testReflection, "fraction", 0.75, 0.5)); 58 59 // bounding box calculation tests 60 61 Node testNode = createTestNode(); 62 array.add(config(testNode.getEffect(), 63 "topOffset", 10.0, 20.0, 64 testNode, 65 "boundsInLocal", 66 box(0.0, 0.0, 100.0, 185.0), 67 box(0.0, 0.0, 100.0, 195.0), 68 new BBoxComparator(0.01))); 69 70 testNode = createTestNode(); 71 array.add(config(testNode.getEffect(), 72 "fraction", 0.0, 1.0, 73 testNode, 74 "boundsInLocal", 75 box(0.0, 0.0, 100.0, 100.0), 76 box(0.0, 0.0, 100.0, 200.0), 77 new BBoxComparator(0.01))); 78 79 testNode = createTestNode(); 80 array.add(config(testNode.getEffect(), 81 "input", null, new BoxBlur(), 82 testNode, 83 "boundsInLocal", 84 box(0.0, 0.0, 100.0, 175.0), 85 box(-2.0, -2.0, 104.0, 182.0), 86 new BBoxComparator(0.01))); 87 88 testNode = createTestNodeWithChainedEffect(); 89 array.add(config(((Glow)testNode.getEffect()).getInput(), 90 "topOffset", 10.0, 20.0, 91 testNode, 92 "boundsInLocal", 93 box(0.0, 0.0, 100.0, 185.0), 94 box(0.0, 0.0, 100.0, 195.0), 95 new BBoxComparator(0.01))); 96 97 testNode = createTestNodeWithChainedEffect(); 98 array.add(config(((Glow)testNode.getEffect()).getInput(), 99 "fraction", 0.0, 1.0, 100 testNode, 101 "boundsInLocal", 102 box(0.0, 0.0, 100.0, 100.0), 103 box(0.0, 0.0, 100.0, 200.0), 104 new BBoxComparator(0.01))); 105 106 testNode = createTestNodeWithChainedEffect(); 107 array.add(config(((Glow)testNode.getEffect()).getInput(), 108 "input", null, new BoxBlur(), 109 testNode, 110 "boundsInLocal", 111 box(0.0, 0.0, 100.0, 175.0), 112 box(-2.0, -2.0, 104.0, 182.0), 113 new BBoxComparator(0.01))); 114 115 return array; 116 } 117 118 public Reflection_properties_Test(final Configuration configuration) { 119 super(configuration); 120 } 121 122 private static Rectangle createTestNode() { 123 Rectangle r = new Rectangle(100, 100); 124 r.setEffect(new Reflection()); 125 return r; 126 } 127 128 private static Rectangle createTestNodeWithChainedEffect() { 129 Rectangle r = new Rectangle(100, 100); 130 Glow g = new Glow(); 131 g.setInput(new Reflection()); 132 r.setEffect(g); 133 return r; 134 } 135 }