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.paint.Color;
  35 import javafx.scene.shape.Rectangle;
  36 
  37 import org.junit.runner.RunWith;
  38 import org.junit.runners.Parameterized;
  39 import org.junit.runners.Parameterized.Parameters;
  40 
  41 import com.sun.javafx.test.BBoxComparator;
  42 import com.sun.javafx.test.PropertiesTestBase;
  43 
  44 @RunWith(Parameterized.class)
  45 public final class ColorInput_properties_Test extends PropertiesTestBase {
  46 
  47     @Parameters
  48     public static Collection data() {
  49         ArrayList array = new ArrayList();
  50 
  51         // simple property tests
  52         final ColorInput testColorInput = new ColorInput();
  53 
  54         array.add(config(testColorInput, "paint", Color.RED, Color.BLUE));
  55         array.add(config(testColorInput, "x", 0.0, 100.0));
  56         array.add(config(testColorInput, "y", 0.0, 100.0));
  57         array.add(config(testColorInput, "width", 50.0, 150.0));
  58         array.add(config(testColorInput, "height", 50.0, 150.0));
  59 
  60         // bounding box calculation tests
  61 
  62         Node testNode = createTestNode();
  63         array.add(config(testNode.getEffect(),
  64                 "width", 0.0, 50.0,
  65                 testNode,
  66                 "boundsInLocal",
  67                 box(0.0, 0.0, 0.0, 50.0),
  68                 box(0.0, 0.0, 50.0, 50.0),
  69                 new BBoxComparator(0.01)));
  70 
  71         testNode = createTestNode();
  72         array.add(config(testNode.getEffect(),
  73                 "height", 0.0, 50.0,
  74                 testNode,
  75                 "boundsInLocal",
  76                 box(0.0, 0.0, 50.0, 0.0),
  77                 box(0.0, 0.0, 50.0, 50.0),
  78                 new BBoxComparator(0.01)));
  79 
  80         testNode = createTestNode();
  81         array.add(config(testNode.getEffect(),
  82                 "x", 0.0, 50.0,
  83                 testNode,
  84                 "boundsInLocal",
  85                 box(0.0, 0.0, 50.0, 50.0),
  86                 box(50.0, 0.0, 50.0, 50.0),
  87                 new BBoxComparator(0.01)));
  88 
  89         testNode = createTestNode();
  90         array.add(config(testNode.getEffect(),
  91                 "y", 0.0, 50.0,
  92                 testNode,
  93                 "boundsInLocal",
  94                 box(0.0, 0.0, 50.0, 50.0),
  95                 box(0.0, 50.0, 50.0, 50.0),
  96                 new BBoxComparator(0.01)));
  97 
  98         testNode = createTestNodeWithChainedEffect();
  99         array.add(config(((ColorAdjust)testNode.getEffect()).getInput(),
 100                 "width", 0.0, 50.0,
 101                 testNode,
 102                 "boundsInLocal",
 103                 box(0.0, 0.0, 0.0, 50.0),
 104                 box(0.0, 0.0, 50.0, 50.0),
 105                 new BBoxComparator(0.01)));
 106 
 107         testNode = createTestNodeWithChainedEffect();
 108         array.add(config(((ColorAdjust)testNode.getEffect()).getInput(),
 109                 "height", 0.0, 50.0,
 110                 testNode,
 111                 "boundsInLocal",
 112                 box(0.0, 0.0, 50.0, 0.0),
 113                 box(0.0, 0.0, 50.0, 50.0),
 114                 new BBoxComparator(0.01)));
 115 
 116         testNode = createTestNodeWithChainedEffect();
 117         array.add(config(((ColorAdjust)testNode.getEffect()).getInput(),
 118                 "x", 0.0, 50.0,
 119                 testNode,
 120                 "boundsInLocal",
 121                 box(0.0, 0.0, 50.0, 50.0),
 122                 box(50.0, 0.0, 50.0, 50.0),
 123                 new BBoxComparator(0.01)));
 124 
 125         testNode = createTestNodeWithChainedEffect();
 126         array.add(config(((ColorAdjust)testNode.getEffect()).getInput(),
 127                 "y", 0.0, 50.0,
 128                 testNode,
 129                 "boundsInLocal",
 130                 box(0.0, 0.0, 50.0, 50.0),
 131                 box(0.0, 50.0, 50.0, 50.0),
 132                 new BBoxComparator(0.01)));
 133 
 134         return array;
 135     }
 136 
 137     public ColorInput_properties_Test(final Configuration configuration) {
 138         super(configuration);
 139     }
 140 
 141     private static Rectangle createTestNode() {
 142         Rectangle r = new Rectangle(100, 100);
 143         ColorInput flood = new ColorInput();
 144         flood.setHeight(50);
 145         flood.setWidth(50);
 146         r.setEffect(flood);
 147         return r;
 148     }
 149 
 150     private static Rectangle createTestNodeWithChainedEffect() {
 151         Rectangle r = new Rectangle(100, 100);
 152         ColorInput flood = new ColorInput();
 153         flood.setHeight(50);
 154         flood.setWidth(50);
 155 
 156         ColorAdjust c = new ColorAdjust();
 157         c.setInput(flood);
 158         r.setEffect(c);
 159         return r;
 160     }
 161 }