summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-01-22 03:27:51 +0100
committerSven Gothel <[email protected]>2023-01-22 03:27:51 +0100
commitd509a3d435e8357a6148617d7792f164dbd0b529 (patch)
tree1498bfa90696e26d91f531616440117b6e5f2990 /src/test/com/jogamp
parentb0ac7056205ed423eab9a04417d2e9e6387cc5a0 (diff)
AWTRobot.getClickTimeout(): NEWT Case: Return maximum(AWT, NEWT), otherwise we see click-count 2 on MacOS 12
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus02SwingAWTRobot.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java42
2 files changed, 43 insertions, 18 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus02SwingAWTRobot.java
index 03e5176c5..5d9f4dc17 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus02SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus02SwingAWTRobot.java
@@ -193,13 +193,13 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
// Button Outer Focus
Thread.sleep(100); // allow event sync
- System.err.println("FOCUS AWT Button Outer request");
+ System.err.println("FOCUS AWT Button Outer request.1");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, null); // OSX sporadically buttonNorthOuter did not gain - major UI failure
Assert.assertEquals(false, glWindow1FA.focusGained());
Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
- System.err.println("FOCUS AWT Button Outer sync");
+ System.err.println("FOCUS AWT Button Outer sync.1");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthOuter, buttonNorthOuterKA); // OSX sporadically won't receive the keyboard input - major UI failure
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
buttonNorthOuter, buttonNorthOuterMA);
@@ -208,7 +208,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
// NEWT Focus
Thread.sleep(100); // allow event sync
- System.err.println("FOCUS NEWT Canvas/GLWindow request");
+ System.err.println("FOCUS NEWT Canvas/GLWindow request.2");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA);
// Manually tested on Java7/[Linux,Windows] (where this assertion failed),
@@ -219,13 +219,16 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
System.err.println("Info: Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA);
}
Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
- System.err.println("FOCUS NEWT Canvas/GLWindow sync");
+ System.err.println("FOCUS NEWT Canvas/GLWindow sync.2");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount());
+ System.err.println("FOCUS NEWT Canvas/GLWindow sync.2.2");
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
glWindow1, glWindow1MA);
+ System.err.println("FOCUS NEWT Canvas/GLWindow sync.2.3");
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
glWindow1, glWindow1MA);
+ System.err.println("FOCUS NEWT Canvas/GLWindow sync.2.4");
if( !newtCanvasAWT.isAWTEventPassThrough() ) {
Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount());
Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
@@ -233,13 +236,13 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
// Button Inner Focus
Thread.sleep(100); // allow event sync
- System.err.println("FOCUS AWT Button request");
+ System.err.println("FOCUS AWT Button request.3");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthInner, buttonNorthInner, buttonNorthInnerFA, glWindow1FA);
Assert.assertEquals(false, glWindow1FA.focusGained());
Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
- System.err.println("FOCUS AWT Button sync");
+ System.err.println("FOCUS AWT Button sync.3");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthInner, buttonNorthInnerKA);
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
buttonNorthInner, buttonNorthInnerMA);
@@ -248,7 +251,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
// NEWT Focus
Thread.sleep(100); // allow event sync
- System.err.println("FOCUS NEWT Canvas/GLWindow request");
+ System.err.println("FOCUS NEWT Canvas/GLWindow request.4");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA);
// Manually tested on Java7/[Linux,Windows] (where this assertion failed),
@@ -260,7 +263,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
}
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
- System.err.println("FOCUS NEWT Canvas/GLWindow sync");
+ System.err.println("FOCUS NEWT Canvas/GLWindow sync.4");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount());
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
index cbc969589..9e3521323 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -86,7 +86,11 @@ public class AWTRobotUtil extends TestUtil {
return awtEDTAliveFlag;
}
}
- private static Runnable aliveRun = new Runnable() { public void run() { awtEDTAliveFlag = true; } };
+ private static Runnable aliveRun = new Runnable() {
+ @Override
+ public void run() {
+ awtEDTAliveFlag = true;
+ } };
private static Object awtEDTAliveSync = new Object();
private static volatile boolean awtEDTAliveFlag = false;
@@ -109,6 +113,7 @@ public class AWTRobotUtil extends TestUtil {
robot.setAutoWaitForIdle(true);
}
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
System.err.println("******** clearAWTFocus.0");
java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
@@ -209,6 +214,7 @@ public class AWTRobotUtil extends TestUtil {
do {
final int _wait = wait;
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
if(0==_wait) {
window.setVisible(true);
@@ -262,19 +268,24 @@ public class AWTRobotUtil extends TestUtil {
awtRobotMouseMove(robot, p0[0], p0[1] );
}
+ private static int getAWTClickTimeout() {
+ if(null == AWT_CLICK_TO) {
+ AWT_CLICK_TO =
+ (Integer) java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval");
+ if(null == AWT_CLICK_TO) {
+ AWT_CLICK_TO = new Integer(500);
+ }
+ }
+ return AWT_CLICK_TO.intValue();
+ }
// FIXME: AWTRobotUtil Cleanup: Use specific type for argument object
public static int getClickTimeout(final Object obj) {
if(obj instanceof com.jogamp.newt.Window) {
- return com.jogamp.newt.event.MouseEvent.getClickTimeout();
+ final int newt_to = com.jogamp.newt.event.MouseEvent.getClickTimeout();
+ final int awt_to = getAWTClickTimeout();
+ return Math.max(awt_to, newt_to);
} else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) {
- if(null == AWT_CLICK_TO) {
- AWT_CLICK_TO =
- (Integer) java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval");
- if(null == AWT_CLICK_TO) {
- AWT_CLICK_TO = new Integer(500);
- }
- }
- return AWT_CLICK_TO.intValue();
+ return getAWTClickTimeout();
} else {
throw new RuntimeException("Neither AWT nor NEWT: "+obj);
}
@@ -327,6 +338,7 @@ public class AWTRobotUtil extends TestUtil {
private static void requestFocusAWT(final java.awt.Component comp, final boolean onTitleBarIfWindow)
throws AWTException, InterruptedException, InvocationTargetException {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
comp.requestFocus();
System.err.println("requestFocus: AWT Component");
@@ -748,6 +760,7 @@ public class AWTRobotUtil extends TestUtil {
final java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
final java.awt.EventQueue evtQ = tk.getSystemEventQueue();
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
+ @Override
public void run() {
evtQ.postEvent(new java.awt.event.WindowEvent(win, java.awt.event.WindowEvent.WINDOW_CLOSING));
} });
@@ -757,6 +770,7 @@ public class AWTRobotUtil extends TestUtil {
public static TestUtil.WindowClosingListener addClosingListener(final java.awt.Window win) {
final AWTWindowClosingAdapter acl = new AWTWindowClosingAdapter();
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
+ @Override
public void run() {
win.addWindowListener(acl);
} } );
@@ -768,30 +782,38 @@ public class AWTRobotUtil extends TestUtil {
AtomicInteger closing = new AtomicInteger(0);
AtomicInteger closed = new AtomicInteger(0);
+ @Override
public void reset() {
closing.set(0);
closed.set(0);
}
+ @Override
public int getWindowClosingCount() {
return closing.get();
}
+ @Override
public int getWindowClosedCount() {
return closed.get();
}
+ @Override
public boolean isWindowClosing() {
return 0 < closing.get();
}
+ @Override
public boolean isWindowClosed() {
return 0 < closed.get();
}
+ @Override
public void windowClosing(final java.awt.event.WindowEvent e) {
closing.incrementAndGet();
System.err.println("AWTWindowClosingAdapter.windowClosing: "+this);
}
+ @Override
public void windowClosed(final java.awt.event.WindowEvent e) {
closed.incrementAndGet();
System.err.println("AWTWindowClosingAdapter.windowClosed: "+this);
}
+ @Override
public String toString() {
return "AWTWindowClosingAdapter[closing "+closing+", closed "+closed+"]";
}