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 static org.junit.Assert.assertEquals;
  29 import static org.junit.Assert.assertNull;
  30 import javafx.beans.property.DoubleProperty;
  31 import javafx.beans.property.SimpleDoubleProperty;
  32 import javafx.scene.paint.Color;
  33 
  34 import org.junit.Before;
  35 import org.junit.Test;
  36 
  37 import com.sun.scenario.effect.AbstractShadow.ShadowMode;
  38 import com.sun.scenario.effect.Color4f;
  39 import javafx.scene.effect.BlurType;
  40 import javafx.scene.effect.BoxBlur;
  41 import javafx.scene.effect.Shadow;
  42 
  43 public class ShadowTest extends EffectsTestBase {
  44     private Shadow effect;
  45 
  46     @Before
  47     public void setUp() {
  48         effect = new Shadow();
  49         setupTest(effect);
  50     }
  51 
  52     @Test
  53     public void testSetBlurType() {
  54         // try setting correct value
  55         effect.setBlurType(BlurType.ONE_PASS_BOX);
  56         assertEquals(BlurType.ONE_PASS_BOX, effect.getBlurType());
  57         pulse();
  58         assertEquals(ShadowMode.ONE_PASS_BOX, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getShadowMode());
  59         
  60         effect.setBlurType(BlurType.TWO_PASS_BOX);
  61         assertEquals(BlurType.TWO_PASS_BOX, effect.getBlurType());
  62         pulse();
  63         assertEquals(ShadowMode.TWO_PASS_BOX, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getShadowMode());
  64         
  65         effect.setBlurType(BlurType.THREE_PASS_BOX);
  66         assertEquals(BlurType.THREE_PASS_BOX, effect.getBlurType());
  67         pulse();
  68         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getShadowMode());
  69         
  70         effect.setBlurType(BlurType.GAUSSIAN);
  71         assertEquals(BlurType.GAUSSIAN, effect.getBlurType());
  72         pulse();
  73         assertEquals(ShadowMode.GAUSSIAN, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getShadowMode());
  74     }
  75     
  76     @Test
  77     public void testDefaultBlurType() {
  78         // default value should be BlurType.THREE_PASS_BOX
  79         assertEquals(BlurType.THREE_PASS_BOX, effect.getBlurType());
  80         assertEquals(BlurType.THREE_PASS_BOX, effect.blurTypeProperty().get());
  81         pulse();
  82         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getShadowMode());
  83     }
  84 
  85     @Test
  86     public void testNullBlurType() {
  87         // null should default to BlurType.THREE_PASS_BOX in render tree
  88         effect.setBlurType(null);
  89         assertEquals(null, effect.getBlurType());
  90         assertEquals(null, effect.blurTypeProperty().get());
  91         pulse();
  92         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getShadowMode());
  93     }
  94 
  95     @Test
  96     public void testSetColor() {
  97         // try setting correct value
  98         effect.setColor(Color.RED);
  99         assertEquals(Color.RED, effect.getColor());
 100         pulse();
 101         Color color = Color.RED;
 102         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 103                 (float) color.getBlue(), (float) color.getOpacity());
 104         Color4f actual = ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getColor();
 105         assertColor4fEquals(red, actual);
 106     }
 107     
 108     @Test
 109     public void testDefaultColor() {
 110         // default value should be Color.BLACK
 111         assertEquals(Color.BLACK, effect.getColor());
 112         assertEquals(Color.BLACK, effect.colorProperty().get());
 113         pulse();
 114         Color color = Color.BLACK;
 115         Color4f black = new Color4f((float) color.getRed(), (float) color.getGreen(),
 116                 (float) color.getBlue(), (float) color.getOpacity());
 117         Color4f actual = ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getColor();
 118         assertColor4fEquals(black, actual);
 119     }
 120 
 121     @Test
 122     public void testNullColor() {
 123         // null color should default to Color.BLACK in render tree
 124         effect.setColor(null);
 125         assertNull(effect.getColor());
 126         assertNull(effect.colorProperty().get());
 127         pulse();
 128         Color color = Color.BLACK;
 129         Color4f black = new Color4f((float) color.getRed(), (float) color.getGreen(),
 130                 (float) color.getBlue(), (float) color.getOpacity());
 131         Color4f actual = ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getColor();
 132         assertColor4fEquals(black, actual);
 133     }
 134 
 135     @Test
 136     public void testSetWidth() {
 137         // try setting correct value
 138         effect.setWidth(9.0f);
 139         assertEquals(9.0f, effect.getWidth(), 1e-100);
 140         pulse();
 141         assertEquals(9.0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 142         // test that radius changed appropriately
 143         // radius = (((width + height)/2) -1) /2
 144         assertEquals(7.0f, effect.getRadius(), 1e-100);
 145     }
 146     
 147     @Test
 148     public void testDefaultWidth() {
 149         // default value should be 21
 150         assertEquals(21f, effect.getWidth(), 1e-100);
 151         assertEquals(21f, effect.widthProperty().get(), 1e-100);
 152         pulse();
 153         assertEquals(21f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 154     }
 155     
 156     @Test
 157     public void testMinWidth() {
 158         // 0 should be ok
 159         effect.setWidth(0);
 160         // try setting value smaller than minimal
 161         effect.setWidth(-0.1f);
 162         assertEquals(-0.1f, effect.getWidth(), 1e-100);
 163         pulse();
 164         assertEquals(0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 165     }
 166 
 167     @Test
 168     public void testMaxWidth() {
 169         // 255 should be ok
 170         effect.setWidth(255);
 171         // try setting value greater than maximal
 172         effect.setWidth(255.1f);
 173         assertEquals(255.1f, effect.getWidth(), 1e-100);
 174         pulse();
 175         assertEquals(255f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 176     }
 177  
 178     @Test
 179     public void testSetHeight() {
 180         // try setting correct value
 181         effect.setHeight(9.0f);
 182         assertEquals(9.0f, effect.getHeight(), 1e-100);
 183         pulse();
 184         assertEquals(9.0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 185         // test that radius changed appropriately
 186         // radius = (((width + height)/2) -1) /2        
 187         assertEquals(7.0f, effect.getRadius(), 1e-100);
 188     }
 189     
 190     @Test
 191     public void testDefaultHeight() {
 192         // default value should be 21
 193         assertEquals(21f, effect.getHeight(), 1e-100);
 194         assertEquals(21f, effect.heightProperty().get(), 1e-100);
 195         pulse();
 196         assertEquals(21f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 197     }
 198     
 199     @Test
 200     public void testMinHeight() {
 201         // 0 should be ok
 202         effect.setHeight(0);
 203         // try setting value smaller than minimal
 204         effect.setHeight(-0.1f);
 205         assertEquals(-0.1f, effect.getHeight(), 1e-100);
 206         pulse();
 207         assertEquals(0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianHeight(), 1e-100);        
 208     }
 209 
 210     @Test
 211     public void testMaxHeight() {
 212         // 255 should be ok
 213         effect.setHeight(1);
 214         // try setting value greater than maximal
 215         effect.setHeight(255.1f); 
 216         assertEquals(255.1f, effect.getHeight(), 1e-100);
 217         pulse();
 218         assertEquals(255f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getGaussianHeight(), 1e-100);        
 219     }
 220        
 221     @Test
 222     public void testSetRadius() {
 223         // try setting correct value
 224         effect.setRadius(4.0f);
 225         assertEquals(4.0f, effect.getRadius(), 1e-100);
 226         pulse();
 227         assertEquals(4.0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getRadius(), 1e-100);
 228         // test that width and height changed appropriately
 229         assertEquals(9.0f, effect.getHeight(), 1e-100);
 230         assertEquals(9.0f, effect.getWidth(), 1e-100);
 231     }
 232     
 233     @Test
 234     public void testDefaultRadius() {
 235         // default value should be 10
 236         assertEquals(10f, effect.getRadius(), 1e-100);
 237         assertEquals(10f, effect.radiusProperty().get(), 1e-100);
 238         pulse();
 239         assertEquals(10f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getRadius(), 1e-100);
 240     }
 241     
 242     @Test
 243     public void testMinRadius() {
 244         // 0 should be ok
 245         effect.setRadius(0);
 246         // try setting value smaller than minimal
 247         effect.setRadius(-0.1f);
 248         assertEquals(-0.1f, effect.getRadius(), 1e-100);
 249         pulse();
 250         assertEquals(0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getRadius(), 1e-100);        
 251     }
 252 
 253     @Test
 254     public void testMaxRadius() {
 255         // 127 should be ok
 256         effect.setRadius(127);
 257         // try setting value greater than maximal
 258         effect.setRadius(127.1f); 
 259         assertEquals(127.1f, effect.getRadius(), 1e-100);
 260         pulse();
 261         assertEquals(127f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getRadius(), 1e-100);           
 262     }
 263     
 264     @Test
 265     public void testRadiusNotNegative() {
 266         effect.setHeight(0.1f);
 267         effect.setWidth(0.1f);
 268         // radius should be 0, not negative
 269         assertEquals(0f, effect.getRadius(), 1e-100);
 270         pulse();
 271         assertEquals(0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getRadius(), 1e-100);
 272 
 273         effect.setWidth(0.2f);
 274         effect.setHeight(0.2f);
 275         // radius should be 0, not negative
 276         assertEquals(0f, effect.getRadius(), 1e-100);
 277         pulse();
 278         assertEquals(0f, ((com.sun.scenario.effect.GeneralShadow)effect.impl_getImpl()).getRadius(), 1e-100);
 279     }
 280 
 281     @Test
 282     public void testHeightSynced() throws Exception {
 283         checkDoublePropertySynced(
 284                 "javafx.scene.effect.Shadow", "height",
 285                 "com.sun.scenario.effect.GeneralShadow", "gaussianHeight", 9);
 286         assertEquals(7, effect.getRadius(), 1e-100);
 287     }
 288 
 289     @Test
 290     public void testWidthSynced() throws Exception {
 291         checkDoublePropertySynced(
 292                 "javafx.scene.effect.Shadow", "width",
 293                 "com.sun.scenario.effect.GeneralShadow", "gaussianWidth", 9);
 294         assertEquals(7, effect.getRadius(), 1e-100);
 295     }
 296 
 297     @Test
 298     public void testBlurTypeSynced() throws Exception {
 299         checkObjectPropertySynced(
 300                 "javafx.scene.effect.Shadow", "blurType",
 301                 "com.sun.scenario.effect.GeneralShadow", "shadowMode",
 302                 BlurType.TWO_PASS_BOX, ShadowMode.TWO_PASS_BOX,
 303                 BlurType.GAUSSIAN);
 304     }
 305 
 306     @Test
 307     public void testRadiusSynced() throws Exception {
 308         checkDoublePropertySynced(
 309                 "javafx.scene.effect.Shadow", "radius",
 310                 "com.sun.scenario.effect.GeneralShadow", "radius", 4);
 311         assertEquals(9, effect.getHeight(), 1e-100);
 312         assertEquals(9, effect.getWidth(), 1e-100);
 313     }
 314 
 315     @Test
 316     public void testInputSynced() throws Exception {
 317         BoxBlur blur = new BoxBlur();
 318         checkEffectPropertySynced(
 319                 "javafx.scene.effect.Shadow", "input",
 320                 "com.sun.scenario.effect.GeneralShadow", "input",
 321                 blur, (com.sun.scenario.effect.BoxBlur)blur.impl_getImpl());
 322     }
 323 
 324     @Test
 325     public void testColorSynced() throws Exception {
 326         Color color = Color.RED;
 327         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 328                 (float) color.getBlue(), (float) color.getOpacity());
 329         Color4f result = (Color4f) getObjectPropertySynced(
 330                 "javafx.scene.effect.Shadow", "color",
 331                 "com.sun.scenario.effect.GeneralShadow", "color",
 332                 Color.RED);
 333         assertColor4fEquals(red, result);
 334     }
 335 
 336     // test whether width/height are changing correctly if radius is bound
 337     // and one of them is changed
 338     @Test
 339     public void testRadiusBound() throws Exception {
 340         DoubleProperty boundRadius = new SimpleDoubleProperty();
 341 
 342         effect.radiusProperty().bind(boundRadius);
 343 
 344         boundRadius.set(4);
 345         effect.setWidth(9);
 346 
 347         assertEquals(9, effect.getHeight(), 1e-100);
 348         pulse();
 349         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 350         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 351         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 352 
 353         effect.setHeight(3);
 354         assertEquals(15, effect.getWidth(), 1e-100);
 355         pulse();
 356         assertEquals(15, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 357     }
 358 
 359     // test whether width/radius are changing correctly if height is bound
 360     // and one of them is changed
 361     @Test
 362     public void testHeightBound() throws Exception {
 363         DoubleProperty boundHeight = new SimpleDoubleProperty();
 364 
 365         effect.heightProperty().bind(boundHeight);
 366 
 367         boundHeight.set(9);
 368         effect.setRadius(4);
 369 
 370         assertEquals(9, effect.getWidth(), 1e-100);
 371         pulse();
 372         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 373         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 374         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 375 
 376         effect.setWidth(3);
 377         assertEquals(2.5, effect.getRadius(), 1e-100);
 378     }
 379 
 380     // test whether height/radius are changing correctly if width is bound
 381     // and one of them is changed
 382     @Test
 383     public void testWidthBound() throws Exception {
 384         DoubleProperty boundWidth = new SimpleDoubleProperty();
 385 
 386         effect.widthProperty().bind(boundWidth);
 387 
 388         boundWidth.set(9);
 389         effect.setRadius(4);
 390 
 391         assertEquals(9, effect.getHeight(), 1e-100);
 392         pulse();
 393         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 394         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 395         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 396 
 397         effect.setHeight(3);
 398         assertEquals(2.5, effect.getRadius(), 1e-100);
 399     }
 400 
 401     // Test for special cases when 2 of width, height, radius are bound
 402     @Test
 403     public void testRadiusWidthBound() throws Exception {
 404         DoubleProperty boundRadius = new SimpleDoubleProperty();
 405         DoubleProperty boundWidth = new SimpleDoubleProperty();
 406 
 407         effect.radiusProperty().bind(boundRadius);
 408         effect.widthProperty().bind(boundWidth);
 409 
 410         boundRadius.set(4);
 411         boundWidth.set(9);
 412 
 413         assertEquals(9, effect.getHeight(), 1e-100);
 414         pulse();
 415         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 416         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 417         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 418 
 419         // set radius once again to be sure that the order of calls is not
 420         // important
 421         boundRadius.set(7);
 422         assertEquals(21, effect.getHeight(), 1e-100);
 423         pulse();
 424         assertEquals(21, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 425     }
 426 
 427     @Test
 428     public void testRadiusHeightBound() throws Exception {
 429         DoubleProperty boundRadius = new SimpleDoubleProperty();
 430         DoubleProperty boundHeight = new SimpleDoubleProperty();
 431 
 432         effect.radiusProperty().bind(boundRadius);
 433         effect.heightProperty().bind(boundHeight);
 434 
 435         boundRadius.set(4);
 436         boundHeight.set(9);
 437 
 438         assertEquals(9, effect.getWidth(), 1e-100);
 439         pulse();
 440         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 441         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 442         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 443 
 444         boundRadius.set(7);
 445         assertEquals(21, effect.getWidth(), 1e-100);
 446         pulse();
 447         assertEquals(21, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 448     }
 449 
 450     @Test
 451     public void testWidthHeightBound() throws Exception {
 452         DoubleProperty boundWidth = new SimpleDoubleProperty();
 453         DoubleProperty boundHeight = new SimpleDoubleProperty();
 454 
 455         effect.widthProperty().bind(boundWidth);
 456         effect.heightProperty().bind(boundHeight);
 457 
 458         boundHeight.set(9);
 459         boundWidth.set(9);
 460 
 461         assertEquals(4, effect.getRadius(), 1e-100);
 462         pulse();
 463         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 464         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 465         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 466 
 467         boundHeight.set(21);
 468         assertEquals(7, effect.getRadius(), 1e-100);
 469         pulse();
 470         assertEquals(7, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 471     }
 472 
 473     // all radius, width and height are bound, radius is ignored in this case
 474     // just test that it doesn't end in infinite loop
 475     @Test
 476     public void testWidthHeightRadiusBound() {
 477         DoubleProperty boundWidth = new SimpleDoubleProperty();
 478         DoubleProperty boundHeight = new SimpleDoubleProperty();
 479         DoubleProperty boundRadius = new SimpleDoubleProperty();
 480 
 481         effect.widthProperty().bind(boundWidth);
 482         effect.heightProperty().bind(boundHeight);
 483         effect.radiusProperty().bind(boundRadius);
 484 
 485         boundHeight.set(9);
 486         boundWidth.set(9);
 487         boundRadius.set(5);
 488 
 489         pulse();
 490         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 491         assertEquals(9, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 492         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 493     }
 494 
 495     @Test
 496     public void testCreateWithParams() {
 497         effect = new Shadow(4, Color.RED);
 498         setupTest(effect);
 499         assertEquals(4, effect.getRadius(), 1e-100);
 500         assertEquals(Color.RED, effect.getColor());
 501         // test that width and height changed appropriately
 502         assertEquals(9, effect.getHeight(), 1e-100);
 503         assertEquals(9, effect.getWidth(), 1e-100);
 504         pulse();
 505         assertEquals(4, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 506         Color color = Color.RED;
 507         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 508                 (float) color.getBlue(), (float) color.getOpacity());
 509         Color4f actual = ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getColor();
 510         assertColor4fEquals(red, actual);
 511     }
 512     
 513     @Test
 514     public void testCreateWithParams3() {
 515         effect = new Shadow(BlurType.GAUSSIAN, Color.RED, 4);
 516         setupTest(effect);
 517         assertEquals(4, effect.getRadius(), 1e-100);
 518         assertEquals(Color.RED, effect.getColor());
 519         assertEquals(BlurType.GAUSSIAN, effect.getBlurType());
 520         // test that width and height changed appropriately
 521         assertEquals(9, effect.getHeight(), 1e-100);
 522         assertEquals(9, effect.getWidth(), 1e-100);
 523         pulse();
 524         assertEquals(4f, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 525         assertEquals(ShadowMode.GAUSSIAN, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getShadowMode());
 526         Color color = Color.RED;
 527         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 528                 (float) color.getBlue(), (float) color.getOpacity());
 529         Color4f actual = ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getColor();
 530         assertColor4fEquals(red, actual);
 531     }
 532 
 533     @Test
 534     public void testCreateWithDefaultParams() {
 535         effect = new Shadow(10, Color.BLACK);
 536         setupTest(effect);
 537         assertEquals(10, effect.getRadius(), 1e-100);
 538         assertEquals(Color.BLACK, effect.getColor());
 539         // test that width and height changed appropriately
 540         assertEquals(21, effect.getHeight(), 1e-100);
 541         assertEquals(21, effect.getWidth(), 1e-100);
 542         pulse();
 543         assertEquals(10, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 544         Color color = Color.BLACK;
 545         Color4f black = new Color4f((float) color.getRed(), (float) color.getGreen(),
 546                 (float) color.getBlue(), (float) color.getOpacity());
 547         Color4f actual = ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getColor();
 548         assertColor4fEquals(black, actual);
 549     }
 550 
 551     @Test
 552     public void testCreateWithDefaultParams3() {
 553         effect = new Shadow(BlurType.THREE_PASS_BOX, Color.BLACK, 10);
 554         setupTest(effect);
 555         assertEquals(10, effect.getRadius(), 1e-100);
 556         assertEquals(Color.BLACK, effect.getColor());
 557         assertEquals(BlurType.THREE_PASS_BOX, effect.getBlurType());
 558         // test that width and height changed appropriately
 559         assertEquals(21, effect.getHeight(), 1e-100);
 560         assertEquals(21, effect.getWidth(), 1e-100);
 561         pulse();
 562         assertEquals(10f, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 563         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getShadowMode());
 564         Color color = Color.BLACK;
 565         Color4f black = new Color4f((float) color.getRed(), (float) color.getGreen(),
 566                 (float) color.getBlue(), (float) color.getOpacity());
 567         Color4f actual = ((com.sun.scenario.effect.GeneralShadow) effect.impl_getImpl()).getColor();
 568         assertColor4fEquals(black, actual);
 569     }
 570 }