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 GlowTest extends EffectsTestBase { 35 private Glow effect; 36 37 @Before 38 public void setUp() { 39 effect = new Glow(); 40 setupTest(effect); 41 } 42 43 @Test 44 public void testSetLevel() { 45 // try setting correct value 46 effect.setLevel(1); 47 assertEquals(1.0f, (float) effect.getLevel(), 1e-100); 48 pulse(); 49 assertEquals(1.0f, (float) ((com.sun.scenario.effect.Glow)effect.impl_getImpl()).getLevel(), 1e-100); 50 } 51 52 @Test 53 public void testDefaultLevel() { 54 // default value should be 0.3 55 assertEquals(0.3f, (float) effect.getLevel(), 1e-100); 56 assertEquals(0.3f, (float) effect.levelProperty().get(), 1e-100); 57 pulse(); 58 assertEquals(0.3f, (float) ((com.sun.scenario.effect.Glow)effect.impl_getImpl()).getLevel(), 1e-100); 59 } 60 61 @Test 62 public void testMinLevel() { 63 // 0 should be ok 64 effect.setLevel(0); 65 // try setting value smaller than minimal 66 effect.setLevel(-0.1f); 67 assertEquals(-0.1f, (float) effect.getLevel(), 1e-100); 68 pulse(); 69 assertEquals(0.0f, (float) ((com.sun.scenario.effect.Glow)effect.impl_getImpl()).getLevel(), 1e-100); 70 } 71 72 @Test 73 public void testMaxLevel() { 74 // 1 should be ok 75 effect.setLevel(1); 76 // try setting value greater than maximal 77 effect.setLevel(1.1f); 78 assertEquals(1.1f, (float) effect.getLevel(), 1e-100); 79 pulse(); 80 assertEquals(1.0f, (float) ((com.sun.scenario.effect.Glow)effect.impl_getImpl()).getLevel(), 1e-100); 81 } 82 83 @Test 84 public void testCreateWithParams() { 85 effect = new Glow(1); 86 setupTest(effect); 87 assertEquals(1, effect.getLevel(), 1e-100); 88 pulse(); 89 assertEquals(1, ((com.sun.scenario.effect.Glow)effect.impl_getImpl()).getLevel(), 1e-100); 90 } 91 92 @Test 93 public void testLevelSynced() throws Exception { 94 checkDoublePropertySynced( 95 "javafx.scene.effect.Glow", "level", 96 "com.sun.scenario.effect.Glow", "level", 0.5); 97 } 98 99 @Test 100 public void testInputSynced() throws Exception { 101 BoxBlur blur = new BoxBlur(); 102 checkEffectPropertySynced( 103 "javafx.scene.effect.Glow", "input", 104 "com.sun.scenario.effect.Glow", "input", 105 blur, (com.sun.scenario.effect.BoxBlur)blur.impl_getImpl()); 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 }