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

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

@@ -21,21 +21,24 @@
  * 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 javafx.scene.paint.Color;
 
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
 import com.sun.scenario.effect.Color4f;
+import javafx.scene.effect.Light;
+import javafx.scene.effect.LightShim;
 
 public class SpotLightTest extends LightTestBase {
 
     @Rule
     public ExpectedException thrown = ExpectedException.none();

@@ -51,137 +54,147 @@
     public void testSetPointsAtX() {
         // try setting correct value
         effect.setPointsAtX(1.0f);
         assertEquals(1.0f, effect.getPointsAtX(), 1e-100);
         pulse();
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getPointsAtX(), 1e-100);
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getPointsAtX(), 1e-100);
     }
 
     @Test
     public void testDefaultPointsAtX() {
         // default value should be 0
         assertEquals(0f, effect.getPointsAtX(), 1e-100);
         assertEquals(0f, effect.pointsAtXProperty().get(), 1e-100);
         pulse();
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getPointsAtX(), 1e-100);
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getPointsAtX(), 1e-100);
     }
 
     @Test
     public void testSetPointsAtY() {
         // trPointsAtY setting correct value
         effect.setPointsAtY(1.0f);
         assertEquals(1.0f, effect.getPointsAtY(), 1e-100);
         pulse();
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getPointsAtY(), 1e-100);
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getPointsAtY(), 1e-100);
     }
 
     @Test
     public void testDefaultPointsAtY() {
         // default value should be 0
         assertEquals(0f, effect.getPointsAtY(), 1e-100);
         assertEquals(0f, effect.pointsAtYProperty().get(), 1e-100);
         pulse();
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getPointsAtY(), 1e-100);
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getPointsAtY(), 1e-100);
     }
 
     @Test
     public void testSetPointsAtZ() {
         // try setting correct value
         effect.setPointsAtZ(1.0f);
         assertEquals(1.0f, effect.getPointsAtZ(), 1e-100);
         pulse();
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getPointsAtZ(), 1e-100);
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getPointsAtZ(), 1e-100);
     }
 
     @Test
     public void testDefaultPointsAtZ() {
         // default value should be 0
         assertEquals(0f, effect.getPointsAtZ(), 1e-100);
         assertEquals(0f, effect.pointsAtZProperty().get(), 1e-100);
         pulse();
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getPointsAtZ(), 1e-100);
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getPointsAtZ(), 1e-100);
     }
     
     @Test
     public void testSetSpecularExponent() {
         // try setting correct value
         effect.setSpecularExponent(1.1f);
         assertEquals(1.1f, effect.getSpecularExponent(), 1e-100);
         pulse();
-        assertEquals(1.1f, ((com.sun.scenario.effect.light.SpotLight)effect.impl_getImpl()).getSpecularExponent(), 1e-100);
+        assertEquals(1.1f, ((com.sun.scenario.effect.light.SpotLight)
+                LightShim.impl_getImpl(effect)).getSpecularExponent(), 1e-100);
     }
     
     @Test
     public void testDefaultSpecularExponent() {
         // default value should be 1
         assertEquals(1f, effect.getSpecularExponent(), 1e-100);
         assertEquals(1f, effect.specularExponentProperty().get(), 1e-100);
         pulse();
-        assertEquals(1f, ((com.sun.scenario.effect.light.SpotLight)effect.impl_getImpl()).getSpecularExponent(), 1e-100);
+        assertEquals(1f, ((com.sun.scenario.effect.light.SpotLight)
+                LightShim.impl_getImpl(effect)).getSpecularExponent(), 1e-100);
     }
     
     @Test
     public void testMinSpecularExponent() {
         // 0 should be ok
         effect.setSpecularExponent(0);
         // try setting value smaller than minimal
         effect.setSpecularExponent(-0.1f);
         assertEquals(-0.1f, effect.getSpecularExponent(), 1e-100);
         pulse();
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight)effect.impl_getImpl()).getSpecularExponent(), 1e-100);
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight)
+                LightShim.impl_getImpl(effect)).getSpecularExponent(), 1e-100);
     }
 
     @Test
     public void testMaxSpecularExponent() {
         // 4 should be ok
         effect.setSpecularExponent(4);
         // try setting value greater than maximal
         effect.setSpecularExponent(4.1f);
         assertEquals(4.1f, effect.getSpecularExponent(), 1e-100);
         pulse();
-        assertEquals(4f, ((com.sun.scenario.effect.light.SpotLight)effect.impl_getImpl()).getSpecularExponent(), 1e-100);
+        assertEquals(4f, ((com.sun.scenario.effect.light.SpotLight)
+                LightShim.impl_getImpl(effect)).getSpecularExponent(), 1e-100);
     }
 
     @Test
     public void testPointsAtXSynced() throws Exception {
         checkDoublePropertySynced(
-                effect, effect.impl_getImpl(),
+                effect, LightShim.impl_getImpl(effect),
                 "javafx.scene.effect.Light$Spot", "pointsAtX",
                 "com.sun.scenario.effect.light.SpotLight", "pointsAtX", 0.3);
     }
 
     @Test
     public void testPointsAtYSynced() throws Exception {
         checkDoublePropertySynced(
-                effect, effect.impl_getImpl(),
+                effect, LightShim.impl_getImpl(effect),
                 "javafx.scene.effect.Light$Spot", "pointsAtY",
                 "com.sun.scenario.effect.light.SpotLight", "pointsAtY", 0.3);
     }
 
     @Test
     public void testSpecularExponentSynced() throws Exception {
         checkDoublePropertySynced(
-                effect, effect.impl_getImpl(),
+                effect, LightShim.impl_getImpl(effect),
                 "javafx.scene.effect.Light$Spot", "specularExponent",
                 "com.sun.scenario.effect.light.SpotLight", "specularExponent", 0.3);
     }
 
     @Test
     public void testPointsAtZSynced() throws Exception {
         checkDoublePropertySynced(
-                effect, effect.impl_getImpl(),
+                effect, LightShim.impl_getImpl(effect),
                 "javafx.scene.effect.Light$Spot", "pointsAtZ",
                 "com.sun.scenario.effect.light.SpotLight", "pointsAtZ", 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$Spot", "color",
                 "com.sun.scenario.effect.light.SpotLight", "color",
                 Color.RED);
         assertColor4fEquals(red, result);
     }

