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.SepiaTone; 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 SepiaToneTest extends EffectsTestBase { 37 private SepiaTone effect; 38 39 @Before 40 public void setUp() { 41 effect = new SepiaTone(); 42 setupTest(effect); 43 } 44 45 @Test 46 public void testSetLevel() { 47 // try setting correct value 48 effect.setLevel(0.5f); 49 assertEquals(0.5f, effect.getLevel(), 1e-100); 50 pulse(); 51 assertEquals(0.5f, ((com.sun.scenario.effect.SepiaTone)effect.impl_getImpl()).getLevel(), 1e-100); 52 } 53 54 @Test 55 public void testDefaultLevel() { 56 // default value should be 1 57 assertEquals(1f, effect.getLevel(), 1e-100); 58 assertEquals(1f, effect.levelProperty().get(), 1e-100); 59 pulse(); 60 assertEquals(1f, ((com.sun.scenario.effect.SepiaTone)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, effect.getLevel(), 1e-100); 70 pulse(); 71 assertEquals(0f, ((com.sun.scenario.effect.SepiaTone)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, effect.getLevel(), 1e-100); 81 pulse(); 82 assertEquals(1f, ((com.sun.scenario.effect.SepiaTone)effect.impl_getImpl()).getLevel(), 1e-100); 83 } 84 85 @Test 86 public void testLevelSynced() throws Exception { 87 checkDoublePropertySynced( 88 "javafx.scene.effect.SepiaTone", "level", 89 "com.sun.scenario.effect.SepiaTone", "level", 0.5); 90 } 91 92 @Test 93 public void testInputSynced() throws Exception { 94 BoxBlur blur = new BoxBlur(); 95 checkEffectPropertySynced( 96 "javafx.scene.effect.SepiaTone", "input", 97 "com.sun.scenario.effect.SepiaTone", "input", 98 blur, (com.sun.scenario.effect.BoxBlur)blur.impl_getImpl()); 99 } 100 101 @Test 102 public void testBounds() { 103 assertEquals(box(0, 0, 100, 100), n.getBoundsInLocal()); 104 } 105 106 @Test 107 public void testBoundsWidthInput() { 108 assertEquals(box(0, 0, 100, 100), n.getBoundsInLocal()); 109 BoxBlur blur = new BoxBlur(); 110 effect.setInput(blur); 111 assertEquals(box(-2, -2, 104, 104), n.getBoundsInLocal()); 112 } 113 114 @Test 115 public void testCreateWithParams() { 116 effect = new SepiaTone(0.1); 117 setupTest(effect); 118 assertEquals(0.1, effect.getLevel(), 1e-100); 119 pulse(); 120 assertEquals(0.1f, ((com.sun.scenario.effect.SepiaTone) effect.impl_getImpl()).getLevel(), 1e-100); 121 } 122 123 @Test 124 public void testCreateWithDefaultParams() { 125 effect = new SepiaTone(1); 126 setupTest(effect); 127 assertEquals(1, effect.getLevel(), 1e-100); 128 pulse(); 129 assertEquals(1f, ((com.sun.scenario.effect.SepiaTone) effect.impl_getImpl()).getLevel(), 1e-100); 130 } 131 }