changeset 1095:0cf2d3897858

Improved event and scene tests.
author Pavel Safrata
date Fri, 18 May 2012 18:31:16 +0200
parents 6f6711e369dd
children 8277e5289ea3
files javafx-ui-common/src/javafx/scene/Scene.java javafx-ui-common/test/unit/javafx/scene/Scene_properties_Test.java javafx-ui-common/test/unit/javafx/scene/Scenegraph_eventHandlers_Test.java javafx-ui-common/test/unit/javafx/scene/input/RotateEventTest.java javafx-ui-common/test/unit/javafx/scene/input/ScrollEventTest.java javafx-ui-common/test/unit/javafx/scene/input/SwipeEventTest.java javafx-ui-common/test/unit/javafx/scene/input/TouchEventTest.java javafx-ui-common/test/unit/javafx/scene/input/ZoomEventTest.java
diffstat 8 files changed, 580 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/Scene.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/src/javafx/scene/Scene.java	Fri May 18 18:31:16 2012 +0200
@@ -2373,6 +2373,17 @@
                 boolean _shiftDown, boolean _controlDown,
                 boolean _altDown, boolean _metaDown, boolean _direct) {
 
+            if (Double.isNaN(x) || Double.isNaN(y) ||
+                    Double.isNaN(screenX) || Double.isNaN(screenY)) {
+                if (cursorScenePos == null || cursorScreenPos == null) {
+                    return;
+                }
+                x = cursorScenePos.getX();
+                y = cursorScenePos.getY();
+                screenX = cursorScreenPos.getX();
+                screenY = cursorScreenPos.getY();
+            }
+
             Scene.this.processGestureEvent(SwipeEvent.impl_swipeEvent(
                     eventType, touchCount, x, y, screenX, screenY,
                     _shiftDown, _controlDown, _altDown, _metaDown, _direct), 
--- a/javafx-ui-common/test/unit/javafx/scene/Scene_properties_Test.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/test/unit/javafx/scene/Scene_properties_Test.java	Fri May 18 18:31:16 2012 +0200
@@ -25,6 +25,7 @@
 
 package javafx.scene;
 
+import com.sun.javafx.cursor.CursorFrame;
 import com.sun.javafx.event.EventHandlerManager;
 import java.util.Arrays;
 import java.util.Collection;
@@ -67,11 +68,18 @@
 //            config(testScene, "height", , ),
             config(testScene, "camera", null, new ParallelCamera()),
             config(testScene, "fill", Color.WHITE, Color.BLACK),
+            config(testScene, "fill", null, Color.TRANSPARENT),
             config(testScene, "root", new Group(), new Pane()),
+            config(testScene, "cursor", null, new Cursor("TestCursor") {
+                @Override public CursorFrame impl_getCurrentFrame() {
+                    throw new UnsupportedOperationException("Not supported yet.");
+                }
+            }),
             config(testScene, "cursor", Cursor.DEFAULT, Cursor.CROSSHAIR),
             config(testScene, "eventDispatcher",
                    null,
                    new EventHandlerManager(null)),
+            config(testScene, "camera", null, new PerspectiveCamera()),
             config(testScene, "onMouseClicked", null, testEventHandler),
             config(testScene, "onMouseDragged", null, testEventHandler),
             config(testScene, "onMouseEntered", null, testEventHandler),
@@ -88,6 +96,34 @@
             config(testScene, "onKeyPressed", null, testEventHandler),
             config(testScene, "onKeyReleased", null, testEventHandler),
             config(testScene, "onKeyTyped", null, testEventHandler),
+            config(testScene, "onContextMenuRequested", null, testEventHandler),
+            config(testScene, "onDragDetected", null, testEventHandler),
+            config(testScene, "onDragDone", null, testEventHandler),
+            config(testScene, "onDragDropped", null, testEventHandler),
+            config(testScene, "onDragEntered", null, testEventHandler),
+            config(testScene, "onDragExited", null, testEventHandler),
+            config(testScene, "onDragOver", null, testEventHandler),
+            config(testScene, "onMouseDragEntered", null, testEventHandler),
+            config(testScene, "onMouseDragExited", null, testEventHandler),
+            config(testScene, "onMouseDragOver", null, testEventHandler),
+            config(testScene, "onMouseDragReleased", null, testEventHandler),
+            config(testScene, "onRotate", null, testEventHandler),
+            config(testScene, "onRotationStarted", null, testEventHandler),
+            config(testScene, "onRotationFinished", null, testEventHandler),
+            config(testScene, "onZoom", null, testEventHandler),
+            config(testScene, "onZoomStarted", null, testEventHandler),
+            config(testScene, "onZoomFinished", null, testEventHandler),
+            config(testScene, "onScroll", null, testEventHandler),
+            config(testScene, "onScrollStarted", null, testEventHandler),
+            config(testScene, "onScrollFinished", null, testEventHandler),
+            config(testScene, "onSwipeLeft", null, testEventHandler),
+            config(testScene, "onSwipeRight", null, testEventHandler),
+            config(testScene, "onSwipeUp", null, testEventHandler),
+            config(testScene, "onSwipeDown", null, testEventHandler),
+            config(testScene, "onTouchPressed", null, testEventHandler),
+            config(testScene, "onTouchReleased", null, testEventHandler),
+            config(testScene, "onTouchMoved", null, testEventHandler),
+            config(testScene, "onTouchStationary", null, testEventHandler),
             config(testScene, "onInputMethodTextChanged",
                    null, testEventHandler)
         });
