modules/graphics/src/test/java/test/javafx/scene/effect/DistantLightTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:

@@ -21,21 +21,23 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package javafx.scene.effect;
+package test.javafx.scene.effect;
 
+import test.javafx.scene.effect.LightTestBase;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import javafx.scene.paint.Color;
 
 import org.junit.Before;
 import org.junit.Test;
 
 import com.sun.scenario.effect.Color4f;
+import javafx.scene.effect.Light;
+import javafx.scene.effect.LightShim;
 
 public class DistantLightTest extends LightTestBase {
     private Light.Distant effect;
 
     @Before

@@ -48,47 +50,52 @@
     public void testSetAzimuth() {
         // try setting correct value
         effect.setAzimuth(1.0f);
         assertEquals(1.0f, effect.getAzimuth(), 1e-100);
         pulse();
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getAzimuth(), 1e-100);
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getAzimuth(), 1e-100);
     }
 
     @Test
     public void testDefaultAzimuth() {
         // default value should be 45
         assertEquals(45f, effect.getAzimuth(), 1e-100);
         assertEquals(45f, effect.azimuthProperty().get(), 1e-100);
         pulse();
-        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getAzimuth(), 1e-100);
+        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getAzimuth(), 1e-100);
     }
 
     @Test
     public void testSetElevation() {
         // try setting correct value
         effect.setElevation(1.0f);
         assertEquals(1.0f, effect.getElevation(), 1e-100);
         pulse();
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getElevation(), 1e-100);
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getElevation(), 1e-100);
     }
 
     @Test
     public void testDefaultElevation() {
         // default value should be 45
         assertEquals(45f, effect.getElevation(), 1e-100);
         assertEquals(45f, effect.elevationProperty().get(), 1e-100);
         pulse();
-        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getElevation(), 1e-100);
+        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getElevation(), 1e-100);
     }
 
     @Test
     public void testSetColor() {
         // try setting correct value
         effect.setColor(Color.BLUE);
         assertEquals(Color.BLUE, effect.getColor());
         pulse();
-        Color4f c = ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getColor();        
+        Color4f c = ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getColor();        
         assertEquals(0f, c.getRed(), 1e-5);
         assertEquals(0f, c.getGreen(), 1e-5);
         assertEquals(1f, c.getBlue(), 1e-5);
         assertEquals(1f, c.getAlpha(), 1e-5); 
     }

@@ -97,11 +104,12 @@
     public void testDefaultColor() {
         // default value should be RED
         assertEquals(Color.WHITE, effect.getColor());
         assertEquals(Color.WHITE, effect.colorProperty().get());
         pulse();
-        Color4f c = ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getColor();        
+        Color4f c = ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getColor();        
         assertEquals(1f, c.getRed(), 1e-5);
         assertEquals(1f, c.getGreen(), 1e-5);
         assertEquals(1f, c.getBlue(), 1e-5);
         assertEquals(1f, c.getAlpha(), 1e-5);      
     }

@@ -111,32 +119,33 @@
         // null value should default to WHITE in render tree
         effect.setColor(null);
         assertNull(effect.getColor());
         assertNull(effect.colorProperty().get());
         pulse();
-        Color4f c = ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getColor();
+        Color4f c = ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getColor();
         assertEquals(1f, c.getRed(), 1e-5);
         assertEquals(1f, c.getGreen(), 1e-5);
         assertEquals(1f, c.getBlue(), 1e-5);
         assertEquals(1f, c.getAlpha(), 1e-5);
     }
 
     @Test
     public void testAzimuthSynced() throws Exception {
         checkDoublePropertySynced(
-                effect, effect.impl_getImpl(),
+                effect, LightShim.impl_getImpl(effect),
                 "javafx.scene.effect.Light$Distant", "azimuth",
                 "com.sun.scenario.effect.light.DistantLight", "azimuth", 0.3);
     }
 
     @Test
     public void testColorSynced() throws Exception {
         Color color = Color.RED;
         Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
                 (float) color.getBlue(), (float) color.getOpacity());
         Color4f result = (Color4f) getObjectPropertySynced(
-                effect, effect.impl_getImpl(),
+                effect, LightShim.impl_getImpl(effect),
                 "javafx.scene.effect.Light$Distant", "color",
                 "com.sun.scenario.effect.light.DistantLight", "color",
                 Color.RED);
         assertColor4fEquals(red, result);
     }

@@ -147,13 +156,16 @@
         setupTest(effect);
         assertEquals(1, effect.getAzimuth(), 1e-100);
         assertEquals(2, effect.getElevation(), 1e-100);
         assertEquals(Color.BLUE, effect.getColor());
         pulse();
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getAzimuth(), 1e-100);
-        assertEquals(2.0f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getElevation(), 1e-100);
-        Color4f c = ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getColor();
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getAzimuth(), 1e-100);
+        assertEquals(2.0f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getElevation(), 1e-100);
+        Color4f c = ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getColor();
         assertEquals(0f, c.getRed(), 1e-5);
         assertEquals(0f, c.getGreen(), 1e-5);
         assertEquals(1f, c.getBlue(), 1e-5);
         assertEquals(1f, c.getAlpha(), 1e-5);
     }

@@ -164,13 +176,16 @@
         setupTest(effect);
         assertEquals(45, effect.getAzimuth(), 1e-100);
         assertEquals(45, effect.getElevation(), 1e-100);
         assertEquals(Color.RED, effect.getColor());
         pulse();
-        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getAzimuth(), 1e-100);
-        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getElevation(), 1e-100);
-        Color4f c = ((com.sun.scenario.effect.light.DistantLight) effect.impl_getImpl()).getColor();
+        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getAzimuth(), 1e-100);
+        assertEquals(45f, ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getElevation(), 1e-100);
+        Color4f c = ((com.sun.scenario.effect.light.DistantLight) 
+                LightShim.impl_getImpl(effect)).getColor();
         assertEquals(1f, c.getRed(), 1e-5);
         assertEquals(0f, c.getGreen(), 1e-5);
         assertEquals(0f, c.getBlue(), 1e-5);
         assertEquals(1f, c.getAlpha(), 1e-5);
     }