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.input;
27
28 import com.sun.javafx.pgstub.StubScene;
29 import javafx.event.Event;
30 import javafx.scene.Group;
31 import static org.junit.Assert.assertEquals;
32 import static org.junit.Assert.assertFalse;
33 import static org.junit.Assert.assertNotNull;
34 import static org.junit.Assert.assertSame;
35 import static org.junit.Assert.assertTrue;
36 import javafx.scene.Scene;
37 import javafx.scene.shape.Rectangle;
38 import javafx.event.EventHandler;
39 import javafx.geometry.Point3D;
40 import javafx.stage.Stage;
41
42 import org.junit.Test;
43
44 public class ContextMenuEventTest {
45
46 @Test public void testShortConstructor() {
47 Rectangle node = new Rectangle(10, 10);
48 node.setTranslateX(3);
49 node.setTranslateY(2);
50 node.setTranslateZ(50);
51
52 PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
53 ContextMenuEvent e = new ContextMenuEvent(
54 ContextMenuEvent.CONTEXT_MENU_REQUESTED, 10, 20, 30, 40,
55 false, pickRes);
56 assertSame(ContextMenuEvent.CONTEXT_MENU_REQUESTED, e.getEventType());
57 assertEquals(18, e.getX(), 10e-20);
58 assertEquals(27, e.getY(), 10e-20);
59 assertEquals(150, e.getZ(), 10e-20);
60 assertEquals(10, e.getSceneX(), 10e-20);
61 assertEquals(20, e.getSceneY(), 10e-20);
62 assertEquals(30, e.getScreenX(), 10e-20);
63 assertEquals(40, e.getScreenY(), 10e-20);
64 assertFalse(e.isKeyboardTrigger());
65 assertFalse(e.isConsumed());
|
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.input;
27
28 import com.sun.javafx.FXUnit;
29 import com.sun.javafx.pgstub.StubScene;
30 import javafx.event.Event;
31 import javafx.scene.Group;
32 import static org.junit.Assert.assertEquals;
33 import static org.junit.Assert.assertFalse;
34 import static org.junit.Assert.assertNotNull;
35 import static org.junit.Assert.assertSame;
36 import static org.junit.Assert.assertTrue;
37 import javafx.scene.Scene;
38 import javafx.scene.shape.Rectangle;
39 import javafx.event.EventHandler;
40 import javafx.geometry.Point3D;
41 import javafx.stage.Stage;
42
43 import org.junit.Rule;
44 import org.junit.Test;
45
46 public class ContextMenuEventTest {
47
48 @Rule
49 public FXUnit fx = new FXUnit();
50
51 @Test public void testShortConstructor() {
52 Rectangle node = new Rectangle(10, 10);
53 node.setTranslateX(3);
54 node.setTranslateY(2);
55 node.setTranslateZ(50);
56
57 PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
58 ContextMenuEvent e = new ContextMenuEvent(
59 ContextMenuEvent.CONTEXT_MENU_REQUESTED, 10, 20, 30, 40,
60 false, pickRes);
61 assertSame(ContextMenuEvent.CONTEXT_MENU_REQUESTED, e.getEventType());
62 assertEquals(18, e.getX(), 10e-20);
63 assertEquals(27, e.getY(), 10e-20);
64 assertEquals(150, e.getZ(), 10e-20);
65 assertEquals(10, e.getSceneX(), 10e-20);
66 assertEquals(20, e.getSceneY(), 10e-20);
67 assertEquals(30, e.getScreenX(), 10e-20);
68 assertEquals(40, e.getScreenY(), 10e-20);
69 assertFalse(e.isKeyboardTrigger());
70 assertFalse(e.isConsumed());
|