--- a/javafx-ui-common/test/unit/javafx/scene/Scenegraph_eventHandlers_Test.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/test/unit/javafx/scene/Scenegraph_eventHandlers_Test.java	Fri May 18 18:31:16 2012 +0200
@@ -46,6 +46,8 @@
 
 import com.sun.javafx.test.PropertyReference;
 import com.sun.javafx.test.MouseEventGenerator;
+import javafx.scene.input.ContextMenuEvent;
+import javafx.scene.input.SwipeEvent;
 
 @RunWith(Parameterized.class)
 public final class Scenegraph_eventHandlers_Test {
@@ -106,6 +108,26 @@
                 "onMouseDragged",
                 mouseEventGenerator.generateMouseEvent(
                         MouseEvent.MOUSE_DRAGGED, 0, 0)
+            }, {
+                SwipeEvent.SWIPE_LEFT,
+                "onSwipeLeft",
+                createSwipeEvent(SwipeEvent.SWIPE_LEFT)
+            }, {
+                SwipeEvent.SWIPE_RIGHT,
+                "onSwipeRight",
+                createSwipeEvent(SwipeEvent.SWIPE_RIGHT)
+            }, {
+                SwipeEvent.SWIPE_UP,
+                "onSwipeUp",
+                createSwipeEvent(SwipeEvent.SWIPE_UP)
+            }, {
+                SwipeEvent.SWIPE_DOWN,
+                "onSwipeDown",
+                createSwipeEvent(SwipeEvent.SWIPE_DOWN)
+            }, {
+                ContextMenuEvent.CONTEXT_MENU_REQUESTED,
+                "onContextMenuRequested",
+                createContextMenuEvent()
             }
         });
     }
@@ -323,6 +345,19 @@
                                       keyEventType);
     }
 
+    private static Event createContextMenuEvent() {
+        return ContextMenuEvent.impl_contextEvent(10, 10,
+          10, 10, false, ContextMenuEvent.CONTEXT_MENU_REQUESTED);
+    }
+
+    private static Event createSwipeEvent(final EventType<SwipeEvent> type) {
+        return SwipeEvent.impl_swipeEvent(
+                type,
+                1,
+                100, 100, 100, 100,
+                false, false, false, false, true);
+    }
+
     private static void setEventHandler(
             final Object bean,
             final PropertyReference handlerPropertyReference,
--- a/javafx-ui-common/test/unit/javafx/scene/input/RotateEventTest.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/test/unit/javafx/scene/input/RotateEventTest.java	Fri May 18 18:31:16 2012 +0200
@@ -370,6 +370,56 @@
         assertTrue(rotated);
     }
 
+    @Test
+    public void unknownLocalShouldBeFixedByMousePosition() {
+        MouseEventGenerator gen = new MouseEventGenerator();
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+        rect.setOnRotate(new EventHandler<RotateEvent>() {
+            @Override public void handle(RotateEvent event) {
+                assertEquals(150.0, event.getSceneX(), 0.0001);
+                assertEquals(150.0, event.getSceneY(), 0.0001);
+                rotated = true;
+            }
+        });
+
+        rotated = false;
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 250, 250));
+
+        ((StubScene) scene.impl_getPeer()).getListener().rotateEvent(
+                RotateEvent.ROTATE, 2, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                true, false, true, false, true, false);
+
+        assertFalse(rotated);
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 150, 150));
+
+        ((StubScene) scene.impl_getPeer()).getListener().rotateEvent(
+                RotateEvent.ROTATE, 2, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                true, false, true, false, true, false);
+
+        assertTrue(rotated);
+    }
+
+    @Test public void testToString() {
+        RotateEvent e = RotateEvent.impl_rotateEvent(RotateEvent.ROTATE,
+            10, 20,
+            100, 100, 200, 200,
+            false, false, false, false,
+            true, false);
+
+        String s = e.toString();
+
+        assertNotNull(s);
+        assertFalse(s.isEmpty());
+    }
+
     private Scene createScene() {
         final Group root = new Group();
         
--- a/javafx-ui-common/test/unit/javafx/scene/input/ScrollEventTest.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/test/unit/javafx/scene/input/ScrollEventTest.java	Fri May 18 18:31:16 2012 +0200
@@ -543,6 +543,60 @@
         assertTrue(scrolled);
     }
 
