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