modules/graphics/src/test/java/test/javafx/scene/effect/BloomTest.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 com.sun.javafx.test.TestHelper.box;



  29 import static org.junit.Assert.assertEquals;
  30 
  31 import org.junit.Before;
  32 import org.junit.Test;

  33 
  34 public class BloomTest extends EffectsTestBase {
  35     private Bloom effect;
  36 
  37     @Before
  38     public void setUp() {
  39         effect = new Bloom();
  40         setupTest(effect);
  41     }
  42 
  43     @Test
  44     public void testSetThreshold() {
  45         // try setting correct value
  46         effect.setThreshold(1.0f);
  47         assertEquals(1.0f, (float) effect.getThreshold(), 1e-100);
  48         pulse();
  49         assertEquals(1.0f, (float) ((com.sun.scenario.effect.Bloom)effect.impl_getImpl()).getThreshold(), 1e-100);

  50     }
  51     
  52     @Test
  53     public void testDefaultThreshold() {
  54         // default value should be 0.3
  55         assertEquals(0.3f, (float) effect.getThreshold(), 1e-100);
  56         assertEquals(0.3f, (float) effect.thresholdProperty().get(), 1e-100);
  57         pulse();
  58         assertEquals(0.3f, (float) ((com.sun.scenario.effect.Bloom)effect.impl_getImpl()).getThreshold(), 1e-100);

  59     }
  60     
  61     @Test
  62     public void testMinThreshold() {
  63         // 0 should be ok
  64         effect.setThreshold(0);
  65         // try setting value smaller than minimal
  66         effect.setThreshold(-0.1f);
  67         assertEquals(-0.1f, (float) effect.getThreshold(), 1e-100);
  68         pulse();
  69         assertEquals(0.0f, (float) ((com.sun.scenario.effect.Bloom)effect.impl_getImpl()).getThreshold(), 1e-100);

  70     }
  71 
  72     @Test
  73     public void testMaxThreshold() {
  74         // 1 should be ok
  75         effect.setThreshold(1);
  76         // try setting value greater than maximal
  77         effect.setThreshold(1.1f);
  78         assertEquals(1.1f, (float) effect.getThreshold(), 1e-100);
  79         pulse();
  80         assertEquals(1.0f, (float) ((com.sun.scenario.effect.Bloom)effect.impl_getImpl()).getThreshold(), 1e-100);

  81     }
  82 
  83     @Test
  84     public void testThresholdSynced() throws Exception {
  85         checkDoublePropertySynced(
  86                 "javafx.scene.effect.Bloom", "threshold",
  87                 "com.sun.scenario.effect.Bloom", "threshold", 0.3);
  88     }
  89 
  90     @Test
  91     public void testInputSynced() throws Exception {
  92         BoxBlur blur = new BoxBlur();
  93         checkEffectPropertySynced(
  94                 "javafx.scene.effect.Bloom", "input",
  95                 "com.sun.scenario.effect.Bloom", "input",
  96                 blur, (com.sun.scenario.effect.BoxBlur)blur.impl_getImpl());

  97     }
  98 
  99     @Test
 100     public void testBounds() {
 101         assertEquals(box(0, 0, 100, 100), n.getBoundsInLocal());
 102     }
 103 
 104     @Test
 105     public void testBoundsWidthInput() {
 106         assertEquals(box(0, 0, 100, 100), n.getBoundsInLocal());
 107         BoxBlur blur = new BoxBlur();
 108         effect.setInput(blur);
 109         assertEquals(box(-2, -2, 104, 104), n.getBoundsInLocal());
 110     }
 111     
 112     @Test
 113     public void testCreateWithParams() {
 114         effect = new Bloom(1);
 115         setupTest(effect);
 116         assertEquals(1, effect.getThreshold(), 1e-100);
 117         pulse();
 118         assertEquals(1.0f, ((com.sun.scenario.effect.Bloom) effect.impl_getImpl()).getThreshold(), 1e-100);

 119     }
 120         
 121     @Test
 122     public void testCreateWithDefaultParams() {
 123         effect = new Bloom(0.3);
 124         setupTest(effect);
 125         assertEquals(0.3, effect.getThreshold(), 1e-100);
 126         pulse();
 127         assertEquals(0.3f, ((com.sun.scenario.effect.Bloom) effect.impl_getImpl()).getThreshold(), 1e-100);

 128     }
 129 }


   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 javafx.scene.effect.Bloom;
  29 import javafx.scene.effect.BoxBlur;
  30 import javafx.scene.effect.EffectShim;
  31 import static test.com.sun.javafx.test.TestHelper.box;
  32 import static org.junit.Assert.assertEquals;
  33 
  34 import org.junit.Before;
  35 import org.junit.Test;
  36 import test.javafx.scene.effect.EffectsTestBase;
  37 
  38 public class BloomTest extends EffectsTestBase {
  39     private Bloom effect;
  40 
  41     @Before
  42     public void setUp() {
  43         effect = new Bloom();
  44         setupTest(effect);
  45     }
  46 
  47     @Test
  48     public void testSetThreshold() {
  49         // try setting correct value
  50         effect.setThreshold(1.0f);
  51         assertEquals(1.0f, (float) effect.getThreshold(), 1e-100);
  52         pulse();
  53         assertEquals(1.0f, (float) ((com.sun.scenario.effect.Bloom)
  54                 EffectShim.impl_getImpl(effect)).getThreshold(), 1e-100);
  55     }
  56     
  57     @Test
  58     public void testDefaultThreshold() {
  59         // default value should be 0.3
  60         assertEquals(0.3f, (float) effect.getThreshold(), 1e-100);
  61         assertEquals(0.3f, (float) effect.thresholdProperty().get(), 1e-100);
  62         pulse();
  63         assertEquals(0.3f, (float) ((com.sun.scenario.effect.Bloom)
  64                 EffectShim.impl_getImpl(effect)).getThreshold(), 1e-100);
  65     }
  66     
  67     @Test
  68     public void testMinThreshold() {
  69         // 0 should be ok
  70         effect.setThreshold(0);
  71         // try setting value smaller than minimal
  72         effect.setThreshold(-0.1f);
  73         assertEquals(-0.1f, (float) effect.getThreshold(), 1e-100);
  74         pulse();
  75         assertEquals(0.0f, (float) ((com.sun.scenario.effect.Bloom)
  76                 EffectShim.impl_getImpl(effect)).getThreshold(), 1e-100);
  77     }
  78 
  79     @Test
  80     public void testMaxThreshold() {
  81         // 1 should be ok
  82         effect.setThreshold(1);
  83         // try setting value greater than maximal
  84         effect.setThreshold(1.1f);
  85         assertEquals(1.1f, (float) effect.getThreshold(), 1e-100);
  86         pulse();
  87         assertEquals(1.0f, (float) ((com.sun.scenario.effect.Bloom)
  88                 EffectShim.impl_getImpl(effect)).getThreshold(), 1e-100);
  89     }
  90 
  91     @Test
  92     public void testThresholdSynced() throws Exception {
  93         checkDoublePropertySynced(
  94                 "javafx.scene.effect.Bloom", "threshold",
  95                 "com.sun.scenario.effect.Bloom", "threshold", 0.3);
  96     }
  97 
  98     @Test
  99     public void testInputSynced() throws Exception {
 100         BoxBlur blur = new BoxBlur();
 101         checkEffectPropertySynced(
 102                 "javafx.scene.effect.Bloom", "input",
 103                 "com.sun.scenario.effect.Bloom", "input",
 104                 blur, 
 105                 (com.sun.scenario.effect.BoxBlur) EffectShim.impl_getImpl(blur));
 106     }
 107 
 108     @Test
 109     public void testBounds() {
 110         assertEquals(box(0, 0, 100, 100), n.getBoundsInLocal());
 111     }
 112 
 113     @Test
 114     public void testBoundsWidthInput() {
 115         assertEquals(box(0, 0, 100, 100), n.getBoundsInLocal());
 116         BoxBlur blur = new BoxBlur();
 117         effect.setInput(blur);
 118         assertEquals(box(-2, -2, 104, 104), n.getBoundsInLocal());
 119     }
 120     
 121     @Test
 122     public void testCreateWithParams() {
 123         effect = new Bloom(1);
 124         setupTest(effect);
 125         assertEquals(1, effect.getThreshold(), 1e-100);
 126         pulse();
 127         assertEquals(1.0f, ((com.sun.scenario.effect.Bloom)
 128                 EffectShim.impl_getImpl(effect)).getThreshold(), 1e-100);
 129     }
 130         
 131     @Test
 132     public void testCreateWithDefaultParams() {
 133         effect = new Bloom(0.3);
 134         setupTest(effect);
 135         assertEquals(0.3, effect.getThreshold(), 1e-100);
 136         pulse();
 137         assertEquals(0.3f, ((com.sun.scenario.effect.Bloom)
 138                 EffectShim.impl_getImpl(effect)).getThreshold(), 1e-100);
 139     }
 140 }