aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java24
5 files changed, 26 insertions, 22 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java
index c1b572df3..19d739a75 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java
@@ -164,7 +164,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
keyAdapter.reset();
AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode
AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release keyCode
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2; j++) { // wait until events are collected
robot.delay(100);
}
@@ -173,7 +173,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode
AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release keyCode
AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2+4; j++) { // wait until events are collected
robot.delay(100);
}
@@ -212,7 +212,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
AWTRobotUtil.newtKeyPress(0, robot, false, m2k, 10); // release MOD
AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4; j++) { // wait until events are collected
robot.delay(100);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java
index a5f47e870..e1254ae6d 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java
@@ -210,7 +210,7 @@ public class TestNewtKeyCodesAWT extends UITestCase {
break;
}
eventCount++;
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
}
for(int j=0; j < 20 && keyAdapter.getQueueSize() < eventCount; j++) { // wait until events are collected
robot.delay(100);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java
index b6c15231c..508ad2cbf 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java
@@ -162,9 +162,9 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
for(int i=0; i<loops; i++) {
System.err.println("+++ KEY Event Auto-Repeat START Input Loop: "+i);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, pressDurationMS);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 500); // 1s .. no AR anymore
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
final int minCodeCount = firstIdx + 2;
final int desiredCodeCount = firstIdx + 4;
for(int j=0; j < 10 && keyAdapter.getQueueSize() < desiredCodeCount; j++) { // wait until events are collected
@@ -183,9 +183,9 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
// add a pair of normal press/release in between auto-repeat!
firstIdx = keyEvents.size();
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
for(int j=0; j < 20 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected
robot.delay(100);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java
index 3a95eacae..961b4969e 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java
@@ -165,23 +165,23 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
// 1
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 100);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
// 2
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 100);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
// 3 + 4
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 10);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
// 5 + 6
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, 10);
AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 10);
AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 10);
- robot.waitForIdle();
+ AWTRobotUtil.waitForIdle(robot);
}
robot.delay(250);
// dumpKeyEvents(keyAdapter.getQueued());
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 8a73d3363..49c56bee1 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -74,6 +74,7 @@ public class AWTRobotUtil {
// System.err.println("AWT EDT alive: "+isAWTEDTAlive());
}
+ /** Probes whether AWT's EDT is alive or not. */
public static boolean isAWTEDTAlive() {
if( EventQueue.isDispatchThread() ) {
return true;
@@ -96,12 +97,19 @@ public class AWTRobotUtil {
return awtEDTAliveFlag;
}
}
+ /** Throws Error if {@link #isAWTEDTAlive()} returns false. */
public static void validateAWTEDTIsAlive() {
if( !isAWTEDTAlive() ) {
throw new Error("AWT EDT not alive");
}
}
+ /** Issuing {@link #validateAWTEDTIsAlive()} before calling {@link Robot#waitForIdle()}. */
+ public static void waitForIdle(Robot robot) {
+ validateAWTEDTIsAlive();
+ robot.waitForIdle();
+ }
+
public static void clearAWTFocus(Robot robot) throws InterruptedException, InvocationTargetException, AWTException {
if(null == robot) {
robot = new Robot();
@@ -293,8 +301,7 @@ public class AWTRobotUtil {
final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
centerMouse(robot, obj, onTitleBarIfWindow);
- validateAWTEDTIsAlive();
- robot.waitForIdle();
+ waitForIdle(robot);
robot.mousePress(mouseButton);
robot.mouseRelease(mouseButton);
final int d = getClickTimeout(obj) + 1;
@@ -443,18 +450,16 @@ public class AWTRobotUtil {
}
private static void awtRobotKeyPress(final Robot robot, final int keyCode, final int msDelay) {
- validateAWTEDTIsAlive();
- robot.waitForIdle();
+ waitForIdle(robot);
robot.keyPress(keyCode);
robot.delay(msDelay);
- robot.waitForIdle();
+ waitForIdle(robot);
}
private static void awtRobotKeyRelease(final Robot robot, final int keyCode, final int msDelay) {
- validateAWTEDTIsAlive();
- robot.waitForIdle();
+ waitForIdle(robot);
robot.keyRelease(keyCode);
robot.delay(msDelay);
- robot.waitForIdle();
+ waitForIdle(robot);
}
public static int keyType(int i, Robot robot, int keyCode,
@@ -592,8 +597,7 @@ public class AWTRobotUtil {
}
final int c0 = null != counter ? counter.getCount() : 0;
if(DEBUG) { System.err.println(i+":"+j+" MC1.1: "+counter); }
- validateAWTEDTIsAlive();
- robot.waitForIdle();
+ waitForIdle(robot);
robot.mousePress(mouseButton);
robot.mouseRelease(mouseButton);
if(DEBUG) { System.err.println(i+":"+j+" MC1.2: "+counter); }