aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena Sayapina <elena.sayapina@jetbrains.com>2020-12-09 18:38:33 +0700
committerElena Sayapina <elena.sayapina@jetbrains.com>2020-12-09 18:43:24 +0700
commit4deb3bbe61087de1afb636e493ea337f8accee27 (patch)
tree00140c0a478c7434c7daa0fa9ada491c924de660
parenteda8e4d50e03a2caa61fd2f0d14a31df89441657 (diff)
downloadJetBrainsRuntime-4deb3bbe61087de1afb636e493ea337f8accee27.tar.gz
JBR-2585 [TESTBUG] TouchScreenEvent tests affect tests simulating mouse actionsjb11_0_9_1-b1214
- added workaround for JBR-2585 - added README.md about manual test run - made an update to close LinuxTouchScreenDevice properly - added an error exit from linux shell script if sudo password is empty or chown fails
-rw-r--r--test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchRobot.java4
-rw-r--r--test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchScreenDevice.java5
-rw-r--r--test/jdk/jb/java/awt/event/TouchScreenEvent/README.md49
-rw-r--r--test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java51
-rw-r--r--test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh19
-rwxr-xr-xtest/jdk/jbProblemList.txt3
6 files changed, 104 insertions, 27 deletions
diff --git a/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchRobot.java b/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchRobot.java
index b8cafa444a7..47cbfe889b3 100644
--- a/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchRobot.java
+++ b/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchRobot.java
@@ -38,4 +38,8 @@ public class LinuxTouchRobot extends TouchRobot {
public void touchMove(int fingerId, int fromX, int fromY, int toX, int toY) throws IOException {
device.move(fingerId, fromX, fromY, toX, toY);
}
+
+ public void closeDevice() throws IOException {
+ device.close();
+ }
}
diff --git a/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchScreenDevice.java b/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchScreenDevice.java
index 6e1151dc54c..52e2d22d872 100644
--- a/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchScreenDevice.java
+++ b/test/jdk/jb/java/awt/event/TouchScreenEvent/LinuxTouchScreenDevice.java
@@ -15,9 +15,10 @@
*/
import java.awt.Toolkit;
+import java.io.Closeable;
import java.io.IOException;
-public class LinuxTouchScreenDevice implements AutoCloseable {
+public class LinuxTouchScreenDevice implements Closeable {
// TODO add product id
private int width;
private int height;
@@ -40,7 +41,7 @@ public class LinuxTouchScreenDevice implements AutoCloseable {
}
@Override
- public void close() throws Exception {
+ public void close() throws IOException {
checkCompletion(destroy(fileDescriptor),
"Failed to close touchscreen device");
}
diff --git a/test/jdk/jb/java/awt/event/TouchScreenEvent/README.md b/test/jdk/jb/java/awt/event/TouchScreenEvent/README.md
new file mode 100644
index 00000000000..d206df6dc40
--- /dev/null
+++ b/test/jdk/jb/java/awt/event/TouchScreenEvent/README.md
@@ -0,0 +1,49 @@
+###Tips for compiling test libraries and preparing env for manual test running
+
+
+## Linux
+```shell script
+# step into the test directory
+cd <JetBrainsRuntime>/test/jdk/jb/java/awt/event/TouchScreenEvent
+
+# complile native lib
+gcc -shared -fPIC -I<path_to_jbr>/include/linux -I<path_to_jbr>/include touchscreen_device.c -o libtouchscreen_device.so
+
+# step into the runtime workspace directory
+cd <JetBrainsRuntime>
+
+# run the test with jtreg
+jtreg -v -testjdk:<path_to_jbr> -e:BUPWD=<SUDO_PWD> -nativepath:'<JetBrainsRuntime>/test/jdk/jb/java/awt/event/TouchScreenEvent' test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh
+
+```
+
+SUDO_PWD above is the sudo password which is needed to allow current user to work with /dev/uinput: please see [group permissions](https://github.com/tuomasjjrasanen/python-uinput/issues/6#issuecomment-538710069) link.
+
+## Windows
+```shell script
+# run cmd and call vcvarsall.bat with the target arch argument
+"<path_to_vcvarsall>\vcvarsall.bat" amd64
+
+# step into the test directory
+cd <JetBrainsRuntime>\test\jdk\jb\java\awt\event\TouchScreenEvent
+
+# complile native lib
+cl -I<path_to_jbr>\include\win32 -I<path_to_jbr>\include -MD -LD windows_touch_robot.c "<path_to_user32lib>\user32.lib" -Fewindows_touch_robot.dll
+
+# step into the runtime workspace directory
+cd <JetBrainsRuntime>
+
+# run bash
+bash
+
+# run the test with jtreg
+jtreg -v -testjdk:<path_to_jbr> -nativepath:'<JetBrainsRuntime>/test/jdk/jb/java/awt/event/TouchScreenEvent' test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java
+
+```
+
+vcvarsall.bat above may be found in Microsoft Visual Studio, for example,
+"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
+
+user32.lib above is needed for WinUser.h (touch injection stuff),
+it may be found, for example, in
+"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64\user32.lib"
diff --git a/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java b/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java
index 2ffc5e408f9..0addc75855b 100644
--- a/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java
+++ b/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java
@@ -17,7 +17,10 @@
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import java.awt.AWTException;
+import java.awt.MouseInfo;
import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent;
@@ -26,10 +29,13 @@ import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import sun.awt.event.TouchEvent;
+
/**
* @test
* @summary Regression test for JBR-2041: Touchscreen devices support
* @requires (jdk.version.major >= 11) & (os.family == "windows")
+ * @modules java.desktop/sun.awt.event
* @build WindowsTouchRobot TouchScreenEventsTest
* @run main/othervm/native TouchScreenEventsTest
*/
@@ -39,10 +45,9 @@ public class TouchScreenEventsTest {
static final int TIMEOUT = 2;
static final int PAUSE = 1000;
- // TODO make this constants accessible within jdk
- static final int TOUCH_BEGIN = 2;
- static final int TOUCH_UPDATE = 3;
- static final int TOUCH_END = 4;
+ static final int TRACKING_ID = 42;
+
+ static final String OS_NAME = System.getProperty("os.name").toLowerCase();
public static void main(String[] args) throws Exception {
if(runTest(new TouchClickSuite())
@@ -57,9 +62,9 @@ public class TouchScreenEventsTest {
}
private static boolean runTest(TouchTestSuite suite) throws Exception {
+ TouchRobot robot = getTouchRobot();
GUI gui = new GUI();
try {
- TouchRobot robot = getTouchRobot();
SwingUtilities.invokeAndWait(gui::createAndShow);
suite.addListener(gui.frame);
robot.waitForIdle();
@@ -68,7 +73,15 @@ public class TouchScreenEventsTest {
robot.waitForIdle();
return suite.passed();
} finally {
- SwingUtilities.invokeLater(() -> {
+ if (OS_NAME.contains("linux")) {
+ // Workaround for JBR-2585
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle();
+ // Close LinuxTouchScreenDevice
+ ((LinuxTouchRobot) robot).closeDevice();
+ }
+ SwingUtilities.invokeAndWait(() -> {
if (gui.frame != null) {
gui.frame.dispose();
}
@@ -78,10 +91,9 @@ public class TouchScreenEventsTest {
}
private static TouchRobot getTouchRobot() throws IOException, AWTException {
- String osName = System.getProperty("os.name").toLowerCase();
- if (osName.contains("linux")) {
+ if (OS_NAME.contains("linux")) {
return new LinuxTouchRobot();
- } else if (osName.contains("windows")) {
+ } else if (OS_NAME.contains("windows")) {
return new WindowsTouchRobot();
}
throw new RuntimeException("Touch robot for this platform isn't implemented");
@@ -96,6 +108,7 @@ class GUI {
frame = new JFrame();
frame.setSize(640, 480);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setAlwaysOnTop(true);
frame.setVisible(true);
frameBounds = frame.getBounds();
}
@@ -155,7 +168,7 @@ class TouchClickSuite implements MouseListener, TouchTestSuite {
public void perform(GUI gui, TouchRobot robot) throws IOException {
int x = gui.frameBounds.x + gui.frameBounds.width / 2;
int y = gui.frameBounds.y + gui.frameBounds.height / 2;
- robot.touchClick(42, x, y);
+ robot.touchClick(TouchScreenEventsTest.TRACKING_ID, x, y);
}
@Override
@@ -187,17 +200,17 @@ class TouchMoveSuite implements MouseWheelListener, TouchTestSuite {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
- if (e.getScrollType() == TouchScreenEventsTest.TOUCH_BEGIN) {
+ if (e.getScrollType() == TouchEvent.TOUCH_BEGIN) {
if (!begin) {
begin = true;
latch.countDown();
}
- } else if (e.getScrollType() == TouchScreenEventsTest.TOUCH_UPDATE) {
+ } else if (e.getScrollType() == TouchEvent.TOUCH_UPDATE) {
if (!update) {
update = true;
latch.countDown();
}
- } else if (e.getScrollType() == TouchScreenEventsTest.TOUCH_END) {
+ } else if (e.getScrollType() == TouchEvent.TOUCH_END) {
if (!end) {
end = true;
latch.countDown();
@@ -211,7 +224,7 @@ class TouchMoveSuite implements MouseWheelListener, TouchTestSuite {
int y1 = gui.frameBounds.y + gui.frameBounds.height / 4;
int x2 = gui.frameBounds.x + gui.frameBounds.width / 2;
int y2 = gui.frameBounds.y + gui.frameBounds.height / 2;
- robot.touchMove(42, x1, y1, x2, y2);
+ robot.touchMove(TouchScreenEventsTest.TRACKING_ID, x1, y1, x2, y2);
}
@Override
@@ -242,7 +255,7 @@ class TouchTinyMoveSuite implements MouseWheelListener, MouseListener, TouchTest
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
- if (e.getScrollType() == TouchScreenEventsTest.TOUCH_UPDATE) {
+ if (e.getScrollType() == TouchEvent.TOUCH_UPDATE) {
scroll = true;
latch.countDown();
}
@@ -255,7 +268,7 @@ class TouchTinyMoveSuite implements MouseWheelListener, MouseListener, TouchTest
// move inside tiny area
int x2 = x1 + 1;
int y2 = y1 + 1;
- robot.touchMove(42, x1, y1, x2, y2);
+ robot.touchMove(TouchScreenEventsTest.TRACKING_ID, x1, y1, x2, y2);
}
@Override
@@ -314,7 +327,7 @@ class TouchAxesScrollSuite implements MouseWheelListener, TouchTestSuite {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
- if (e.getScrollType() == TouchScreenEventsTest.TOUCH_UPDATE) {
+ if (e.getScrollType() == TouchEvent.TOUCH_UPDATE) {
if (e.isShiftDown()) {
horizontal = true;
} else {
@@ -331,11 +344,11 @@ class TouchAxesScrollSuite implements MouseWheelListener, TouchTestSuite {
switch (axis) {
case X:
int x2 = gui.frameBounds.x + gui.frameBounds.width / 2;
- robot.touchMove(42, x1, y1, x2, y1);
+ robot.touchMove(TouchScreenEventsTest.TRACKING_ID, x1, y1, x2, y1);
break;
case Y:
int y2 = gui.frameBounds.y + gui.frameBounds.height / 2;
- robot.touchMove(42, x1, y1, x1, y2);
+ robot.touchMove(TouchScreenEventsTest.TRACKING_ID, x1, y1, x1, y2);
break;
}
}
diff --git a/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh b/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh
index 4c4e663e71a..96d5a527835 100644
--- a/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh
+++ b/test/jdk/jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh
@@ -19,26 +19,37 @@
# @test
# @summary Regression test for JBR-2041: Touchscreen devices support
# @requires (jdk.version.major >= 11) & (os.family == "linux")
+# @modules java.desktop/sun.awt.event
# @build TouchRobot LinuxTouchRobot LinuxTouchScreenDevice TouchScreenEventsTest
# @run shell TouchScreenEventsTestLinux.sh
# password for sudo
PASSWORD=${BUPWD}
+if [ "${PASSWORD}" = "" ]
+then
+ echo "Error: Root password is empty"; exit 1
+fi
+
echo "Allow current user write to /dev/uinput:"
echo "> sudo chown `whoami` /dev/uinput"
echo ${PASSWORD} | sudo -S chown `whoami` /dev/uinput
-echo "result=$?"
+if [ $? != 0 ] ; then
+ echo "Error: Cannot change owner of /dev/uinput"; exit 1
+fi
+
echo "Launching TouchScreenEventsTest.java:"
echo "> $TESTJAVA/bin/java $TESTVMOPTS -cp $TESTCLASSES TouchScreenEventsTest"
$TESTJAVA/bin/java $TESTVMOPTS -cp $TESTCLASSES TouchScreenEventsTest
result=$?
-echo "result=$result"
+echo "Test run result=$result"
-echo "Restore permissions for /dev/uinput:"
+echo "Restore permissions on /dev/uinput:"
echo "> sudo chown root /dev/uinput"
echo ${PASSWORD} | sudo -S chown root /dev/uinput
-echo "result=$?"
+if [ $? != 0 ] ; then
+ echo "Error: Cannot restore permissions on /dev/uinput"
+fi
exit $result
diff --git a/test/jdk/jbProblemList.txt b/test/jdk/jbProblemList.txt
index 976f97c5b8d..06817260e89 100755
--- a/test/jdk/jbProblemList.txt
+++ b/test/jdk/jbProblemList.txt
@@ -1267,8 +1267,7 @@ sanity/client/SwingSet/src/GridBagLayoutDemoTest.java
jb/java/jcef/MouseEventTest.java JBR-2750 linux-all
jb/java/jcef/MouseEventAfterHideAndShowBrowserTest.java JBR-2750 linux-all
-jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java JBR-2585 linux-all,windows-all nobug windows-6.1 not supported on Windows 7
-jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTestLinux.sh JBR-2585 linux-all
+jb/java/awt/event/TouchScreenEvent/TouchScreenEventsTest.java nobug windows-6.1 not supported on Windows 7
jb/java/awt/Focus/ChainOfPopupsFocusTest.java JBR-1518 linux-all
jb/java/awt/Focus/ModalDialogFromMenuTest.java JBR-2768 macosx-all