aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-08 04:55:02 +0100
committerSven Gothel <[email protected]>2019-12-08 04:55:02 +0100
commit2e59792eba285d7cd3c2f4f4c78838b8cc8918f7 (patch)
tree187d20f6ca9599f173b65efecdc40020c8820913 /src/test/com/jogamp
parentbb3ee12b7aeef276a03f091333eacc68542e784b (diff)
Bug 1393: Make window position check more tolerant (2x insets or 64 pixels, whichever is greater)
Certain WM's may modify the windowing position 'a little', which has been experienced on one X11 server during invisible setting. The insets were removed and its value added to the position! We could argue that this is an issue in our windowing code, however, the WM is free to reposition a window. Refines commit b8db98376069a72ad40b7ef2fe2d9003aea2b091
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NewtTestUtil.java25
3 files changed, 33 insertions, 14 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
index a9d38d98c..a7a822647 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
@@ -45,6 +45,7 @@ import java.io.IOException;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.NewtTestUtil;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -110,8 +111,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertNotNull(window.getScreen());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
// lazy native creation sequence: Display, Screen and Window
Assert.assertEquals(0, window.getTotalFPSFrames());
@@ -126,8 +126,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames());
Assert.assertTrue(0 < window.getTotalFPSFrames());
@@ -141,8 +140,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
window.setVisible(false);
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
// just make the Window visible again
window.resetFPSCounter();
@@ -150,8 +148,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
window.setVisible(true);
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames());
Assert.assertTrue(0 < window.getTotalFPSFrames());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
index 97a56ab2a..1ba8686e7 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
@@ -100,8 +100,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
// lazy native creation sequence: Display, Screen and Window
Assert.assertEquals(0, window.getTotalFPSFrames());
@@ -117,8 +116,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames());
Assert.assertTrue(0 < window.getTotalFPSFrames());
@@ -142,8 +140,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
window.setVisible(true);
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(xy_pos,window.getX());
- Assert.assertEquals(xy_pos,window.getY());
+ Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
System.err.println("Frames for setVisible(true) 1: "+window.getTotalFPSFrames());
Assert.assertTrue(0 < window.getTotalFPSFrames());
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NewtTestUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NewtTestUtil.java
index 295690f8a..9ee63dcf8 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NewtTestUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NewtTestUtil.java
@@ -31,6 +31,7 @@ package com.jogamp.opengl.test.junit.util;
import java.util.concurrent.atomic.AtomicInteger;
+import com.jogamp.nativewindow.util.InsetsImmutable;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.WindowEvent;
@@ -200,6 +201,30 @@ public class NewtTestUtil extends TestUtil {
WindowImplAccess.windowDestroyNotify(win);
return waitUntilClosed(willClose, closingListener, waitAction);
}
+
+ /**
+ * Validates whether the window position is on the given position within tolerances.
+ * <p>
+ * Since WM may not obey our positional request exactly, we allow a tolerance of 2 times insets[left/top], or 64 pixels, whichever is greater.
+ * </p>
+ */
+ public static boolean hasPositionMax2xInsetsOr64Pix(final Window win, final int shouldX, final int shouldY) {
+ final int maxDX, maxDY;
+ {
+ final InsetsImmutable insets = win.getInsets();
+ maxDX = Math.max(64, insets.getLeftWidth() * 2);
+ maxDY = Math.max(64, insets.getTopHeight() * 2);
+ }
+ return hasPosition(win, shouldX, shouldY, maxDX, maxDY);
+ }
+ /**
+ * Validates whether the window position is on the given position within the given tolerances.
+ */
+ public static boolean hasPosition(final Window win, final int shouldX, final int shouldY, final int maxDX, final int maxDY) {
+ final boolean ok = Math.abs(shouldX - win.getX()) <= maxDX &&
+ Math.abs(shouldY - win.getY()) <= maxDY ;
+ return ok;
+ }
}