+    @Test
+    public void unknownLocalShouldBeFixedByMousePosition() {
+        MouseEventGenerator gen = new MouseEventGenerator();
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        rect.setOnScroll(new EventHandler<ScrollEvent>() {
+            @Override public void handle(ScrollEvent event) {
+                assertEquals(150.0, event.getSceneX(), 0.0001);
+                assertEquals(150.0, event.getSceneY(), 0.0001);
+                scrolled = true;
+            }
+        });
+
+        scrolled = false;
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 250, 250));
+
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                true, false, true, false, true, false);
+
+        assertFalse(scrolled);
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 150, 150));
+
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                true, false, true, false, true, false);
+
+        assertTrue(scrolled);
+    }
+
+    @Test public void testToString() {
+        ScrollEvent e = ScrollEvent.impl_scrollEvent(ScrollEvent.SCROLL,
+            10, 10, 20, 20,
+            ScrollEvent.HorizontalTextScrollUnits.NONE, 0,
+            ScrollEvent.VerticalTextScrollUnits.NONE, 0,
+            3,
+            100, 100, 200, 200,
+            false, false, false, false,
+            true, false);
+
+        String s = e.toString();
+
+        assertNotNull(s);
+        assertFalse(s.isEmpty());
+    }
+
     private Scene createScene() {
         final Group root = new Group();
         
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javafx-ui-common/test/unit/javafx/scene/input/SwipeEventTest.java	Fri May 18 18:31:16 2012 +0200
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * 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.input;
+
+import com.sun.javafx.pgstub.StubScene;
+import com.sun.javafx.test.MouseEventGenerator;
+import javafx.event.EventHandler;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.shape.Rectangle;
+import javafx.stage.Stage;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class SwipeEventTest {
+
+    private boolean swiped;
+
+    @Test
+    public void shouldDeliverSwipeLeftEventToPickedNode() {
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        swiped = false;
+        rect.setOnSwipeLeft(new EventHandler<SwipeEvent>() {
+            @Override public void handle(SwipeEvent event) {
+                swiped = true;
+            }
+        });
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_LEFT, 1, 1, 1, 1, 1,
+                false, false, false, false, false);
+
+        assertFalse(swiped);
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_LEFT, 1, 150, 150, 150, 150,
+                false, false, false, false, false);
+
+        assertTrue(swiped);
+    }
+
+    @Test
+    public void shouldPassTouchCount() {
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        swiped = false;
+
+        rect.setOnSwipeUp(new EventHandler<SwipeEvent>() {
+            @Override public void handle(SwipeEvent event) {
+                assertEquals(3, event.getTouchCount());
+                swiped = true;
+            }
+        });
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_UP, 3, 150, 150, 150, 150,
+                false, false, false, false, false);
+
+        assertTrue(swiped);
+    }
+
+    @Test
+    public void shouldPassCoordinates() {
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        swiped = false;
+
+        rect.setOnSwipeUp(new EventHandler<SwipeEvent>() {
+            @Override public void handle(SwipeEvent event) {
+                assertEquals(151.0, event.getX(), 0.0001);
+                assertEquals(152.0, event.getY(), 0.0001);
+                assertEquals(153.0, event.getScreenX(), 0.0001);
+                assertEquals(154.0, event.getScreenY(), 0.0001);
+                swiped = true;
+            }
+        });
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_UP, 3, 151, 152, 153, 154,
+                false, false, false, false, false);
+
+        assertTrue(swiped);
+    }
+
+    @Test
+    public void shouldPassDirect() {
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        swiped = false;
+
+        rect.setOnSwipeDown(new EventHandler<SwipeEvent>() {
+            @Override public void handle(SwipeEvent event) {
+                assertEquals(swiped, event.isDirect());
+                swiped = !swiped;
+            }
+        });
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_DOWN, 3, 151, 152, 153, 154,
+                false, false, false, false, false);
+
+        assertTrue(swiped);
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_DOWN, 3, 151, 152, 153, 154,
+                false, false, false, false, true);
+
+        assertFalse(swiped);
+    }
+
+    @Test
+    public void handlingAnyShouldGetAllTypes() {
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        rect.addEventHandler(SwipeEvent.ANY, new EventHandler<SwipeEvent>() {
+            @Override public void handle(SwipeEvent event) {
+                swiped = true;
+            }
+        });
+
+        swiped = false;
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_UP, 3, 151, 152, 153, 154,
+                false, false, false, false, false);
+        assertTrue(swiped);
+
+        swiped = false;
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_DOWN, 3, 151, 152, 153, 154,
+                false, false, false, false, false);
+        assertTrue(swiped);
+
+        swiped = false;
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_LEFT, 3, 151, 152, 153, 154,
+                false, false, false, false, false);
+        assertTrue(swiped);
+
+        swiped = false;
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_RIGHT, 3, 151, 152, 153, 154,
+                false, false, false, false, false);
+        assertTrue(swiped);
+    }
+
+    @Test
+    public void unknownLocalShouldBeFixedByMousePosition() {
+        MouseEventGenerator gen = new MouseEventGenerator();
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        rect.setOnSwipeRight(new EventHandler<SwipeEvent>() {
+            @Override public void handle(SwipeEvent event) {
+                assertEquals(150.0, event.getSceneX(), 0.0001);
+                assertEquals(150.0, event.getSceneY(), 0.0001);
+                swiped = true;
+            }
+        });
+
+        swiped = false;
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 250, 250));
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_RIGHT, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                false, false, false, false, false);
+
+        assertFalse(swiped);
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 150, 150));
+
+        ((StubScene) scene.impl_getPeer()).getListener().swipeEvent(
+                SwipeEvent.SWIPE_RIGHT, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                false, false, false, false, false);
+
+        assertTrue(swiped);
+    }
+
+    @Test public void testToString() {
+        SwipeEvent e = SwipeEvent.impl_swipeEvent(SwipeEvent.SWIPE_RIGHT,
+            3,
+            100, 100, 200, 200,
+            false, false, false, false,
+            true);
+
+        String s = e.toString();
+
+        assertNotNull(s);
+        assertFalse(s.isEmpty());
+    }
+
+    private Scene createScene() {
+        final Group root = new Group();
+
+        final Scene scene = new Scene(root, 400, 400);
+
+        Rectangle rect = new Rectangle(100, 100, 100, 100);
+        Rectangle rect2 = new Rectangle(200, 200, 100, 100);
+
+        root.getChildren().addAll(rect, rect2);
+
+        Stage stage = new Stage();
+        stage.setScene(scene);
+        stage.show();
+
+        return scene;
+    }
+}
--- a/javafx-ui-common/test/unit/javafx/scene/input/TouchEventTest.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/test/unit/javafx/scene/input/TouchEventTest.java	Fri May 18 18:31:16 2012 +0200
@@ -448,6 +448,103 @@
     }
 
     @Test
