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 GaussianBlur_properties_Test extends PropertiesTestBase {
  45 
  46     @Parameters
  47     public static Collection data() {
  48         ArrayList array = new ArrayList();
  49 
  50         // simple property tests
  51         final GaussianBlur testGaussianBlur = new GaussianBlur();
  52 
  53         array.add(config(testGaussianBlur, "input", null, new BoxBlur()));
  54         array.add(config(testGaussianBlur, "radius", 20.0, 40.0));
  55 
  56         // bounding box calculation tests
  57 
  58         Node testNode = createTestNode();
  59         array.add(config(testNode.getEffect(),
  60                 "radius", 0.0, 10.0,
  61                 testNode,
  62                 "boundsInLocal",
  63                 box(0.0, 0.0, 100.0, 100.0),
  64                 box(-10.0, -10.0, 120.0, 120.0),
  65                 new BBoxComparator(0.01)));
  66 
  67         testNode = createTestNode();
  68         array.add(config(testNode.getEffect(),
  69                 "input", null, new BoxBlur(),
  70                 testNode,
  71                 "boundsInLocal",
  72                 box(-10.0, -10.0, 120.0, 120.0),
  73                 box(-12.0, -12.0, 124.0, 124.0),
  74                 new BBoxComparator(0.01)));
  75 
  76         testNode = createTestNodeWithChainedEffect();
  77         array.add(config(((Glow)testNode.getEffect()).getInput(),
  78                 "radius", 0.0, 10.0,
  79                 testNode,
  80                 "boundsInLocal",
  81                 box(0.0, 0.0, 100.0, 100.0),
  82                 box(-10.0, -10.0, 120.0, 120.0),
  83                 new BBoxComparator(0.01)));
  84 
  85         testNode = createTestNodeWithChainedEffect();
  86         array.add(config(((Glow)testNode.getEffect()).getInput(),
  87                 "input", null, new BoxBlur(),
  88                 testNode,
  89                 "boundsInLocal",
  90                 box(-10.0, -10.0, 120.0, 120.0),
  91                 box(-12.0, -12.0, 124.0, 124.0),
  92                 new BBoxComparator(0.01)));
  93 
  94         return array;
  95     }
  96 
  97     public GaussianBlur_properties_Test(final Configuration configuration) {
  98         super(configuration);
  99     }
 100 
 101     private static Rectangle createTestNode() {
 102         Rectangle r = new Rectangle(100, 100);
 103         r.setEffect(new GaussianBlur());
 104         return r;
 105     }
 106 
 107     private static Rectangle createTestNodeWithChainedEffect() {
 108         Rectangle r = new Rectangle(100, 100);
 109         Glow g = new Glow();
 110         g.setInput(new GaussianBlur());
 111         r.setEffect(g);
 112         return r;
 113     }
 114 }