changeset 7899:62aa644a60d4

[Unit Tests] Additional case for DragTouchInAndOutAWindowTest, contributed-By: Diana Berkovich
author Elina Kleyman <elina.kleyman@oracle.com>
date Thu, 28 Aug 2014 16:46:20 +0300
parents 33220c4b1e46
children b72f6918383b
files tests/system/src/test/java/com/sun/glass/ui/monocle/DragTouchInAndOutAWindowTest.java
diffstat 1 files changed, 86 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/DragTouchInAndOutAWindowTest.java	Thu Aug 28 14:59:31 2014 +0200
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/DragTouchInAndOutAWindowTest.java	Thu Aug 28 16:46:20 2014 +0300
@@ -27,6 +27,7 @@
 
 import com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
 import com.sun.glass.ui.monocle.input.devices.TestTouchDevices;
+import javafx.geometry.Rectangle2D;
 import javafx.stage.Stage;
 import org.junit.Assert;
 import org.junit.Assume;
@@ -68,12 +69,12 @@
     }
 
     /**
-     * RT-33771 stated that exceptions are been thrown because the state of the 
-     * point, when entering the window, is wrong. 
-     * Test check that states are ok and no exception is been thrown 
-     *  
-     * Test update for RT-34191 - make sure no touch event received if drag 
-     * started outside the window 
+     * RT-33771 stated that exceptions are been thrown because the state of the
+     * point, when entering the window, is wrong.
+     * Test check that states are ok and no exception is been thrown
+     *
+     * Test update for RT-34191 - make sure no touch event received if drag
+     * started outside the window
      */
     @Test
     public void singleTouch_dragPointIntoTheWindow() throws Exception {
@@ -107,11 +108,11 @@
 
     @Test
     /**
-     * This test is also related to RT-33687 - Lens:some touch events are been 
-     * dropped in native causing exceptions to be thrown. 
-     * In short there was a problem that when touch point moved outside a window 
+     * This test is also related to RT-33687 - Lens:some touch events are been
+     * dropped in native causing exceptions to be thrown.
+     * In short there was a problem that when touch point moved outside a window
      * no notifications were sent, especially releases.
-     * 
+     *
      */
     public void singleTouch_dragPointoutsideAwindow() throws Exception {
         Stage stage = TestApplication.getStage();
@@ -138,10 +139,10 @@
 
      @Test
     /**
-     * Combining the two test cases above, start a touch sequence inside a 
-     * window, drag the 'finger' out and in again and see that we gat the 
-     * events. 
-     * 
+     * Combining the two test cases above, start a touch sequence inside a
+     * window, drag the 'finger' out and in again and see that we gat the
+     * events.
+     *
      */
     public void singleTouch_dragPointInandOutAwindow() throws Exception {
         Stage stage = TestApplication.getStage();
@@ -177,10 +178,10 @@
 
      @Test
     /**
-     * Same test as above, but for multi touch. 
-     * Test should pass in either single touch mode or multi touch mode 
+     * Same test as above, but for multi touch.
+     * Test should pass in either single touch mode or multi touch mode
      * Main point is to see that no exception is been thrown
-     * 
+     *
      */
     public void multiTouch_dragPointInandOutAwindow() throws Exception {
         Assume.assumeTrue(device.getPointCount() >= 2);
@@ -192,7 +193,7 @@
         int p1 = device.addPoint(windowRightEnd + 15, windowMiddleHeight);
         int p2 = device.addPoint(windowRightEnd + 15, windowMiddleHeight + 10);
         device.sync();
-        //start outside the window and drag point into the center of window 
+        //start outside the window and drag point into the center of window
         for (i = windowRightEnd + 12; i >= windowMiddleWidth ; i -= 3) {
             //first finger
             device.setPoint(p1, i, windowMiddleHeight);
@@ -201,7 +202,7 @@
             device.sync();
         }
 
-        //continue from where we stopped and drag point outside the window to 
+        //continue from where we stopped and drag point outside the window to
         //the end of screen
         for (; i + windowMiddleWidth < width ; i += 5) {
             //first finger
@@ -221,4 +222,70 @@
         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: MOVED"));
         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: RELEASED"));
     }
+
+    @Test
+    /**
+     * Drag two touch points simultaneously from outside the window (from the
+     * right side) to the window's center.
+     * No "move", "press" or "release" events should be sent.
+     */
+    public void multiTouch_dragTwoPointsIntoTheWindow() throws Exception {
+        Assume.assumeTrue(device.getPointCount() >= 2);
+        Stage stage = TestApplication.getStage();
+        double[] bounds = {0.0, 0.0, 0.0, 0.0};
+        TestRunnable.invokeAndWait(() -> {
+            bounds[0] = stage.getX();
+            bounds[1] = stage.getY();
+            bounds[2] = stage.getWidth();
+            bounds[3] = stage.getHeight();
+        });
+        Rectangle2D stageBounds = new Rectangle2D(bounds[0], bounds[1],
+                                                  bounds[2], bounds[3]);
+        int windowX = (int) (stageBounds.getMinX());
+        int windowY = (int) (stageBounds.getMinY());
+        int windowMiddleX = (int) (stageBounds.getMinX() + stageBounds.getWidth() / 2);
+        int windowMiddleY = (int) (stageBounds.getMinY() + stageBounds.getHeight() / 2);
+        int windowRightEnd = (int) (stageBounds.getMaxX());
+        //distance between tap points
+        int distance = device.getTapRadius() + 2;
+        int x1 = windowRightEnd + distance;
+        int y1 = windowMiddleY;
+        int x2 = windowRightEnd + distance * 2;
+        int y2 = y1;
+        Assert.assertTrue(x1 < width && x2 < width);
+        //press two fingers
+        int p1 = device.addPoint(x1, y1);
+        int p2 = device.addPoint(x2, y2);
+        device.sync();
+
+        //drag the fingers into the center of window
+        for (int i = x1 - 3; i >= windowMiddleX; i -= 3) {
+            device.setPoint(p1, i, windowMiddleY);
+            device.setPoint(p2, i + distance, windowMiddleY);
+            device.sync();
+        }
+
+        //release all points
+        device.removePoint(p1);
+        device.removePoint(p2);
+        device.sync();
+
+        //tap in the window in order to verify all events were received
+        int x3 = windowX;
+        int y3 = windowY;
+        int p = device.addPoint(x3, y3);
+        device.sync();
+        device.removePoint(p);
+        device.sync();
+        //verify events press/release were received
+        TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x3, y3);
+        TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d", x3, y3);
+
+        //Verify press/release events were received only once
+        Assert.assertEquals(1, TestLog.countLogContaining("TouchPoint: PRESSED"));
+        Assert.assertEquals(1, TestLog.countLogContaining("TouchPoint: RELEASED"));
+
+        //make sure no move event was received
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: MOVED"));
+    }
 }