1 /* 2 * Copyright (c) 2010, 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 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 }