changeset 6847:cd30fe269fba

RT-36605 : Create new (unit) input tests to check the fix for RT-36487 Reviewed-by : dblaukopf.
author Rafi Tayar <rafi.tayar@oracle.com>
date Tue, 22 Apr 2014 15:18:06 +0300
parents da7406208784
children f2043e51608b
files tests/system/src/test/java/com/sun/glass/ui/monocle/input/SingleTouchTest.java tests/system/src/test/java/com/sun/glass/ui/monocle/input/TestApplication.java tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDevice.java tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDevice1.java tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDevice2.java tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDeviceBase.java tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevices.java
diffstat 7 files changed, 213 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/SingleTouchTest.java	Tue Apr 22 15:31:26 2014 +0400
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/SingleTouchTest.java	Tue Apr 22 15:18:06 2014 +0300
@@ -63,6 +63,9 @@
         TestLog.waitForLog("Mouse clicked: %d, %d", x, y);
         TestLog.waitForLog("Touch pressed: %d, %d", x, y);
         TestLog.waitForLog("Touch released: %d, %d", x, y);
+
+        // Check that the touch event has no more than one touch point.
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint(2):"));
     }
 
     /**
@@ -91,6 +94,8 @@
         // same location, so make sure they are filtered out.
         Assert.assertEquals(0, TestLog.countLogContaining("Mouse pressed:"));
         Assert.assertEquals(0, TestLog.countLogContaining("Touch pressed:"));
+        // Check that the touch event has no more than one touch point.
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint(2):"));
     }
 
     /**
@@ -118,6 +123,8 @@
         TestLog.waitForLog("Touch pressed: %d, %d", x1, y1);
         TestLog.waitForLog("Touch moved: %d, %d", x2, y2);
         TestLog.waitForLog("Touch released: %d, %d", x2, y2);
+        // Check that the touch event has no more than one touch point.
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint(2):"));
     }
 
     /**
@@ -144,6 +151,8 @@
         TestLog.waitForLog("Touch pressed: %d, %d", x1, y1);
         TestLog.waitForLog("Touch moved: %d, %d", x2, y1);
         TestLog.waitForLog("Touch released: %d, %d", x2, y1);
+        // Check that the touch event has no more than one touch point.
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint(2):"));
     }
 
     /**
@@ -170,6 +179,8 @@
         TestLog.waitForLog("Touch pressed: %d, %d", x1, y1);
         TestLog.waitForLog("Touch moved: %d, %d", x1, y2);
         TestLog.waitForLog("Touch released: %d, %d", x1, y2);
+        // Check that the touch event has no more than one touch point.
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint(2):"));
     }
 
     /**
@@ -198,6 +209,8 @@
         TestLog.waitForLog("Touch released: %d, %d", x1, y1);
         Assert.assertEquals(0l, TestLog.countLogContaining("Mouse dragged"));
         Assert.assertEquals(0l, TestLog.countLogContaining("Touch moved"));
+        // Check that the touch event has no more than one touch point.
+        Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint(2):"));
     }
 
 
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/TestApplication.java	Tue Apr 22 15:31:26 2014 +0400
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/TestApplication.java	Tue Apr 22 15:18:06 2014 +0300
@@ -231,8 +231,9 @@
 
     public static void addTouchListeners() throws Exception {
         Consumer<List<TouchPoint>> logTouchPoints = (tps) -> {
+            int i = 1;
             for (TouchPoint tp : tps) {
-                TestLog.log("TouchPoint: " + tp.getState() + " "
+                TestLog.log("TouchPoint(" + i++ + "): " + tp.getState() + " "
                         + (int) tp.getScreenX() + ", " + (int) tp.getScreenY()
                         + " id=" + tp.getId());
             }
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDevice.java	Tue Apr 22 15:31:26 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2014, 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 com.sun.glass.ui.monocle.input.devices;
-
-import com.sun.glass.ui.monocle.input.TestApplication;
-import com.sun.glass.ui.monocle.input.UInput;
-import org.junit.Assume;
-
-/**
- * EGalaxSingleTouchDevice sends ABS_X and ABS_Y events. It uses BTN_TOUCH to notify
- * presses and releases. It does not send ABS_X or ABS_Y if that coordinate has
- * not changed. Before the first touch it sends coordinates with no EV_KEY
- * event.
- */
-public class EGalaxSingleTouchDevice extends TestTouchDevice {
-
-    private boolean firstPress = true;
-
-    public EGalaxSingleTouchDevice() {
-        super(1);
-    }
-
-    @Override
-    public void create() {
-        Assume.assumeTrue(TestApplication.isMonocle());
-        ui = new UInput();
-        ui.processLine("OPEN");
-        ui.processLine("EVBIT EV_SYN");
-        ui.processLine("EVBIT EV_KEY");
-        ui.processLine("KEYBIT BTN_TOUCH");
-        ui.processLine("EVBIT EV_ABS");
-        ui.processLine("ABSBIT ABS_X");
-        ui.processLine("ABSBIT ABS_Y");
-        ui.processLine("ABSMIN ABS_X 0");
-        ui.processLine("ABSMAX ABS_X 4095");
-        ui.processLine("ABSMIN ABS_Y 0");
-        ui.processLine("ABSMAX ABS_Y 4095");
-        ui.processLine("PROPBIT INPUT_PROP_POINTER");
-        ui.processLine("PROPBIT INPUT_PROP_DIRECT");
-        ui.processLine("PROPERTY ID_INPUT_TOUCHSCREEN 1");
-        ui.processLine("CREATE");
-        setAbsScale(4096, 4096);
-    }
-
-    @Override
-    public int addPoint(double x, double y) {
-        int p = super.addPoint(x, y);
-        if (firstPress) {
-            ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
-            ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
-            ui.processLine("EV_SYN SYN_REPORT 0");
-            firstPress = false;
-        }
-        ui.processLine("EV_KEY BTN_TOUCH 1");
-        ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
-        ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
-        return p;
-    }
-
-    @Override
-    public void removePoint(int p) {
-        super.removePoint(p);
-        ui.processLine("EV_KEY BTN_TOUCH 0");
-    }
-
-    @Override
-    public void setPoint(int p, double x, double y) {
-        int oldX = transformedXs[p];
-        int oldY = transformedYs[p];
-        super.setPoint(p, x, y);
-        // if neither X nor Y have changed, we send X
-        if (oldX != transformedXs[p] || oldY == transformedYs[p]) {
-            ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
-        }
-        if (oldY != transformedYs[p]) {
-            ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
-        }
-    }
-
-    @Override
-    public void resendStateAndSync() {
-        if (points[0]) {
-            ui.processLine("EV_ABS ABS_X " + transformedXs[0]);
-            ui.processLine("EV_ABS ABS_Y " + transformedYs[0]);
-        }
-        sync();
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDevice1.java	Tue Apr 22 15:18:06 2014 +0300
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014, 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 com.sun.glass.ui.monocle.input.devices;
+
+import com.sun.glass.ui.monocle.input.TestApplication;
+import com.sun.glass.ui.monocle.input.UInput;
+import org.junit.Assume;
+
+
+public class EGalaxSingleTouchDevice1 extends EGalaxSingleTouchDeviceBase {
+
+    private boolean firstPress = true;
+
+    @Override
+    public int addPoint(double x, double y) {
+        int p = super.addPoint(x, y);
+        if (firstPress) {
+            ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
+            ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
+            ui.processLine("EV_SYN SYN_REPORT 0");
+            firstPress = false;
+        }
+        ui.processLine("EV_KEY BTN_TOUCH 1");
+        ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
+        ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
+        return p;
+    }
+
+    @Override
+    public void removePoint(int p) {
+        super.removePoint(p);
+        ui.processLine("EV_KEY BTN_TOUCH 0");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDevice2.java	Tue Apr 22 15:18:06 2014 +0300
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014, 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 com.sun.glass.ui.monocle.input.devices;
+
+import com.sun.glass.ui.monocle.input.TestApplication;
+import com.sun.glass.ui.monocle.input.UInput;
+import org.junit.Assume;
+
+public class EGalaxSingleTouchDevice2 extends EGalaxSingleTouchDeviceBase {
+
+    @Override
+    public int addPoint(double x, double y) {
+        int p = super.addPoint(x, y);
+        ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
+        ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
+        ui.processLine("EV_KEY BTN_TOUCH 1");
+        ui.processLine("EV_ABS ABS_PRESSURE 1");
+        return p;
+    }
+
+    @Override
+    public void removePoint(int p) {
+        super.removePoint(p);
+        ui.processLine("EV_KEY BTN_TOUCH 0");
+        ui.processLine("EV_ABS ABS_PRESSURE 0");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/EGalaxSingleTouchDeviceBase.java	Tue Apr 22 15:18:06 2014 +0300
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2014, 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 com.sun.glass.ui.monocle.input.devices;
+
+import com.sun.glass.ui.monocle.input.TestApplication;
+import com.sun.glass.ui.monocle.input.UInput;
+import org.junit.Assume;
+
+/**
+ * EGalaxSingleTouchDeviceBase sends ABS_X and ABS_Y events. It uses BTN_TOUCH to notify
+ * presses and releases. It does not send ABS_X or ABS_Y if that coordinate has
+ * not changed. Before the first touch it sends coordinates with no EV_KEY
+ * event.
+ */
+public abstract class EGalaxSingleTouchDeviceBase extends TestTouchDevice {
+
+    public EGalaxSingleTouchDeviceBase() {
+        super(1);
+    }
+
+    @Override
+    public void create() {
+        Assume.assumeTrue(TestApplication.isMonocle());
+        ui = new UInput();
+        ui.processLine("OPEN");
+        ui.processLine("EVBIT EV_SYN");
+        ui.processLine("EVBIT EV_KEY");
+        ui.processLine("KEYBIT BTN_TOUCH");
+        ui.processLine("EVBIT EV_ABS");
+        ui.processLine("ABSBIT ABS_X");
+        ui.processLine("ABSBIT ABS_Y");
+        ui.processLine("ABSMIN ABS_X 0");
+        ui.processLine("ABSMAX ABS_X 4095");
+        ui.processLine("ABSMIN ABS_Y 0");
+        ui.processLine("ABSMAX ABS_Y 4095");
+        ui.processLine("PROPBIT INPUT_PROP_POINTER");
+        ui.processLine("PROPBIT INPUT_PROP_DIRECT");
+        ui.processLine("PROPERTY ID_INPUT_TOUCHSCREEN 1");
+        ui.processLine("CREATE");
+        setAbsScale(4096, 4096);
+    }
+
+    @Override
+    public void setPoint(int p, double x, double y) {
+        int oldX = transformedXs[p];
+        int oldY = transformedYs[p];
+        super.setPoint(p, x, y);
+        // if neither X nor Y have changed, we send X
+        if (oldX != transformedXs[p] || oldY == transformedYs[p]) {
+            ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
+        }
+        if (oldY != transformedYs[p]) {
+            ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
+        }
+    }
+
+    @Override
+    public void resendStateAndSync() {
+        if (points[0]) {
+            ui.processLine("EV_ABS ABS_X " + transformedXs[0]);
+            ui.processLine("EV_ABS ABS_Y " + transformedYs[0]);
+        }
+        sync();
+    }
+
+}
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevices.java	Tue Apr 22 15:31:26 2014 +0400
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevices.java	Tue Apr 22 15:18:06 2014 +0300
@@ -60,7 +60,8 @@
         devices.addAll(Arrays.asList(new TestTouchDevice[] {
                 new SingleTouchDevice1(),
                 new SingleTouchDevice2(),
-                new EGalaxSingleTouchDevice(),
+                new EGalaxSingleTouchDevice1(),
+                new EGalaxSingleTouchDevice2(),
                 new EGalaxMultiTouchDevice1(),
                 new EGalaxMultiTouchDevice2(),
                 new TouchRevolutionFusionDevice(),