+    public void shouldMaintainIDMappingInDynamicConditions() {
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        touched = 0;
+        rect.setOnTouchPressed(new EventHandler<TouchEvent>() {
+            @Override public void handle(TouchEvent event) {
+                touched++;
+                switch(event.getTouchPoint().getId()) {
+                    case 1:
+                        assertEquals(110.0, event.getTouchPoint().getX(), 0.0001);
+                        assertEquals(110.0, event.getTouchPoint().getY(), 0.0001);
+                        assertEquals(1, event.getTouchPoints().get(0).getId());
+                        assertEquals(2, event.getTouchPoints().get(1).getId());
+                        assertEquals(1, touched);
+                        break;
+                    case 2:
+                        assertEquals(120.0, event.getTouchPoint().getX(), 0.0001);
+                        assertEquals(120.0, event.getTouchPoint().getY(), 0.0001);
+                        assertEquals(1, event.getTouchPoints().get(0).getId());
+                        assertEquals(2, event.getTouchPoints().get(1).getId());
+                        assertEquals(2, touched);
+                        break;
+                    case 3:
+                        assertEquals(160.0, event.getTouchPoint().getX(), 0.0001);
+                        assertEquals(160.0, event.getTouchPoint().getY(), 0.0001);
+                        assertEquals(2, event.getTouchPoints().get(0).getId());
+                        assertEquals(3, event.getTouchPoints().get(1).getId());
+                        assertEquals(3, touched);
+                        break;
+                    default:
+                        fail("Wrong touch point id " + event.getTouchPoint().getId());
+                }
+            }
+        });
+
+        rect.setOnTouchMoved(new EventHandler<TouchEvent>() {
+            @Override public void handle(TouchEvent event) {
+                touched++;
+                switch(event.getTouchPoint().getId()) {
+                    case 2:
+                        assertEquals(120.0, event.getTouchPoint().getX(), 0.0001);
+                        assertEquals(120.0, event.getTouchPoint().getY(), 0.0001);
+                        assertEquals(2, event.getTouchPoints().get(0).getId());
+                        assertEquals(3, event.getTouchPoints().get(1).getId());
+                        assertEquals(4, touched);
+                        break;
+                    case 3:
+                        assertEquals(160.0, event.getTouchPoint().getX(), 0.0001);
+                        assertEquals(160.0, event.getTouchPoint().getY(), 0.0001);
+                        assertEquals(2, event.getTouchPoints().get(0).getId());
+                        assertEquals(3, event.getTouchPoints().get(1).getId());
+                        assertEquals(5, touched);
+                        break;
+                    default:
+                        fail("Wrong touch point id " + event.getTouchPoint().getId());
+                }
+            }
+        });
+
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventBegin(
+                System.currentTimeMillis(), 2, true, false, false, false, false);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.PRESSED, 1368, 110, 110, 110, 110);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.PRESSED, 127, 120, 120, 120, 120);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventEnd();
+
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventBegin(
+                System.currentTimeMillis(), 2, true, false, false, false, false);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.STATIONARY, 127, 120, 120, 120, 120);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.RELEASED, 1368, 120, 120, 120, 120);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventEnd();
+
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventBegin(
+                System.currentTimeMillis(), 2, true, false, false, false, false);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.PRESSED, 11, 160, 160, 160, 160);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.STATIONARY, 127, 120, 120, 120, 120);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventEnd();
+
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventBegin(
+                System.currentTimeMillis(), 2, true, false, false, false, false);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.MOVED, 11, 160, 160, 160, 160);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventNext(
+                TouchPoint.State.MOVED, 127, 120, 120, 120, 120);
+        ((StubScene) scene.impl_getPeer()).getListener().touchEventEnd();
+
+        assertEquals(5, touched);
+    }
+
+    @Test
     public void shouldResetIDsAfterGesture() {
         Scene scene = createScene();
         Rectangle rect =
--- a/javafx-ui-common/test/unit/javafx/scene/input/ZoomEventTest.java	Fri May 18 15:56:48 2012 +0200
+++ b/javafx-ui-common/test/unit/javafx/scene/input/ZoomEventTest.java	Fri May 18 18:31:16 2012 +0200
@@ -370,6 +370,57 @@
         assertTrue(zoomed);
     }
 
