modules/graphics/src/test/java/test/javafx/scene/effect/ImageInputTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:


   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 org.junit.Assert.assertEquals;
  29 import static org.junit.Assert.assertNull;
  30 import javafx.beans.property.ObjectProperty;
  31 import javafx.beans.property.SimpleObjectProperty;
  32 import javafx.scene.image.Image;
  33 import javafx.scene.image.TestImages;
  34 
  35 import org.junit.Before;
  36 import org.junit.Test;
  37 
  38 import com.sun.javafx.geom.Point2D;
  39 import com.sun.javafx.tk.Toolkit;

  40 
  41 public class ImageInputTest extends EffectsTestBase {
  42     private ImageInput effect;
  43 
  44     @Before
  45     public void setUp() {
  46         effect = new ImageInput();
  47         setupTest(effect);
  48     }
  49 
  50     @Test
  51     public void testSetX() {
  52         // try setting correct value
  53         effect.setX(1.0f);
  54         assertEquals(1.0f, effect.getX(), 1e-100);
  55         pulse();
  56         assertEquals(1.0f, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getLocation().x, 1e-100);
  57     }
  58 
  59     @Test


  69     public void testSetY() {
  70         // try setting correct value
  71         effect.setY(1.0f);
  72         assertEquals(1.0f, effect.getY(), 1e-100);
  73         pulse();
  74         assertEquals(1.0f, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getLocation().y, 1e-100);
  75     }
  76 
  77     @Test
  78     public void testDefaultY() {
  79         // default value should be 0
  80         assertEquals(0, effect.getY(), 1e-100);
  81         assertEquals(0, effect.yProperty().get(), 1e-100);
  82         pulse();
  83         assertEquals(0, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getLocation().y, 1e-100);
  84     }
  85     
  86     @Test
  87     public void testSetSource() {
  88         // try setting non-existing image
  89         Image i = new Image("javafx/scene/image/test.png");
  90         effect.setSource(i);
  91         assertEquals(i, effect.getSource());
  92         pulse();
  93         assertEquals(null, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getSource());
  94         // try setting correct one
  95         effect.setSource(TestImages.TEST_IMAGE_32x32);
  96         pulse();
  97         assertEquals(TestImages.TEST_IMAGE_32x32, effect.getSource());
  98         assertEquals(Toolkit.getToolkit().toFilterable(TestImages.TEST_IMAGE_32x32).getPhysicalHeight(),
  99                 ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getSource().getPhysicalHeight());
 100         assertEquals(Toolkit.getToolkit().toFilterable(TestImages.TEST_IMAGE_32x32).getPhysicalWidth(),
 101                 ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getSource().getPhysicalWidth());
 102     }
 103 
 104     @Test
 105     public void testDefaultSource() {
 106         // default value should be null
 107         assertNull(effect.getSource());
 108         assertNull(effect.sourceProperty().get());
 109         pulse();




   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 org.junit.Assert.assertEquals;
  29 import static org.junit.Assert.assertNull;
  30 import javafx.beans.property.ObjectProperty;
  31 import javafx.beans.property.SimpleObjectProperty;
  32 import javafx.scene.image.Image;
  33 import test.javafx.scene.image.TestImages;
  34 
  35 import org.junit.Before;
  36 import org.junit.Test;
  37 
  38 import com.sun.javafx.geom.Point2D;
  39 import com.sun.javafx.tk.Toolkit;
  40 import javafx.scene.effect.ImageInput;
  41 
  42 public class ImageInputTest extends EffectsTestBase {
  43     private ImageInput effect;
  44 
  45     @Before
  46     public void setUp() {
  47         effect = new ImageInput();
  48         setupTest(effect);
  49     }
  50 
  51     @Test
  52     public void testSetX() {
  53         // try setting correct value
  54         effect.setX(1.0f);
  55         assertEquals(1.0f, effect.getX(), 1e-100);
  56         pulse();
  57         assertEquals(1.0f, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getLocation().x, 1e-100);
  58     }
  59 
  60     @Test


  70     public void testSetY() {
  71         // try setting correct value
  72         effect.setY(1.0f);
  73         assertEquals(1.0f, effect.getY(), 1e-100);
  74         pulse();
  75         assertEquals(1.0f, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getLocation().y, 1e-100);
  76     }
  77 
  78     @Test
  79     public void testDefaultY() {
  80         // default value should be 0
  81         assertEquals(0, effect.getY(), 1e-100);
  82         assertEquals(0, effect.yProperty().get(), 1e-100);
  83         pulse();
  84         assertEquals(0, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getLocation().y, 1e-100);
  85     }
  86     
  87     @Test
  88     public void testSetSource() {
  89         // try setting non-existing image
  90         Image i = new Image("test/javafx/scene/image/test.png");
  91         effect.setSource(i);
  92         assertEquals(i, effect.getSource());
  93         pulse();
  94         assertEquals(null, ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getSource());
  95         // try setting correct one
  96         effect.setSource(TestImages.TEST_IMAGE_32x32);
  97         pulse();
  98         assertEquals(TestImages.TEST_IMAGE_32x32, effect.getSource());
  99         assertEquals(Toolkit.getToolkit().toFilterable(TestImages.TEST_IMAGE_32x32).getPhysicalHeight(),
 100                 ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getSource().getPhysicalHeight());
 101         assertEquals(Toolkit.getToolkit().toFilterable(TestImages.TEST_IMAGE_32x32).getPhysicalWidth(),
 102                 ((com.sun.scenario.effect.Identity) effect.impl_getImpl()).getSource().getPhysicalWidth());
 103     }
 104 
 105     @Test
 106     public void testDefaultSource() {
 107         // default value should be null
 108         assertNull(effect.getSource());
 109         assertNull(effect.sourceProperty().get());
 110         pulse();