Bug 528968: [Wayland] JVM crashes when running JUnit tests on Wayland
Guard call to takeScreenshot() so that running the SWT JUnit tests
doesn't crash the JVM on Wayland.
Change-Id: I0ea725a491dfc1f7781ccd647b706e5a5517fc59
Signed-off-by: Eric Williams <ericwill@redhat.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 409fd3dc..b640eb4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -749,6 +749,10 @@
System.setProperty("org.eclipse.swt.internal.gtk.version",
(GTK_VERSION >>> 16) + "." + (GTK_VERSION >>> 8 & 0xFF) + "." + (GTK_VERSION & 0xFF));
+ // set GDK backend if we are on X11
+ if (isX11()) {
+ System.setProperty("org.eclipse.swt.internal.gdk.backend", "x11");
+ }
}
protected static byte [] ascii (String name) {
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/SwtTestUtil.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/SwtTestUtil.java
index fa8397f..44bfcde 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/SwtTestUtil.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/SwtTestUtil.java
@@ -73,6 +73,9 @@
&& ("hudsonbuild".equalsIgnoreCase(System.getProperty("user.name"))
|| "genie.platform".equalsIgnoreCase(System.getProperty("user.name")));
+ public final static boolean isX11 = isGTK
+ && "x11".equals(System.getProperty("org.eclipse.swt.internal.gdk.backend"));
+
static {
testFontName = "Helvetica";
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
index bb7c5f7..de4638e 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
@@ -1191,9 +1191,9 @@
display.setCursorLocation(location.x, location.y); // don't put cursor into a corner, since that could trigger special platform events
drainEventQueue(display, 150); // workaround for https://bugs.eclipse.org/492569
Point actual = display.getCursorLocation();
- if (!BUG_492569) {
+ if (!BUG_492569 && SwtTestUtil.isX11) {
if (!location.equals(actual)) {
- Screenshots.takeScreenshot(getClass(), testName.getMethodName());
+ Screenshots.takeScreenshot(getClass(), testName.getMethodName()); // Bug 528968 This call causes crash on Wayland.
fail("\nExpected:"+location.toString()+" Actual:"+actual.toString());
}
} else {
@@ -1223,9 +1223,9 @@
}
drainEventQueue(display, 150); // workaround for https://bugs.eclipse.org/492569
Point actual = display.getCursorLocation();
- if (!BUG_492569) {
+ if (!BUG_492569 && SwtTestUtil.isX11) {
if (!location.equals(actual)) {
- Screenshots.takeScreenshot(getClass(), testName.getMethodName());
+ Screenshots.takeScreenshot(getClass(), testName.getMethodName()); // Bug 528968 This call causes crash on Wayland.
fail("\nExpected:"+location.toString()+" Actual:"+actual.toString());
}
} else {