+    @Test
+    public void unknownLocalShouldBeFixedByMousePosition() {
+        MouseEventGenerator gen = new MouseEventGenerator();
+        Scene scene = createScene();
+        Rectangle rect =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+
+        rect.setOnZoom(new EventHandler<ZoomEvent>() {
+            @Override public void handle(ZoomEvent event) {
+                assertEquals(150.0, event.getSceneX(), 0.0001);
+                assertEquals(150.0, event.getSceneY(), 0.0001);
+                zoomed = true;
+            }
+        });
+
+        zoomed = false;
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 250, 250));
+
+        ((StubScene) scene.impl_getPeer()).getListener().zoomEvent(
+                ZoomEvent.ZOOM, 2, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                true, false, true, false, true, false);
+
+        assertFalse(zoomed);
+
+        scene.impl_processMouseEvent(
+                gen.generateMouseEvent(MouseEvent.MOUSE_MOVED, 150, 150));
+
+        ((StubScene) scene.impl_getPeer()).getListener().zoomEvent(
+                ZoomEvent.ZOOM, 2, 3,
+                Double.NaN, Double.NaN, Double.NaN, Double.NaN,
+                true, false, true, false, true, false);
+
+        assertTrue(zoomed);
+    }
+
+    @Test public void testToString() {
+        ZoomEvent e = ZoomEvent.impl_zoomEvent(ZoomEvent.ZOOM,
+            10, 20,
+            100, 100, 200, 200,
+            false, false, false, false,
+            true, false);
+
+        String s = e.toString();
+
+        assertNotNull(s);
+        assertFalse(s.isEmpty());
+    }
+
     private Scene createScene() {
         final Group root = new Group();