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 org.junit.Assert.assertEquals; 29 30 import com.sun.javafx.FXUnit; 31 import org.junit.Before; 32 import org.junit.Rule; 33 import org.junit.Test; 34 35 public class GaussianBlurTest extends EffectsTestBase { 36 37 @Rule 38 public FXUnit fx = new FXUnit(); 39 40 private GaussianBlur effect; 41 42 @Before 43 public void setUp() { 44 effect = new GaussianBlur(); 45 setupTest(effect); 46 } 47 48 @Test 49 public void testSetRadius() { 50 // try setting correct value 51 effect.setRadius(1.0f); 52 assertEquals(1.0f, effect.getRadius(), 1e-100); 53 pulse(); 54 assertEquals(1.0f, ((com.sun.scenario.effect.GaussianBlur)effect.impl_getImpl()).getRadius(), 1e-100); 55 } 56 57 @Test 58 public void testDefaultRadius() { 59 // default value should be 10 60 assertEquals(10, effect.getRadius(), 1e-10); 61 assertEquals(10, effect.radiusProperty().get(), 1e-10); 62 pulse(); 63 assertEquals(10, ((com.sun.scenario.effect.GaussianBlur)effect.impl_getImpl()).getRadius(), 1e-100); 64 } 65 66 @Test 67 public void testMinRadius() { 68 // 0 should be ok 69 effect.setRadius(0); 70 // try setting value smaller than minimal 71 effect.setRadius(-0.1f); 72 assertEquals(-0.1f, effect.getRadius(), 1e-100); 73 pulse(); 74 assertEquals(0f, ((com.sun.scenario.effect.GaussianBlur)effect.impl_getImpl()).getRadius(), 1e-100); 75 } 76 77 @Test 78 public void testMaxRadius() { 79 // 63 should be ok 80 effect.setRadius(63); 81 // try setting value greater than maximal 82 effect.setRadius(63.1f); 83 assertEquals(63.1f, effect.getRadius(), 1e-100); 84 pulse(); 85 assertEquals(63f, ((com.sun.scenario.effect.GaussianBlur)effect.impl_getImpl()).getRadius(), 1e-100); 86 } 87 88 @Test 89 public void testRadiusSynced() throws Exception { 90 checkDoublePropertySynced( 91 "javafx.scene.effect.GaussianBlur", "radius", 92 "com.sun.scenario.effect.GaussianBlur", "radius", 15); 93 } 94 95 @Test 96 public void testInputSynced() throws Exception { 97 BoxBlur blur = new BoxBlur(); 98 checkEffectPropertySynced( 99 "javafx.scene.effect.GaussianBlur", "input", 100 "com.sun.scenario.effect.GaussianBlur", "input", 101 blur, (com.sun.scenario.effect.BoxBlur)blur.impl_getImpl()); 102 } 103 104 @Test 105 public void testCreateWithParams() { 106 effect = new GaussianBlur(4); 107 setupTest(effect); 108 assertEquals(4, effect.getRadius(), 1e-100); 109 pulse(); 110 assertEquals(4f, ((com.sun.scenario.effect.GaussianBlur) effect.impl_getImpl()).getRadius(), 1e-100); 111 } 112 113 @Test 114 public void testCreateWithDefaultParams() { 115 effect = new GaussianBlur(10); 116 setupTest(effect); 117 assertEquals(10, effect.getRadius(), 1e-100); 118 pulse(); 119 assertEquals(10f, ((com.sun.scenario.effect.GaussianBlur) effect.impl_getImpl()).getRadius(), 1e-100); 120 } 121 }