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 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 
  40 public class DropShadowTest extends EffectsTestBase {
  41     private DropShadow effect;
  42 
  43     @Before
  44     public void setUp() {
  45         effect = new DropShadow();
  46         setupTest(effect);
  47     }
  48 
  49     @Test
  50     public void testSetBlurType() {
  51         // try setting correct value
  52         effect.setBlurType(BlurType.ONE_PASS_BOX);
  53         assertEquals(BlurType.ONE_PASS_BOX, effect.getBlurType());
  54         pulse();
  55         assertEquals(ShadowMode.ONE_PASS_BOX, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
  56 
  57         effect.setBlurType(BlurType.TWO_PASS_BOX);
  58         assertEquals(BlurType.TWO_PASS_BOX, effect.getBlurType());
  59         pulse();
  60         assertEquals(ShadowMode.TWO_PASS_BOX, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
  61 
  62         effect.setBlurType(BlurType.THREE_PASS_BOX);
  63         assertEquals(BlurType.THREE_PASS_BOX, effect.getBlurType());
  64         pulse();
  65         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
  66 
  67         effect.setBlurType(BlurType.GAUSSIAN);
  68         assertEquals(BlurType.GAUSSIAN, effect.getBlurType());
  69         pulse();
  70         assertEquals(ShadowMode.GAUSSIAN, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
  71     }
  72 
  73     @Test
  74     public void testNullBlurType() {
  75         // null should default to BlurType.THREE_PASS_BOX in render tree
  76         effect.setBlurType(null);
  77         assertEquals(null, effect.getBlurType());
  78         assertEquals(null, effect.blurTypeProperty().get());
  79         pulse();
  80         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
  81     }
  82 
  83     @Test
  84     public void testDefaultBlurType() {
  85         // default value should be BlurType.THREE_PASS_BOX
  86         assertEquals(BlurType.THREE_PASS_BOX, effect.getBlurType());
  87         assertEquals(BlurType.THREE_PASS_BOX, effect.blurTypeProperty().get());
  88         pulse();
  89         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
  90     }
  91 
  92 
  93     @Test
  94     public void testSetColor() {
  95         // try setting correct value
  96         effect.setColor(Color.RED);
  97         assertEquals(Color.RED, effect.getColor());
  98         pulse();
  99         Color color = Color.RED;
 100         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 101                 (float) color.getBlue(), (float) color.getOpacity());
 102         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 103         assertColor4fEquals(red, actual);
 104     }
 105 
 106     @Test
 107     public void testDefaultColor() {
 108         // default value should be Color.BLACK
 109         assertEquals(Color.BLACK, effect.getColor());
 110         assertEquals(Color.BLACK, effect.colorProperty().get());
 111         pulse();
 112         Color color = Color.BLACK;
 113         Color4f black = new Color4f((float) color.getRed(), (float) color.getGreen(),
 114                 (float) color.getBlue(), (float) color.getOpacity());
 115         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 116         assertColor4fEquals(black, actual);
 117     }
 118 
 119     @Test
 120     public void testNullColor() {
 121         // null color should default to Color.BLACK in render tree
 122         effect.setColor(null);
 123         assertNull(effect.getColor());
 124         assertNull(effect.colorProperty().get());
 125         pulse();
 126         Color color = Color.BLACK;
 127         Color4f black = new Color4f((float) color.getRed(), (float) color.getGreen(),
 128                 (float) color.getBlue(), (float) color.getOpacity());
 129         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 130         assertColor4fEquals(black, actual);
 131     }
 132 
 133     @Test
 134     public void testSetWidth() {
 135         // try setting correct value
 136         effect.setWidth(9.0f);
 137         assertEquals(9.0f, effect.getWidth(), 1e-100);
 138         pulse();
 139         assertEquals(9.0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 140         // test that radius changed appropriately
 141         // radius = (((width + height)/2) -1) /2
 142         assertEquals(7.0f, effect.getRadius(), 1e-100);
 143     }
 144 
 145     @Test
 146     public void testDefaultWidth() {
 147         // default value should be 21
 148         assertEquals(21f, effect.getWidth(), 1e-100);
 149         assertEquals(21f, effect.widthProperty().get(), 1e-100);
 150         pulse();
 151         assertEquals(21f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 152     }
 153 
 154     @Test
 155     public void testMinWidth() {
 156         // 0 should be ok
 157         effect.setWidth(0);
 158         // try setting value smaller than minimal
 159         effect.setWidth(-0.1f);
 160         assertEquals(-0.1f, effect.getWidth(), 1e-100);
 161         pulse();
 162         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 163     }
 164 
 165     @Test
 166     public void testMaxWidth() {
 167         // 255 should be ok
 168         effect.setWidth(255);
 169         // try setting value greater than maximal
 170         effect.setWidth(255.1f);
 171         assertEquals(255.1f, effect.getWidth(), 1e-100);
 172         pulse();
 173         assertEquals(255f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 174     }
 175 
 176     @Test
 177     public void testSetHeight() {
 178         // try setting correct value
 179         effect.setHeight(9.0f);
 180         assertEquals(9.0f, effect.getHeight(), 1e-100);
 181         pulse();
 182         assertEquals(9.0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 183         // test that radius changed appropriately
 184         // radius = (((width + height)/2) -1) /2
 185         assertEquals(7.0f, effect.getRadius(), 1e-100);
 186     }
 187 
 188     @Test
 189     public void testDefaultHeight() {
 190         // default value should be 21
 191         assertEquals(21f, effect.getHeight(), 1e-100);
 192         assertEquals(21f, effect.heightProperty().get(), 1e-100);
 193         pulse();
 194         assertEquals(21f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 195     }
 196 
 197     @Test
 198     public void testMinHeight() {
 199         // 0 should be ok
 200         effect.setHeight(0);
 201         // try setting value smaller than minimal
 202         effect.setHeight(-0.1f);
 203         assertEquals(-0.1f, effect.getHeight(), 1e-100);
 204         pulse();
 205         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 206     }
 207 
 208     @Test
 209     public void testMaxHeight() {
 210         // 255 should be ok
 211         effect.setHeight(1);
 212         // try setting value greater than maximal
 213         effect.setHeight(255.1f);
 214         assertEquals(255.1f, effect.getHeight(), 1e-100);
 215         pulse();
 216         assertEquals(255f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 217     }
 218 
 219     @Test
 220     public void testSetRadius() {
 221         // try setting correct value
 222         effect.setRadius(4.0f);
 223         assertEquals(4.0f, effect.getRadius(), 1e-100);
 224         pulse();
 225         assertEquals(4.0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getRadius(), 1e-100);
 226         // test that width and height changed appropriately
 227         assertEquals(9.0f, effect.getHeight(), 1e-100);
 228         assertEquals(9.0f, effect.getWidth(), 1e-100);
 229     }
 230 
 231     @Test
 232     public void testDefaultRadius() {
 233         // default value should be 10
 234         assertEquals(10f, effect.getRadius(), 1e-100);
 235         assertEquals(10f, effect.radiusProperty().get(), 1e-100);
 236         pulse();
 237         assertEquals(10f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getRadius(), 1e-100);
 238     }
 239 
 240     @Test
 241     public void testMinRadius() {
 242         // 0 should be ok
 243         effect.setRadius(0);
 244         // try setting value smaller than minimal
 245         effect.setRadius(-0.1f);
 246         assertEquals(-0.1f, effect.getRadius(), 1e-100);
 247         pulse();
 248         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getRadius(), 1e-100);
 249     }
 250 
 251     @Test
 252     public void testMaxRadius() {
 253         // 127 should be ok
 254         effect.setRadius(127);
 255         // try setting value greater than maximal
 256         effect.setRadius(127.1f);
 257         assertEquals(127.1f, effect.getRadius(), 1e-100);
 258         pulse();
 259         assertEquals(127f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getRadius(), 1e-100);
 260     }
 261 
 262     @Test
 263     public void testRadiusNotNegative() {
 264         effect.setHeight(0.1f);
 265         effect.setWidth(0.1f);
 266         // radius should be 0, not negative
 267         assertEquals(0f, effect.getRadius(), 1e-100);
 268         pulse();
 269         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getRadius(), 1e-100);
 270 
 271         effect.setWidth(0.2f);
 272         effect.setHeight(0.2f);
 273         // radius should be 0, not negative
 274         assertEquals(0f, effect.getRadius(), 1e-100);
 275         pulse();
 276         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getRadius(), 1e-100);
 277     }
 278 
 279     @Test
 280     public void testSetSpread() {
 281         // try setting correct value
 282         effect.setSpread(1.0f);
 283         assertEquals(1.0f, effect.getSpread(), 1e-100);
 284         pulse();
 285         assertEquals(1.0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getSpread(), 1e-100);
 286     }
 287 
 288     @Test
 289     public void testDefaultSpread() {
 290         // default value should be 0
 291         assertEquals(0f, effect.getSpread(), 1e-100);
 292         assertEquals(0f, effect.spreadProperty().get(), 1e-100);
 293         pulse();
 294         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getSpread(), 1e-100);
 295     }
 296 
 297     @Test
 298     public void testMinSpread() {
 299         // 0 should be ok
 300         effect.setSpread(0);
 301         // try setting value smaller than minimal
 302         effect.setSpread(-0.1f);
 303         assertEquals(-0.1f, effect.getSpread(), 1e-100);
 304         pulse();
 305         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getSpread(), 1e-100);
 306     }
 307 
 308     @Test
 309     public void testMaxSpread() {
 310         // 1 should be ok
 311         effect.setSpread(1);
 312         // try setting value greater than maximal
 313         effect.setSpread(1.1f);
 314         assertEquals(1.1f, effect.getSpread(), 1e-100);
 315         pulse();
 316         assertEquals(1f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getSpread(), 1e-100);
 317     }
 318 
 319     @Test
 320     public void testSetOffsetX() {
 321         // try setting correct value
 322         effect.setOffsetX(1.0f);
 323         assertEquals(1.0f, effect.getOffsetX(), 1e-100);
 324         pulse();
 325         assertEquals(1.0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetX(), 1e-100);
 326     }
 327 
 328     @Test
 329     public void testDefaultOffsetX() {
 330         // default value should be 0
 331         assertEquals(0f, effect.getOffsetX(), 1e-100);
 332         assertEquals(0f, effect.offsetXProperty().get(), 1e-100);
 333         pulse();
 334         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetX(), 1e-100);
 335     }
 336 
 337     @Test
 338     public void testSetOffsetY() {
 339         // try setting correct value
 340         effect.setOffsetY(1.0f);
 341         assertEquals(1.0f, effect.getOffsetY(), 1e-100);
 342         pulse();
 343         assertEquals(1.0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetY(), 1e-100);
 344     }
 345 
 346     @Test
 347     public void testDefaultOffsetY() {
 348         // default value should be 0
 349         assertEquals(0f, effect.getOffsetY(), 1e-100);
 350         assertEquals(0f, effect.offsetYProperty().get(), 1e-100);
 351         pulse();
 352         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetY(), 1e-100);
 353     }
 354 
 355     @Test
 356     public void testHeightSynced() throws Exception {
 357         checkDoublePropertySynced(
 358                 "javafx.scene.effect.DropShadow", "height",
 359                 "com.sun.scenario.effect.DropShadow", "gaussianHeight", 9);
 360         assertEquals(7, effect.getRadius(), 1e-100);
 361     }
 362 
 363     @Test
 364     public void testWidthSynced() throws Exception {
 365         checkDoublePropertySynced(
 366                 "javafx.scene.effect.DropShadow", "width",
 367                 "com.sun.scenario.effect.DropShadow", "gaussianWidth", 9);
 368         assertEquals(7, effect.getRadius(), 1e-100);
 369     }
 370 
 371     @Test
 372     public void testBlurTypeSynced() throws Exception {
 373         checkObjectPropertySynced(
 374                 "javafx.scene.effect.DropShadow", "blurType",
 375                 "com.sun.scenario.effect.DropShadow", "shadowMode",
 376                 BlurType.TWO_PASS_BOX, ShadowMode.TWO_PASS_BOX,
 377                 BlurType.GAUSSIAN);
 378     }
 379 
 380     @Test
 381     public void testOffsetXSynced() throws Exception {
 382         checkDoublePropertySynced(
 383                 "javafx.scene.effect.DropShadow", "offsetX",
 384                 "com.sun.scenario.effect.DropShadow", "offsetX", 10);
 385     }
 386 
 387     @Test
 388     public void testOffsetYSynced() throws Exception {
 389         checkDoublePropertySynced(
 390                 "javafx.scene.effect.DropShadow", "offsetY",
 391                 "com.sun.scenario.effect.DropShadow", "offsetY", 10);
 392     }
 393 
 394     @Test
 395     public void testRadiusSynced() throws Exception {
 396         checkDoublePropertySynced(
 397                 "javafx.scene.effect.DropShadow", "radius",
 398                 "com.sun.scenario.effect.DropShadow", "radius", 4);
 399         assertEquals(9, effect.getHeight(), 1e-100);
 400         assertEquals(9, effect.getWidth(), 1e-100);
 401     }
 402 
 403     @Test
 404     public void testSpreadSynced() throws Exception {
 405         checkDoublePropertySynced(
 406                 "javafx.scene.effect.DropShadow", "spread",
 407                 "com.sun.scenario.effect.DropShadow", "spread", 0.3);
 408     }
 409 
 410     @Test
 411     public void testInputSynced() throws Exception {
 412         BoxBlur blur = new BoxBlur();
 413         checkEffectPropertySynced(
 414                 "javafx.scene.effect.DropShadow", "input",
 415                 "com.sun.scenario.effect.DropShadow", "contentInput",
 416                 blur, (com.sun.scenario.effect.BoxBlur)blur.impl_getImpl());
 417     }
 418 
 419     @Test
 420     public void testColorSynced() throws Exception {
 421         Color color = Color.RED;
 422         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 423                 (float) color.getBlue(), (float) color.getOpacity());
 424         Color4f result = (Color4f) getObjectPropertySynced(
 425                 "javafx.scene.effect.DropShadow", "color",
 426                 "com.sun.scenario.effect.DropShadow", "color",
 427                 Color.RED);
 428         assertColor4fEquals(red, result);
 429     }
 430 
 431     // test whether width/height are changing correctly if radius is bound
 432     // and one of them is changed
 433     @Test
 434     public void testRadiusBound() throws Exception {
 435         DoubleProperty boundRadius = new SimpleDoubleProperty();
 436 
 437         effect.radiusProperty().bind(boundRadius);
 438 
 439         boundRadius.set(4);
 440         effect.setWidth(9);
 441 
 442         assertEquals(9, effect.getHeight(), 1e-100);
 443         pulse();
 444         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 445         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 446         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 447 
 448         effect.setHeight(3);
 449         assertEquals(15, effect.getWidth(), 1e-100);
 450         pulse();
 451         assertEquals(15, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 452     }
 453 
 454     // test whether width/radius are changing correctly if height is bound
 455     // and one of them is changed    
 456     @Test
 457     public void testHeightBound() throws Exception {
 458         DoubleProperty boundHeight = new SimpleDoubleProperty();
 459 
 460         effect.heightProperty().bind(boundHeight);
 461 
 462         boundHeight.set(9);
 463         effect.setRadius(4);
 464 
 465         assertEquals(9, effect.getWidth(), 1e-100);
 466         pulse();
 467         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 468         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 469         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 470 
 471         effect.setWidth(3);
 472         assertEquals(2.5, effect.getRadius(), 1e-100);
 473     }
 474 
 475     // test whether height/radius are changing correctly if width is bound
 476     // and one of them is changed
 477     @Test
 478     public void testWidthBound() throws Exception {
 479         DoubleProperty boundWidth = new SimpleDoubleProperty();
 480 
 481         effect.widthProperty().bind(boundWidth);
 482 
 483         boundWidth.set(9);
 484         effect.setRadius(4);
 485 
 486         assertEquals(9, effect.getHeight(), 1e-100);
 487         pulse();
 488         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 489         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 490         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 491 
 492         effect.setHeight(3);
 493         assertEquals(2.5, effect.getRadius(), 1e-100);
 494     }
 495 
 496     // Test for special cases when 2 of width, height, radius are bound
 497     @Test
 498     public void testRadiusWidthBound() throws Exception {
 499         DoubleProperty boundRadius = new SimpleDoubleProperty();
 500         DoubleProperty boundWidth = new SimpleDoubleProperty();
 501 
 502         effect.radiusProperty().bind(boundRadius);
 503         effect.widthProperty().bind(boundWidth);
 504 
 505         boundRadius.set(4);
 506         boundWidth.set(9);
 507 
 508         assertEquals(9, effect.getHeight(), 1e-100);
 509         pulse();
 510         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 511         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 512         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 513 
 514         // set radius once again to be sure that the order of calls is not
 515         // important
 516         boundRadius.set(7);
 517         assertEquals(21, effect.getHeight(), 1e-100);
 518         pulse();
 519         assertEquals(21, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 520     }
 521 
 522     @Test
 523     public void testRadiusHeightBound() throws Exception {
 524         DoubleProperty boundRadius = new SimpleDoubleProperty();
 525         DoubleProperty boundHeight = new SimpleDoubleProperty();
 526 
 527         effect.radiusProperty().bind(boundRadius);
 528         effect.heightProperty().bind(boundHeight);
 529 
 530         boundRadius.set(4);
 531         boundHeight.set(9);
 532 
 533         assertEquals(9, effect.getWidth(), 1e-100);
 534         pulse();
 535         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 536         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 537         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 538 
 539         boundRadius.set(7);
 540         assertEquals(21, effect.getWidth(), 1e-100);
 541         pulse();
 542         assertEquals(21, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 543     }
 544 
 545     @Test
 546     public void testWidthHeightBound() throws Exception {
 547         DoubleProperty boundWidth = new SimpleDoubleProperty();
 548         DoubleProperty boundHeight = new SimpleDoubleProperty();
 549 
 550         effect.widthProperty().bind(boundWidth);
 551         effect.heightProperty().bind(boundHeight);
 552 
 553         boundHeight.set(9);
 554         boundWidth.set(9);
 555 
 556         assertEquals(4, effect.getRadius(), 1e-100);
 557         pulse();
 558         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 559         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 560         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 561 
 562         boundHeight.set(21);
 563         assertEquals(7, effect.getRadius(), 1e-100);
 564         pulse();
 565         assertEquals(7, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 566     }
 567 
 568     // all radius, width and height are bound, radius is ignored in this case
 569     // just test that it doesn't end in infinite loop
 570     @Test
 571     public void testWidthHeightRadiusBound() {
 572         DoubleProperty boundWidth = new SimpleDoubleProperty();
 573         DoubleProperty boundHeight = new SimpleDoubleProperty();
 574         DoubleProperty boundRadius = new SimpleDoubleProperty();
 575 
 576         effect.widthProperty().bind(boundWidth);
 577         effect.heightProperty().bind(boundHeight);
 578         effect.radiusProperty().bind(boundRadius);
 579 
 580         boundHeight.set(9);
 581         boundWidth.set(9);
 582         boundRadius.set(5);
 583 
 584         pulse();
 585         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianHeight(), 1e-100);
 586         assertEquals(9, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianWidth(), 1e-100);
 587         assertEquals(4, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 588     }
 589     
 590     @Test
 591     public void testCreateWithParams() {
 592         effect = new DropShadow(4, Color.RED);
 593         setupTest(effect);
 594         assertEquals(4, effect.getRadius(), 1e-100);
 595         assertEquals(Color.RED, effect.getColor());
 596         // test that width and height changed appropriately
 597         assertEquals(9, effect.getHeight(), 1e-100);
 598         assertEquals(9, effect.getWidth(), 1e-100);
 599         pulse();
 600         assertEquals(4f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 601         Color color = Color.RED;
 602         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 603                 (float) color.getBlue(), (float) color.getOpacity());
 604         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 605         assertColor4fEquals(red, actual);
 606     }
 607 
 608     @Test
 609     public void testCreateWithParams4() {
 610         effect = new DropShadow(4, 1, 2, Color.RED);
 611         setupTest(effect);
 612         assertEquals(1, effect.getOffsetX(), 1e-100);
 613         assertEquals(2, effect.getOffsetY(), 1e-100);
 614         assertEquals(4, effect.getRadius(), 1e-100);
 615         assertEquals(Color.RED, effect.getColor());
 616         // test that width and height changed appropriately
 617         assertEquals(9, effect.getHeight(), 1e-100);
 618         assertEquals(9, effect.getWidth(), 1e-100);
 619         pulse();
 620         assertEquals(4f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 621         assertEquals(1f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetX(), 1e-100);
 622         assertEquals(2f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetY(), 1e-100);
 623         Color color = Color.RED;
 624         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 625                 (float) color.getBlue(), (float) color.getOpacity());
 626         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 627         assertColor4fEquals(red, actual);
 628     }
 629     
 630     @Test
 631     public void testCreateWithParams6() {
 632         effect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.5, 1, 2);
 633         setupTest(effect);
 634         assertEquals(1, effect.getOffsetX(), 1e-100);
 635         assertEquals(2, effect.getOffsetY(), 1e-100);
 636         assertEquals(4, effect.getRadius(), 1e-100);
 637         assertEquals(0.5, effect.getSpread(), 1e-100);
 638         assertEquals(Color.RED, effect.getColor());
 639         assertEquals(BlurType.GAUSSIAN, effect.getBlurType());
 640         // test that width and height changed appropriately
 641         assertEquals(9, effect.getHeight(), 1e-100);
 642         assertEquals(9, effect.getWidth(), 1e-100);
 643         pulse();
 644         assertEquals(4f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 645         assertEquals(0.5f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getSpread(), 1e-100);
 646         assertEquals(1f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetX(), 1e-100);
 647         assertEquals(2f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetY(), 1e-100);
 648         assertEquals(ShadowMode.GAUSSIAN, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
 649         Color color = Color.RED;
 650         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 651                 (float) color.getBlue(), (float) color.getOpacity());
 652         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 653         assertColor4fEquals(red, actual);
 654     }
 655 
 656     @Test
 657     public void testCreateWithDefaultParams() {
 658         effect = new DropShadow(10, Color.BLACK);
 659         setupTest(effect);
 660         assertEquals(10, effect.getRadius(), 1e-100);
 661         assertEquals(Color.BLACK, effect.getColor());
 662         // test that width and height changed appropriately
 663         assertEquals(21, effect.getHeight(), 1e-100);
 664         assertEquals(21, effect.getWidth(), 1e-100);
 665         pulse();
 666         assertEquals(10f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 667         Color color = Color.BLACK;
 668         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 669                 (float) color.getBlue(), (float) color.getOpacity());
 670         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 671         assertColor4fEquals(red, actual);
 672     }
 673 
 674     @Test
 675     public void testCreateWithDefaultParams4() {
 676         effect = new DropShadow(10, 0, 0, Color.BLACK);
 677         setupTest(effect);
 678         assertEquals(0, effect.getOffsetX(), 1e-100);
 679         assertEquals(0, effect.getOffsetY(), 1e-100);
 680         assertEquals(10, effect.getRadius(), 1e-100);
 681         assertEquals(Color.BLACK, effect.getColor());
 682         // test that width and height changed appropriately
 683         assertEquals(21, effect.getHeight(), 1e-100);
 684         assertEquals(21, effect.getWidth(), 1e-100);
 685         pulse();
 686         assertEquals(10f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 687         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetX(), 1e-100);
 688         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetY(), 1e-100);
 689         Color color = Color.BLACK;
 690         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 691                 (float) color.getBlue(), (float) color.getOpacity());
 692         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 693         assertColor4fEquals(red, actual);
 694     }
 695 
 696     @Test
 697     public void testCreateWithDefaultParams6() {
 698         effect = new DropShadow(BlurType.THREE_PASS_BOX, Color.BLACK, 10, 0, 0, 0);
 699         setupTest(effect);
 700         assertEquals(0, effect.getOffsetX(), 1e-100);
 701         assertEquals(0, effect.getOffsetY(), 1e-100);
 702         assertEquals(10, effect.getRadius(), 1e-100);
 703         assertEquals(0, effect.getSpread(), 1e-100);
 704         assertEquals(Color.BLACK, effect.getColor());
 705         assertEquals(BlurType.THREE_PASS_BOX, effect.getBlurType());
 706         // test that width and height changed appropriately
 707         assertEquals(21, effect.getHeight(), 1e-100);
 708         assertEquals(21, effect.getWidth(), 1e-100);
 709         pulse();
 710         assertEquals(10f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getGaussianRadius(), 1e-100);
 711         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getSpread(), 1e-100);
 712         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetX(), 1e-100);
 713         assertEquals(0f, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getOffsetY(), 1e-100);
 714         assertEquals(ShadowMode.THREE_PASS_BOX, ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getShadowMode());
 715         Color color = Color.BLACK;
 716         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
 717                 (float) color.getBlue(), (float) color.getOpacity());
 718         Color4f actual = ((com.sun.scenario.effect.DropShadow) effect.impl_getImpl()).getColor();
 719         assertColor4fEquals(red, actual);
 720     }
 721 }