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 javafx.scene.paint.Color;
30
31 import org.junit.Before;
32 import org.junit.Test;
33
34 import com.sun.scenario.effect.Color4f;
35
36 public class PointLightTest extends LightTestBase {
37 private Light.Point effect;
38
39 @Before
40 public void setUp() {
41 effect = new Light.Point();
42 setupTest(effect);
43 }
44
45 @Test
46 public void testSetX() {
47 // try setting correct value
48 effect.setX(1.0f);
49 assertEquals(1.0f, effect.getX(), 1e-100);
50 pulse();
51 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getX(), 1e-100);
52 }
53
54 @Test
55 public void testDefaultX() {
56 // default value should be 0
57 assertEquals(0f, effect.getX(), 1e-100);
58 assertEquals(0f, effect.xProperty().get(), 1e-100);
59 pulse();
60 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getX(), 1e-100);
61 }
62
63 @Test
64 public void testSetY() {
65 // try setting correct value
66 effect.setY(1.0f);
67 assertEquals(1.0f, effect.getY(), 1e-100);
68 pulse();
69 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getY(), 1e-100);
70 }
71
72 @Test
73 public void testDefaultY() {
74 // default value should be 0
75 assertEquals(0f, effect.getY(), 1e-100);
76 assertEquals(0f, effect.yProperty().get(), 1e-100);
77 pulse();
78 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getY(), 1e-100);
79 }
80
81 @Test
82 public void testSetZ() {
83 // try setting correct value
84 effect.setZ(1.0f);
85 assertEquals(1.0f, effect.getZ(), 1e-100);
86 pulse();
87 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getZ(), 1e-100);
88 }
89
90 @Test
91 public void testDefaultZ() {
92 // default value should be 0
93 assertEquals(0f, effect.getZ(), 1e-100);
94 assertEquals(0f, effect.zProperty().get(), 1e-100);
95 pulse();
96 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getZ(), 1e-100);
97 }
98
99 @Test
100 public void testXSynced() throws Exception {
101 checkDoublePropertySynced(
102 effect, effect.impl_getImpl(),
103 "javafx.scene.effect.Light$Point", "x",
104 "com.sun.scenario.effect.light.PointLight", "x", 0.3);
105 }
106
107 @Test
108 public void testYSynced() throws Exception {
109 checkDoublePropertySynced(
110 effect, effect.impl_getImpl(),
111 "javafx.scene.effect.Light$Point", "y",
112 "com.sun.scenario.effect.light.PointLight", "y", 0.3);
113 }
114
115 @Test
116 public void testZSynced() throws Exception {
117 checkDoublePropertySynced(
118 effect, effect.impl_getImpl(),
119 "javafx.scene.effect.Light$Point", "z",
120 "com.sun.scenario.effect.light.PointLight", "z", 0.3);
121 }
122
123 @Test
124 public void testColorSynced() throws Exception {
125 Color color = Color.RED;
126 Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
127 (float) color.getBlue(), (float) color.getOpacity());
128 Color4f result = (Color4f) getObjectPropertySynced(
129 effect, effect.impl_getImpl(),
130 "javafx.scene.effect.Light$Point", "color",
131 "com.sun.scenario.effect.light.PointLight", "color",
132 Color.RED);
133 assertColor4fEquals(red, result);
134 }
135
136 @Test
137 public void testCreateWithParams() {
138 effect = new Light.Point(1, 2, 3, Color.RED);
139 setupTest(effect);
140 assertEquals(1, effect.getX(), 1e-100);
141 assertEquals(2, effect.getY(), 1e-100);
142 assertEquals(3, effect.getZ(), 1e-100);
143 assertEquals(Color.RED, effect.getColor());
144 pulse();
145 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getX(), 1e-100);
146 assertEquals(2.0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getY(), 1e-100);
147 assertEquals(3.0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getZ(), 1e-100);
148 Color4f c = ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getColor();
149 assertEquals(1f, c.getRed(), 1e-5);
150 assertEquals(0f, c.getGreen(), 1e-5);
151 assertEquals(0f, c.getBlue(), 1e-5);
152 assertEquals(1f, c.getAlpha(), 1e-5);
153 }
154
155 @Test
156 public void testCreateWithDefaultParams() {
157 effect = new Light.Point(0, 0, 0, Color.WHITE);
158 setupTest(effect);
159 assertEquals(0, effect.getX(), 1e-100);
160 assertEquals(0, effect.getY(), 1e-100);
161 assertEquals(0, effect.getZ(), 1e-100);
162 assertEquals(Color.WHITE, effect.getColor());
163 pulse();
164 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getX(), 1e-100);
165 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getY(), 1e-100);
166 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getZ(), 1e-100);
167 Color4f c = ((com.sun.scenario.effect.light.PointLight) effect.impl_getImpl()).getColor();
168 assertEquals(1f, c.getRed(), 1e-5);
169 assertEquals(1f, c.getGreen(), 1e-5);
170 assertEquals(1f, c.getBlue(), 1e-5);
171 assertEquals(1f, c.getAlpha(), 1e-5);
172 }
173 }
|
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 test.javafx.scene.effect.LightTestBase;
29 import static org.junit.Assert.assertEquals;
30 import javafx.scene.paint.Color;
31
32 import org.junit.Before;
33 import org.junit.Test;
34
35 import com.sun.scenario.effect.Color4f;
36 import javafx.scene.effect.Light;
37 import javafx.scene.effect.LightShim;
38
39 public class PointLightTest extends LightTestBase {
40 private Light.Point effect;
41
42 @Before
43 public void setUp() {
44 effect = new Light.Point();
45 setupTest(effect);
46 }
47
48 @Test
49 public void testSetX() {
50 // try setting correct value
51 effect.setX(1.0f);
52 assertEquals(1.0f, effect.getX(), 1e-100);
53 pulse();
54 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight)
55 LightShim.impl_getImpl(effect)).getX(), 1e-100);
56 }
57
58 @Test
59 public void testDefaultX() {
60 // default value should be 0
61 assertEquals(0f, effect.getX(), 1e-100);
62 assertEquals(0f, effect.xProperty().get(), 1e-100);
63 pulse();
64 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight)
65 LightShim.impl_getImpl(effect)).getX(), 1e-100);
66 }
67
68 @Test
69 public void testSetY() {
70 // try setting correct value
71 effect.setY(1.0f);
72 assertEquals(1.0f, effect.getY(), 1e-100);
73 pulse();
74 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight)
75 LightShim.impl_getImpl(effect)).getY(), 1e-100);
76 }
77
78 @Test
79 public void testDefaultY() {
80 // default value should be 0
81 assertEquals(0f, effect.getY(), 1e-100);
82 assertEquals(0f, effect.yProperty().get(), 1e-100);
83 pulse();
84 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight)
85 LightShim.impl_getImpl(effect)).getY(), 1e-100);
86 }
87
88 @Test
89 public void testSetZ() {
90 // try setting correct value
91 effect.setZ(1.0f);
92 assertEquals(1.0f, effect.getZ(), 1e-100);
93 pulse();
94 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight)
95 LightShim.impl_getImpl(effect)).getZ(), 1e-100);
96 }
97
98 @Test
99 public void testDefaultZ() {
100 // default value should be 0
101 assertEquals(0f, effect.getZ(), 1e-100);
102 assertEquals(0f, effect.zProperty().get(), 1e-100);
103 pulse();
104 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight)
105 LightShim.impl_getImpl(effect)).getZ(), 1e-100);
106 }
107
108 @Test
109 public void testXSynced() throws Exception {
110 checkDoublePropertySynced(
111 effect, LightShim.impl_getImpl(effect),
112 "javafx.scene.effect.Light$Point", "x",
113 "com.sun.scenario.effect.light.PointLight", "x", 0.3);
114 }
115
116 @Test
117 public void testYSynced() throws Exception {
118 checkDoublePropertySynced(
119 effect, LightShim.impl_getImpl(effect),
120 "javafx.scene.effect.Light$Point", "y",
121 "com.sun.scenario.effect.light.PointLight", "y", 0.3);
122 }
123
124 @Test
125 public void testZSynced() throws Exception {
126 checkDoublePropertySynced(
127 effect, LightShim.impl_getImpl(effect),
128 "javafx.scene.effect.Light$Point", "z",
129 "com.sun.scenario.effect.light.PointLight", "z", 0.3);
130 }
131
132 @Test
133 public void testColorSynced() throws Exception {
134 Color color = Color.RED;
135 Color4f red = new Color4f((float) color.getRed(), (float) color.getGreen(),
136 (float) color.getBlue(), (float) color.getOpacity());
137 Color4f result = (Color4f) getObjectPropertySynced(
138 effect, LightShim.impl_getImpl(effect),
139 "javafx.scene.effect.Light$Point", "color",
140 "com.sun.scenario.effect.light.PointLight", "color",
141 Color.RED);
142 assertColor4fEquals(red, result);
143 }
144
145 @Test
146 public void testCreateWithParams() {
147 effect = new Light.Point(1, 2, 3, Color.RED);
148 setupTest(effect);
149 assertEquals(1, effect.getX(), 1e-100);
150 assertEquals(2, effect.getY(), 1e-100);
151 assertEquals(3, effect.getZ(), 1e-100);
152 assertEquals(Color.RED, effect.getColor());
153 pulse();
154 assertEquals(1.0f, ((com.sun.scenario.effect.light.PointLight)
155 LightShim.impl_getImpl(effect)).getX(), 1e-100);
156 assertEquals(2.0f, ((com.sun.scenario.effect.light.PointLight)
157 LightShim.impl_getImpl(effect)).getY(), 1e-100);
158 assertEquals(3.0f, ((com.sun.scenario.effect.light.PointLight)
159 LightShim.impl_getImpl(effect)).getZ(), 1e-100);
160 Color4f c = ((com.sun.scenario.effect.light.PointLight)
161 LightShim.impl_getImpl(effect)).getColor();
162 assertEquals(1f, c.getRed(), 1e-5);
163 assertEquals(0f, c.getGreen(), 1e-5);
164 assertEquals(0f, c.getBlue(), 1e-5);
165 assertEquals(1f, c.getAlpha(), 1e-5);
166 }
167
168 @Test
169 public void testCreateWithDefaultParams() {
170 effect = new Light.Point(0, 0, 0, Color.WHITE);
171 setupTest(effect);
172 assertEquals(0, effect.getX(), 1e-100);
173 assertEquals(0, effect.getY(), 1e-100);
174 assertEquals(0, effect.getZ(), 1e-100);
175 assertEquals(Color.WHITE, effect.getColor());
176 pulse();
177 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight)
178 LightShim.impl_getImpl(effect)).getX(), 1e-100);
179 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight)
180 LightShim.impl_getImpl(effect)).getY(), 1e-100);
181 assertEquals(0f, ((com.sun.scenario.effect.light.PointLight)
182 LightShim.impl_getImpl(effect)).getZ(), 1e-100);
183 Color4f c = ((com.sun.scenario.effect.light.PointLight)
184 LightShim.impl_getImpl(effect)).getColor();
185 assertEquals(1f, c.getRed(), 1e-5);
186 assertEquals(1f, c.getGreen(), 1e-5);
187 assertEquals(1f, c.getBlue(), 1e-5);
188 assertEquals(1f, c.getAlpha(), 1e-5);
189 }
190 }
|