@@ -194,15 +207,20 @@
         assertEquals(2, effect.getY(), 1e-100);
         assertEquals(3, effect.getZ(), 1e-100);
         assertEquals(4, effect.getSpecularExponent(), 1e-100);
         assertEquals(Color.RED, effect.getColor());
         pulse();        
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getX(), 1e-100);
-        assertEquals(2.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getY(), 1e-100);
-        assertEquals(3.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getZ(), 1e-100);
-        assertEquals(4.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getSpecularExponent(), 1e-100);
-        Color4f c = ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getColor();
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getX(), 1e-100);
+        assertEquals(2.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getY(), 1e-100);
+        assertEquals(3.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getZ(), 1e-100);
+        assertEquals(4.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getSpecularExponent(), 1e-100);
+        Color4f c = ((com.sun.scenario.effect.light.SpotLight) 
+                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);
     }

@@ -215,15 +233,20 @@
         assertEquals(0, effect.getY(), 1e-100);
         assertEquals(0, effect.getZ(), 1e-100);
         assertEquals(1, effect.getSpecularExponent(), 1e-100);
         assertEquals(Color.WHITE, effect.getColor());
         pulse();        
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getX(), 1e-100);
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getY(), 1e-100);
-        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getZ(), 1e-100);
-        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getSpecularExponent(), 1e-100);
-        Color4f c = ((com.sun.scenario.effect.light.SpotLight) effect.impl_getImpl()).getColor();
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getX(), 1e-100);
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getY(), 1e-100);
+        assertEquals(0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getZ(), 1e-100);
+        assertEquals(1.0f, ((com.sun.scenario.effect.light.SpotLight) 
+                LightShim.impl_getImpl(effect)).getSpecularExponent(), 1e-100);
+        Color4f c = ((com.sun.scenario.effect.light.SpotLight) 
+                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);
     }