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 BoxBlur_properties_Test extends PropertiesTestBase { 45 46 @Parameters 47 public static Collection data() { 48 ArrayList array = new ArrayList(); 49 50 // simple property tests 51 final BoxBlur testBoxBlur = new BoxBlur(); 52 53 array.add(config(testBoxBlur, "input", null, new BoxBlur())); 54 array.add(config(testBoxBlur, "width", 100.0, 200.0)); 55 array.add(config(testBoxBlur, "height", 100.0, 200.0)); 56 array.add(config(testBoxBlur, "iterations", 1, 3)); 57 58 // bounding box calculation tests 59 60 // BoxBlur set directly on node 61 Node testNode = createTestNode(); 62 63 array.add(config(testNode.getEffect(), 64 "iterations", 1, 2, 65 testNode, 66 "boundsInLocal", 67 box(-2.0, -2.0, 104.0, 104.0), 68 box(-4.0, -4.0, 108.0, 108.0), 69 new BBoxComparator(0.01))); 70 71 testNode = createTestNode(); 72 array.add(config(testNode.getEffect(), 73 "width", 5.0, 100.0, 74 testNode, 75 "boundsInLocal", 76 box(-2.0, -2.0, 104.0, 104.0), 77 box(-50.0, -2.0, 200.0, 104.0), 78 new BBoxComparator(0.01))); 79 80 testNode = createTestNode(); 81 array.add(config(testNode.getEffect(), 82 "height", 5.0, 100.0, 83 testNode, 84 "boundsInLocal", 85 box(-2.0, -2.0, 104.0, 104.0), 86 box(-2.0, -50.0, 104.0, 200.0), 87 new BBoxComparator(0.01))); 88 89 testNode = createTestNode(); 90 array.add(config(testNode.getEffect(), 91 "input", null, new BoxBlur(), 92 testNode, 93 "boundsInLocal", 94 box(-2.0, -2.0, 104.0, 104.0), 95 box(-4.0, -4.0, 108.0, 108.0), 96 new BBoxComparator(0.01))); 97 98 // BoxBlur chained to another effect 99 testNode = createTestNodeWithChainedEffect(); 100 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 101 "iterations", 1, 2, 102 testNode, 103 "boundsInLocal", 104 box(-2.0, -2.0, 104.0, 104.0), 105 box(-4.0, -4.0, 108.0, 108.0), 106 new BBoxComparator(0.01))); 107 108 testNode = createTestNodeWithChainedEffect(); 109 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 110 "width", 5.0, 100.0, 111 testNode, 112 "boundsInLocal", 113 box(-2.0, -2.0, 104.0, 104.0), 114 box(-50.0, -2.0, 200.0, 104.0), 115 new BBoxComparator(0.01))); 116 117 testNode = createTestNodeWithChainedEffect(); 118 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 119 "height", 5.0, 100.0, 120 testNode, 121 "boundsInLocal", 122 box(-2.0, -2.0, 104.0, 104.0), 123 box(-2.0, -50.0, 104.0, 200.0), 124 new BBoxComparator(0.01))); 125 126 testNode = createTestNodeWithChainedEffect(); 127 array.add(config(((ColorAdjust)testNode.getEffect()).getInput(), 128 "input", null, new BoxBlur(), 129 testNode, 130 "boundsInLocal", 131 box(-2.0, -2.0, 104.0, 104.0), 132 box(-4.0, -4.0, 108.0, 108.0), 133 new BBoxComparator(0.01))); 134 135 return array; 136 } 137 138 public BoxBlur_properties_Test(final Configuration configuration) { 139 super(configuration); 140 } 141 142 private static Rectangle createTestNode() { 143 Rectangle r = new Rectangle(100, 100); 144 r.setEffect(new BoxBlur()); 145 return r; 146 } 147 148 private static Rectangle createTestNodeWithChainedEffect() { 149 Rectangle r = new Rectangle(100, 100); 150 ColorAdjust ca = new ColorAdjust(); 151 ca.setInput(new BoxBlur()); 152 r.setEffect(ca); 153 return r; 154 } 155 }