keyEvents = keyAdapter.getQueued();
NEWTKeyUtil.validateKeyEventOrder(keyEvents);
final boolean hasAR = 0 < keyAdapter.getKeyPressedCount(true) ;
- Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3);
- final int expTotal = keyEvents.size()/3;
- final int expAR = hasAR ? expTotal - loops - loops : 0;
- NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR);
+ {
+ final int expTotal = keyEvents.size();
+ final int expAR = hasAR ? expTotal - 3 * 2 * loops : 0; // per loop: 3 for non AR events and 3 for non AR 'B'
+ NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR);
+ }
if( !hasAR ) {
System.err.println("No AUTO-REPEAT triggered by AWT Robot .. aborting test analysis");
@@ -266,7 +271,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase {
Thread.sleep(durationPerTest); // manual testing
AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic
- AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
+ AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
glWindow1KA.reset();
//
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java
index 11f552ecb..cf5016173 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java
@@ -56,7 +56,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.*;
/**
- * Testing key event order incl. auto-repeat (Bug 601)
+ * Testing key event order excl. auto-repeat (Bug 601)
*
*
* Note Event order:
@@ -167,7 +167,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
NEWTKeyUtil.validateKeyEventOrder(keyAdapter.getQueued());
- NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 6*loops, 0);
+ NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 6*3*loops, 0);
}
void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException {
@@ -191,7 +191,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase {
Thread.sleep(durationPerTest); // manual testing
AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic
- AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
+ AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
glWindow1KA.reset();
//
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java
index 6ebaf2707..c27513905 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java
@@ -151,7 +151,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase {
Thread.sleep(durationPerTest); // manual testing
AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic
- AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
+ AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
// Remove listeners to avoid logging during dispose/destroy.
glWindow.removeKeyListener(simpleKeyPressRelease);
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java
index a9fa373b5..837ba5da1 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java
@@ -46,33 +46,37 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
reset();
}
- public void setVerbose(boolean v) { verbose = false; }
+ public synchronized void setVerbose(boolean v) { verbose = false; }
- public boolean isPressed() {
+ public synchronized boolean isPressed() {
return pressed;
}
- public int getCount() {
+ public synchronized int getCount() {
return keyTyped;
}
- public int getKeyPressedCount(boolean autoRepeatOnly) {
+ public synchronized int getKeyPressedCount(boolean autoRepeatOnly) {
return keyPressed;
}
- public int getKeyReleasedCount(boolean autoRepeatOnly) {
+ public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) {
return keyReleased;
}
- public int getKeyTypedCount(boolean autoRepeatOnly) {
+ public synchronized int getKeyTypedCount(boolean autoRepeatOnly) {
return keyTyped;
}
- public List getQueued() {
+ public synchronized List getQueued() {
return queue;
}
- public void reset() {
+ public synchronized int getQueueSize() {
+ return queue.size();
+ }
+
+ public synchronized void reset() {
keyTyped = 0;
keyPressed = 0;
keyReleased = 0;
@@ -80,7 +84,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
queue.clear();
}
- public void keyPressed(KeyEvent e) {
+ public synchronized void keyPressed(KeyEvent e) {
pressed = true;
keyPressed++;
queue.add(e);
@@ -89,7 +93,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
}
}
- public void keyReleased(KeyEvent e) {
+ public synchronized void keyReleased(KeyEvent e) {
pressed = false;
keyReleased++;
queue.add(e);
@@ -98,7 +102,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
}
}
- public void keyTyped(java.awt.event.KeyEvent e) {
+ public synchronized void keyTyped(java.awt.event.KeyEvent e) {
keyTyped++;
queue.add(e);
if( verbose ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java
index 3334f18ea..31362bfa1 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java
@@ -45,27 +45,31 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu
reset();
}
- public void setVerbose(boolean v) { verbose = false; }
+ public synchronized void setVerbose(boolean v) { verbose = false; }
- public boolean isPressed() {
+ public synchronized boolean isPressed() {
return pressed;
}
- public int getCount() {
+ public synchronized int getCount() {
return mouseClicked;
}
- public List getQueued() {
+ public synchronized List getQueued() {
return queue;
}
- public void reset() {
+ public synchronized int getQueueSize() {
+ return queue.size();
+ }
+
+ public synchronized void reset() {
mouseClicked = 0;
pressed = false;
queue.clear();
}
- public void mousePressed(MouseEvent e) {
+ public synchronized void mousePressed(MouseEvent e) {
pressed = true;
queue.add(e);
if( verbose ) {
@@ -73,7 +77,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu
}
}
- public void mouseReleased(MouseEvent e) {
+ public synchronized void mouseReleased(MouseEvent e) {
pressed = false;
queue.add(e);
if( verbose ) {
@@ -81,7 +85,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu
}
}
- public void mouseClicked(java.awt.event.MouseEvent e) {
+ public synchronized void mouseClicked(java.awt.event.MouseEvent e) {
mouseClicked+=e.getClickCount();
queue.add(e);
if( verbose ) {
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 f48033ae0..e64b3208e 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -196,10 +196,20 @@ public class AWTRobotUtil {
/**
* requestFocus, if robot is valid, use mouse operation,
- * otherwise programatic, ie call requestFocus
+ * otherwise programmatic, ie call requestFocus
*/
public static void requestFocus(Robot robot, Object obj)
throws AWTException, InterruptedException, InvocationTargetException {
+ requestFocus(robot, obj, true);
+ }
+
+ /**
+ * requestFocus, if robot is valid, use mouse operation,
+ * otherwise programmatic, ie call requestFocus
+ */
+ public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow)
+ throws AWTException, InterruptedException, InvocationTargetException {
+
final Component comp;
final com.jogamp.newt.Window win;
@@ -226,7 +236,7 @@ public class AWTRobotUtil {
}
} else {
final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
- centerMouse(robot, obj, true);
+ centerMouse(robot, obj, onTitleBarIfWindow);
robot.waitForIdle();
robot.mousePress(mouseButton);
diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java
index ed7485951..c4078436f 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java
@@ -35,6 +35,7 @@ public interface InputEventCountAdapter extends EventCountAdapter {
int getCount();
boolean isPressed();
- public List getQueued();
+ public List getQueued();
+ public int getQueueSize();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
index 42235254a..f19169b42 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
@@ -50,33 +50,37 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
reset();
}
- public void setVerbose(boolean v) { verbose = false; }
+ public synchronized void setVerbose(boolean v) { verbose = false; }
- public boolean isPressed() {
+ public synchronized boolean isPressed() {
return pressed;
}
- public int getCount() {
+ public synchronized int getCount() {
return keyTyped;
}
- public int getKeyPressedCount(boolean autoRepeatOnly) {
+ public synchronized int getKeyPressedCount(boolean autoRepeatOnly) {
return autoRepeatOnly ? keyPressedAR: keyPressed;
}
- public int getKeyReleasedCount(boolean autoRepeatOnly) {
+ public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) {
return autoRepeatOnly ? keyReleasedAR: keyReleased;
}
- public int getKeyTypedCount(boolean autoRepeatOnly) {
+ public synchronized int getKeyTypedCount(boolean autoRepeatOnly) {
return autoRepeatOnly ? keyTypedAR: keyTyped;
}
- public List getQueued() {
+ public synchronized List getQueued() {
return queue;
}
- public void reset() {
+ public synchronized int getQueueSize() {
+ return queue.size();
+ }
+
+ public synchronized void reset() {
keyTyped = 0;
keyPressed = 0;
keyReleased = 0;
@@ -87,7 +91,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
queue.clear();
}
- public void keyPressed(KeyEvent e) {
+ public synchronized void keyPressed(KeyEvent e) {
pressed = true;
keyPressed++;
if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) {
@@ -99,7 +103,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
}
}
- public void keyReleased(KeyEvent e) {
+ public synchronized void keyReleased(KeyEvent e) {
pressed = false;
keyReleased++;
if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) {
@@ -112,7 +116,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
}
@Override
- public void keyTyped(KeyEvent e) {
+ public synchronized void keyTyped(KeyEvent e) {
keyTyped++;
if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) {
keyTypedAR++;
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java
index 95818845e..e090ed4cf 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java
@@ -62,14 +62,14 @@ public class NEWTKeyUtil {
return "Code 0x"+Integer.toHexString(code)+" != "+event+" // "+description;
}
}
-
+
public static void dumpKeyEvents(List keyEvents) {
for(int i=0; i> keyEventsList, boolean verbose) {
+
+ public static boolean validateKeyCodes(CodeSeg[] codeSegments, List> keyEventsList, boolean verbose) {
final List missCodes = new ArrayList();
int totalCodeCount = 0;
boolean res = true;
@@ -77,7 +77,7 @@ public class NEWTKeyUtil {
final CodeSeg codeSeg = codeSegments[i];
totalCodeCount += codeSeg.max - codeSeg.min + 1;
final List keyEvents = keyEventsList.get(i);
- res &= validateKeyCode(missCodes, codeSeg, keyEvents, verbose);
+ res &= validateKeyCodes(missCodes, codeSeg, keyEvents, verbose);
}
if(verbose) {
System.err.println("*** Total KeyCode Misses "+missCodes.size()+" / "+totalCodeCount+", valid "+res);
@@ -87,7 +87,7 @@ public class NEWTKeyUtil {
}
return res;
}
- public static boolean validateKeyCode(List missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) {
+ public static boolean validateKeyCodes(List missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) {
final int codeCount = codeSeg.max - codeSeg.min + 1;
int misses = 0;
for(int i=0; i keyEvents = keyAdapter.getQueued();
Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3);
- Assert.assertEquals("Key event count not 3 * press_release_count", 3*expTotalCount, keyEvents.size());
- Assert.assertEquals("Key press count failure", expTotalCount, keyPressed);
- Assert.assertEquals("Key press count failure (AR)", expARCount, keyPressedAR);
- Assert.assertEquals("Key released count failure", expTotalCount, keyReleased);
- Assert.assertEquals("Key released count failure (AR)", expARCount, keyReleasedAR);
- Assert.assertEquals("Key typed count failure", expTotalCount, keyTyped);
- Assert.assertEquals("Key typed count failure (AR)", expARCount, keyTypedAR);
+ Assert.assertEquals("Key event count not 3 * press_release_count", expTotalCount, keyEvents.size());
+ Assert.assertEquals("Key press count failure", expTotalCount/3, keyPressed);
+ Assert.assertEquals("Key press count failure (AR)", expARCount/3, keyPressedAR);
+ Assert.assertEquals("Key released count failure", expTotalCount/3, keyReleased);
+ Assert.assertEquals("Key released count failure (AR)", expARCount/3, keyReleasedAR);
+ Assert.assertEquals("Key typed count failure", expTotalCount/3, keyTyped);
+ Assert.assertEquals("Key typed count failure (AR)", expARCount/3, keyTypedAR);
// should be true - always, reaching this point - duh!
- Assert.assertEquals(expTotalCount-expARCount, keyPressedNR);
- Assert.assertEquals(expTotalCount-expARCount, keyReleasedNR);
- Assert.assertEquals(expTotalCount-expARCount, keyTypedNR);
+ Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyPressedNR);
+ Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyReleasedNR);
+ Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyTypedNR);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java
index c77462884..644523782 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java
@@ -48,27 +48,31 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
reset();
}
- public void setVerbose(boolean v) { verbose = false; }
+ public synchronized void setVerbose(boolean v) { verbose = false; }
- public boolean isPressed() {
+ public synchronized boolean isPressed() {
return pressed;
}
- public int getCount() {
+ public synchronized int getCount() {
return mouseClicked;
}
- public List getQueued() {
+ public synchronized List getQueued() {
return queue;
}
- public void reset() {
+ public synchronized int getQueueSize() {
+ return queue.size();
+ }
+
+ public synchronized void reset() {
mouseClicked = 0;
pressed = false;
queue.clear();
}
- public void mousePressed(MouseEvent e) {
+ public synchronized void mousePressed(MouseEvent e) {
pressed = true;
queue.add(e);
if( verbose ) {
@@ -76,7 +80,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
}
}
- public void mouseReleased(MouseEvent e) {
+ public synchronized void mouseReleased(MouseEvent e) {
pressed = false;
queue.add(e);
if( verbose ) {
@@ -84,7 +88,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
}
}
- public void mouseClicked(MouseEvent e) {
+ public synchronized void mouseClicked(MouseEvent e) {
mouseClicked+=e.getClickCount();
queue.add(e);
if( verbose ) {
--
cgit v1.2.3