aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java0
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java0
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java0
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java3
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java0
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java0
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java0
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java0
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java124
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestTeapotNEWT.java159
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java0
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java0
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java4
-rw-r--r--[-rwxr-xr-x]src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.pngbin4873 -> 4873 bytes
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java97
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java61
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java56
18 files changed, 414 insertions, 104 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
index ea02e930c..ea02e930c 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
index 160dc0ffe..160dc0ffe 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java
index adeb700d7..adeb700d7 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java
index 0b70cf151..2df1d3cb6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java
@@ -57,9 +57,6 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
/**
* Tests using an AWT {@link GLCanvas} {@link GLAutoDrawable auto drawable} for on- and offscreen cases.
- * <p>
- * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}.
- * </p>
*/
public class TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT extends UITestCase {
static final int widthStep = 800/4;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
index 208367102..208367102 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
index 5bbd6737c..5bbd6737c 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
index 7f2713354..7f2713354 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
index e17c9e88b..e17c9e88b 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
new file mode 100644
index 000000000..ae5a0b3ba
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
@@ -0,0 +1,124 @@
+package com.jogamp.opengl.test.junit.jogl.demos.gl2;
+
+import java.net.URLConnection;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.util.gl2.GLUT;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+/**
+ * Adapted from
+ * http://www.java-tips.org/other-api-tips/jogl/how-to-draw-a-texture-mapped-teapot-with-automatically-generated-texture-coordi.html
+ */
+public class Teapot implements GLEventListener {
+
+ private GLUT glut;
+
+ /* glTexGen stuff: */
+ private float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+
+ private Texture tex = null;
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ GL2 gl = drawable.getGL().getGL2();
+ glut = new GLUT();
+
+ gl.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
+
+ try {
+ URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
+ tex = TextureIO.newTexture(gl, TextureIO.newTextureData(gl.getGLProfile(), urlConn.getInputStream(), false, TextureIO.PNG));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ tex.bind(gl);
+
+ // uncomment this and comment the above to see a working texture
+ // makeStripeImage();
+ // gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
+ // gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE,
+ // GL2.GL_MODULATE);
+ // gl.glTexParameterf(GL2.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S,
+ // GL.GL_REPEAT);
+ // gl.glTexParameterf(GL2.GL_TEXTURE_1D, GL.GL_TEXTURE_MAG_FILTER,
+ // GL.GL_LINEAR);
+ // gl.glTexParameterf(GL2.GL_TEXTURE_1D, GL.GL_TEXTURE_MIN_FILTER,
+ // GL.GL_LINEAR);
+ // gl.glTexImage1D(GL2.GL_TEXTURE_1D, 0, 3, stripeImageWidth, 0,
+ // GL.GL_RGB, GL.GL_UNSIGNED_BYTE, stripeImageBuf);
+
+ gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
+
+ // gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
+ // gl.glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, sgenparams, 0);
+
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL.GL_LESS);
+ // gl.glEnable(GL2.GL_TEXTURE_GEN_S);
+ // gl.glEnable(GL2.GL_TEXTURE_1D);
+ gl.glEnable(GL2.GL_TEXTURE_2D);
+ gl.glEnable(GL2.GL_CULL_FACE);
+ gl.glEnable(GL2.GL_LIGHTING);
+ gl.glEnable(GL2.GL_LIGHT0);
+ gl.glEnable(GL2.GL_AUTO_NORMAL);
+ gl.glEnable(GL2.GL_NORMALIZE);
+ gl.glFrontFace(GL.GL_CW);
+ gl.glCullFace(GL.GL_BACK);
+ gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 64.0f);
+ }
+
+ float angleZ = 0.0f;
+ float rotDir = 1.0f;
+ public float rotIncr = 0.4f;
+
+ @Override
+ public void display(GLAutoDrawable gLDrawable) {
+ final GL2 gl = gLDrawable.getGL().getGL2();
+
+ tex.bind(gl);
+ gl.glEnable(GL2.GL_TEXTURE_2D);
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ gl.glPushMatrix();
+ gl.glRotatef(angleZ, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(45.0f, 0.0f, 0.0f, 1.0f);
+ glut.glutSolidTeapot(2.0f);
+ gl.glPopMatrix();
+ gl.glFlush();
+ if( angleZ >= 180.0f ) {
+ rotDir = -1.0f;
+ } else if (angleZ <= 0.0f ) {
+ rotDir = +1.0f;
+ }
+ angleZ += rotIncr * rotDir;
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable gLDrawable, int x, int y, int w, int h) {
+ GL2 gl = gLDrawable.getGL().getGL2();
+
+ gl.glViewport(0, 0, w, h);
+ gl.glMatrixMode(GL2.GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (w <= h) {
+ gl.glOrtho(-3.5, 3.5, -3.5 * (float) h / (float) w,
+ 3.5 * (float) h / (float) w, -3.5, 3.5);
+ } else {
+ gl.glOrtho(-3.5 * (float) w / (float) h,
+ 3.5 * (float) w / (float) h, -3.5, 3.5, -3.5, 3.5);
+ }
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable gLDrawable) {
+ }
+} \ No newline at end of file
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestTeapotNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestTeapotNEWT.java
new file mode 100644
index 000000000..ddde837ab
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestTeapotNEWT.java
@@ -0,0 +1,159 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos.gl2.newt;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Teapot;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+public class TestTeapotNEWT extends UITestCase {
+ static GLProfile glp;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2)) {
+ glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+ width = 640;
+ height = 480;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps, boolean withAnimator) throws InterruptedException {
+ final GLWindow glWindow = GLWindow.create(caps);
+
+ glWindow.setTitle("Teapot NEWT Test");
+ Teapot demo = new Teapot();
+ if( !withAnimator ) {
+ demo.rotIncr *= 10f;
+ }
+ glWindow.addGLEventListener(demo);
+ final SnapshotGLEventListener snap = new SnapshotGLEventListener();
+ glWindow.addGLEventListener(snap);
+
+ final Animator animator = withAnimator ? new Animator(glWindow) : null;
+ final QuitAdapter quitAdapter = new QuitAdapter();
+
+ //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
+ //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+
+ glWindow.setSize(width, height);
+ glWindow.setVisible(true);
+ if( withAnimator ) {
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.start();
+ }
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ int snaps=3;
+ while(!quitAdapter.shouldQuit() && t1-t0<duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ if( snaps-- > 0 ) {
+ snap.setMakeSnapshot();
+ }
+ if( !withAnimator ) {
+ glWindow.display();
+ }
+ }
+
+ if( withAnimator ) {
+ animator.stop();
+ }
+ glWindow.destroy();
+ }
+
+ @Test
+ public void test01_DefCaps_Anim() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+ runTestGL(caps, true);
+ }
+
+ @Test
+ public void test02_DefCaps_NoAnim() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+ runTestGL(caps, false);
+ }
+
+ @Test
+ public void test12_FBOCaps_NoAnim() throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+ caps.setHardwareAccelerated(true);
+ caps.setDoubleBuffered(true);
+ caps.setAlphaBits(8);
+ caps.setDepthBits(8);
+ caps.setNumSamples(0);
+ caps.setSampleBuffers(false);
+ caps.setStencilBits(0);
+ caps.setRedBits(8);
+ caps.setBlueBits(8);
+ caps.setGreenBits(8);
+
+ // caps.setPBuffer(true);
+ caps.setFBO(true);
+
+ runTestGL(caps, false);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestTeapotNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java
index 34b30f04e..34b30f04e 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java
index 717d5e4b8..717d5e4b8 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
index 7106ed7ce..d1b276105 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
@@ -226,8 +226,8 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
{
try {
System.err.println("[K-"+_n+"]");
- AWTRobotUtil.keyPress(_n, _robot, true, KeyEvent.VK_0, 10);
- AWTRobotUtil.keyPress(_n, _robot, false, KeyEvent.VK_0, 0);
+ AWTRobotUtil.newtKeyPress(_n, _robot, true, KeyEvent.VK_0, 10);
+ AWTRobotUtil.newtKeyPress(_n, _robot, false, KeyEvent.VK_0, 0);
Thread.sleep( 40L ) ;
_n++;
if(!_display.isDisposed()) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png
index dac0f13de..dac0f13de 100755..100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png
Binary files differ
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 08a181e10..b075af977 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
@@ -160,81 +160,90 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
}
@SuppressWarnings("deprecation")
- static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask, int keyCode, char keyCharOnly, char keyCharMod) {
+ static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, short modifierKey, int modifierMask, short keyCode,
+ char keyCharOnly, char keyCharMod) {
keyAdapter.reset();
- AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode
- AWTRobotUtil.keyPress(0, robot, false, keyCode, 100); // release+typed keyCode
+ AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode
+ AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release+typed keyCode
robot.waitForIdle();
- for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected
+ for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected
robot.delay(100);
}
- AWTRobotUtil.keyPress(0, robot, true, modifierKey, 10); // press MOD
- AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode
- AWTRobotUtil.keyPress(0, robot, false, keyCode, 10); // release+typed keyCode
- AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release MOD
+ AWTRobotUtil.newtKeyPress(0, robot, true, modifierKey, 10); // press MOD
+ AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode
+ AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release+typed keyCode
+ AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD
robot.waitForIdle();
- for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected
+ for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected
robot.delay(100);
}
- NEWTKeyUtil.validateKeyAdapterStats(keyAdapter,
- 3 /* press-SI */, 3 /* release-SI */, 2 /* typed-SI */,
+ final int modTypedCount = KeyEvent.NULL_CHAR != keyCharMod ? 2 : -1 ; // ignore due to mods 'isPrintable' impact.
+ NEWTKeyUtil.validateKeyAdapterStats(keyAdapter,
+ 3 /* press-SI */, 3 /* release-SI */, modTypedCount /* typed-SI */,
0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ );
- final List<EventObject> queue = keyAdapter.getQueued();
+ final List<EventObject> queue = keyAdapter.getQueued();
int i=0;
NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly);
NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly);
NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, (char)0);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, KeyEvent.NULL_CHAR);
NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod);
NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, (char)0);
+ KeyEvent e = (KeyEvent) queue.get(i++);
+ if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact.
+ NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod);
+ e = (KeyEvent) queue.get(i++);
+ }
+ NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, KeyEvent.NULL_CHAR);
}
@SuppressWarnings("deprecation")
static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) {
- final int m1k = KeyEvent.VK_ALT;
- final int m1m = InputEvent.ALT_MASK;
- final int m2k = KeyEvent.VK_CONTROL;
- final int m2m = InputEvent.CTRL_MASK;
- final int m3k = KeyEvent.VK_SHIFT;
- final int m3m = InputEvent.SHIFT_MASK;
+ final short m1k = KeyEvent.VK_ALT;
+ final int m1m = InputEvent.ALT_MASK;
+ final short m2k = KeyEvent.VK_CONTROL;
+ final int m2m = InputEvent.CTRL_MASK;
+ final short m3k = KeyEvent.VK_SHIFT;
+ final int m3m = InputEvent.SHIFT_MASK;
keyAdapter.reset();
- AWTRobotUtil.keyPress(0, robot, true, m1k, 10); // press MOD1
- AWTRobotUtil.keyPress(0, robot, true, m2k, 10); // press MOD2
- AWTRobotUtil.keyPress(0, robot, true, m3k, 10); // press MOD3
- AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P
+ AWTRobotUtil.newtKeyPress(0, robot, true, m1k, 10); // press MOD1
+ AWTRobotUtil.newtKeyPress(0, robot, true, m2k, 10); // press MOD2
+ AWTRobotUtil.newtKeyPress(0, robot, true, m3k, 10); // press MOD3
+ AWTRobotUtil.newtKeyPress(0, robot, true, KeyEvent.VK_1, 10); // press P
- AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P
- AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release MOD
- AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release MOD
- AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release MOD
+ AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release+typed P
+ AWTRobotUtil.newtKeyPress(0, robot, false, m3k, 10); // release MOD
+ AWTRobotUtil.newtKeyPress(0, robot, false, m2k, 10); // release MOD
+ AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD
robot.waitForIdle();
- for(int j=0; j < 40 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected
+ for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected
robot.delay(100);
}
NEWTKeyUtil.validateKeyAdapterStats(keyAdapter,
- 4 /* press-SI */, 4 /* release-SI */, 1 /* typed-SI */,
- 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ );
+ 4 /* press-SI */, 4 /* release-SI */, -1 /* typed-SI - ignored, since unknow whether printable w/ all mods */,
+ 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ );
final List<EventObject> queue = keyAdapter.getQueued();
int i=0;
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, (char)0);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, (char)0);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, (char)0);
-
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, KeyEvent.NULL_CHAR);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, KeyEvent.NULL_CHAR);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, (char)0);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, (char)0);
- NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, (char)0);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR);
+ KeyEvent e = (KeyEvent) queue.get(i++);
+ if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact.
+ NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR);
+ e = (KeyEvent) queue.get(i++);
+ }
+ NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, KeyEvent.NULL_CHAR);
+ NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, KeyEvent.NULL_CHAR);
}
void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException {
@@ -265,8 +274,8 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase {
testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_1, '1', '!');
testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_Y, 'y', 'Y'); // US: Y, DE: Z
testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_P, 'p', 'P');
- testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_P, 'p', (char)0);
- testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_P, 'p', (char)0);
+ testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_1, '1', KeyEvent.NULL_CHAR);
+ testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_1, '1', KeyEvent.NULL_CHAR);
testKeyCodeAllModifierV1(robot, glWindow1KA);
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 277924477..fb42141ea 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
@@ -155,32 +155,35 @@ public class TestNewtKeyCodesAWT extends UITestCase {
testNewtCanvasAWT_Impl(false);
}
+ /** Almost all keyCodes reachable w/o modifiers [shift, alt, ..] on US keyboard! */
static CodeSeg[] codeSegments = new CodeSeg[] {
- new CodeSeg(0x008, 0x008, "bs"),
- // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key
- new CodeSeg(0x00a, 0x00a, "cr"),
- new CodeSeg(0x010, 0x012, "shift, ctrl, alt"),
- new CodeSeg(0x01B, 0x01B, "esc"),
- new CodeSeg(0x020, 0x024, "space, up, down, end, home"),
- new CodeSeg(0x025, 0x028, "cursor"),
- new CodeSeg(0x02C, 0x02F, ", - . /"),
- new CodeSeg(0x030, 0x039, "0 - 9"),
- new CodeSeg(0x03B, 0x03B, ";"),
- new CodeSeg(0x03D, 0x03D, "="),
- new CodeSeg(0x041, 0x05A, "a - z"),
- new CodeSeg(0x05B, 0x05D, "[ \\ ]"),
- // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes
- // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes
- new CodeSeg(0x07F, 0x07F, "del"),
- // new CodeSeg(0x090, 0x091, "num lock, scroll lock"),
- // new CodeSeg(0x070, 0x07B, "F1 - F12"),
- // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"),
- new CodeSeg(0x0C0, 0x0C0, "back quote"),
- new CodeSeg(0x0DE, 0x0DE, "quote"),
- // new CodeSeg(0x0E0, 0x0E3, "cursor kp"),
- // new CodeSeg(0x080, 0x08F, "dead-1"),
- // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"),
- // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; ..
+ // new CodeSeg(KeyEvent.VK_HOME, KeyEvent.VK_PRINTSCREEN, "home, end, final, prnt"),
+ new CodeSeg(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE, "bs"),
+ // new CodeSeg(KeyEvent.VK_TAB, KeyEvent.VK_TAB, "tab"), // TAB functions as focus traversal key
+ new CodeSeg(KeyEvent.VK_ENTER, KeyEvent.VK_ENTER, "cr"),
+ new CodeSeg(KeyEvent.VK_PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, "pg_down"),
+ new CodeSeg(KeyEvent.VK_SHIFT, KeyEvent.VK_ALT, "shift, pg_up, ctrl, alt"),
+ // new CodeSeg(KeyEvent.VK_ALT_GRAPH, KeyEvent.VK_ALT_GRAPH, "alt_gr"), // AWT Robot produces 0xff7e on X11
+ // new CodeSeg(KeyEvent.VK_SCROLL_LOCK, KeyEvent.VK_SCROLL_LOCK, "scroll lock"),
+ new CodeSeg(KeyEvent.VK_ESCAPE, KeyEvent.VK_ESCAPE, "esc"),
+ new CodeSeg(KeyEvent.VK_SPACE, KeyEvent.VK_SPACE, "space"),
+ new CodeSeg(KeyEvent.VK_QUOTE, KeyEvent.VK_QUOTE, "quote"),
+ new CodeSeg(KeyEvent.VK_COMMA, KeyEvent.VK_SLASH, ", - . /"),
+ new CodeSeg(KeyEvent.VK_0, KeyEvent.VK_9, "0 - 9"),
+ new CodeSeg(KeyEvent.VK_SEMICOLON, KeyEvent.VK_SEMICOLON, ";"),
+ new CodeSeg(KeyEvent.VK_EQUALS, KeyEvent.VK_EQUALS, "="),
+ new CodeSeg(KeyEvent.VK_A, KeyEvent.VK_Z, "a - z"),
+ new CodeSeg(KeyEvent.VK_OPEN_BRACKET, KeyEvent.VK_CLOSE_BRACKET, "[ \\ ]"),
+ new CodeSeg(KeyEvent.VK_BACK_QUOTE, KeyEvent.VK_BACK_QUOTE, "`"),
+ new CodeSeg(KeyEvent.VK_F1, KeyEvent.VK_F8, "f1..f8"),
+ // new CodeSeg(KeyEvent.VK_F1, KeyEvent.VK_F12, "f1..f12"), // f9-f12 may cause some odd desktop functions!
+ new CodeSeg(KeyEvent.VK_DELETE, KeyEvent.VK_DELETE, "del"),
+ // new CodeSeg(KeyEvent.VK_NUMPAD0, KeyEvent.VK_NUMPAD9, "numpad0-9"), // can be mapped to normal keycodes
+ // new CodeSeg(KeyEvent.VK_DECIMAL, KeyEvent.VK_DIVIDE, "numpad ops"), // can be mapped to normal keycodes
+ // new CodeSeg(KeyEvent.VK_NUM_LOCK, KeyEvent.VK_NUM_LOCK, "num lock"),
+ // new CodeSeg(KeyEvent.VK_KP_LEFT, KeyEvent.VK_KP_DOWN, "numpad cursor arrows"),
+ new CodeSeg(KeyEvent.VK_LEFT, KeyEvent.VK_DOWN, "cursor arrows"),
+ // new CodeSeg(KeyEvent.VK_WINDOWS, KeyEvent.VK_HELP, "windows, meta, hlp"),
};
static void testKeyCodes(Robot robot, NEWTKeyAdapter keyAdapter) {
@@ -191,23 +194,23 @@ public class TestNewtKeyCodesAWT extends UITestCase {
final CodeSeg codeSeg = codeSegments[i];
// System.err.println("*** Segment "+codeSeg.description);
int eventCount = 0;
- for(short c=codeSeg.min; c<=codeSeg.max; c++) {
+ for(short c=codeSeg.min; c<=codeSeg.max; c++) {
// System.err.println("*** KeyCode 0x"+Integer.toHexString(c));
try {
- AWTRobotUtil.keyPress(0, robot, true, c, 10);
+ AWTRobotUtil.newtKeyPress(0, robot, true, c, 10);
} catch (Exception e) {
System.err.println("Exception @ AWT Robot.PRESS "+MiscUtils.toHexString(c)+" - "+e.getMessage());
break;
}
eventCount++;
try {
- AWTRobotUtil.keyPress(0, robot, false, c, 100);
+ AWTRobotUtil.newtKeyPress(0, robot, false, c, 100);
} catch (Exception e) {
System.err.println("Exception @ AWT Robot.RELEASE "+MiscUtils.toHexString(c)+" - "+e.getMessage());
break;
}
eventCount++;
- if( KeyEvent.isPrintableKey(c) ) {
+ if( KeyEvent.isPrintableKey(c, false) ) {
eventCount++;
}
robot.waitForIdle();
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 4195711d6..e128123ed 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -29,6 +29,7 @@
package com.jogamp.opengl.test.junit.util;
import jogamp.newt.WindowImplAccess;
+import jogamp.newt.awt.event.AWTNewtEventFactory;
import java.lang.reflect.InvocationTargetException;
import java.awt.AWTException;
@@ -449,6 +450,19 @@ public class AWTRobotUtil {
return (int) ( System.currentTimeMillis() - t0 ) ;
}
+ /** No validation is performed .. */
+ public static int newtKeyPress(int i, Robot robot, boolean press, short newtKeyCode, int msDelay) {
+ final int keyCode = AWTNewtEventFactory.newtKeyCode2AWTKeyCode(newtKeyCode);
+ final long t0 = System.currentTimeMillis();
+ if(press) {
+ awtRobotKeyPress(robot, keyCode, msDelay);
+ } else {
+ awtRobotKeyRelease(robot, keyCode, msDelay);
+ }
+
+ return (int) ( System.currentTimeMillis() - t0 ) ;
+ }
+
/**
* @param keyCode TODO
* @param counter shall return the number of keys typed (press + release)
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 d007d2424..1def57edf 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java
@@ -104,7 +104,7 @@ public class NEWTKeyUtil {
missCodes.add(new CodeEvent(c, codeSeg.description, e));
misses++;
}
- if( KeyEvent.isPrintableKey(c) ) {
+ if( KeyEvent.isPrintableKey(c, false) ) {
evtIdx += 3; // w/ TYPED
} else {
evtIdx += 2;
@@ -118,17 +118,17 @@ public class NEWTKeyUtil {
return res;
}
- public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode, char keyChar) {
+ public static void validateKeyEvent(KeyEvent e, short eventType, int modifiers, short keyCode, char keyChar) {
if(0 <= eventType) {
Assert.assertTrue("KeyEvent type mismatch, expected 0x"+Integer.toHexString(eventType)+", has "+e, eventType == e.getEventType());
}
- if(0 <= modifier) {
- Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifier)+", has "+e, modifier == e.getModifiers());
+ if(0 <= modifiers) {
+ Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifiers)+", has "+e, modifiers == e.getModifiers());
}
- if(0 < keyCode) {
+ if(KeyEvent.VK_UNDEFINED != keyCode) {
Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode());
}
- if(0 < keyChar) {
+ if(KeyEvent.NULL_CHAR != keyChar) {
Assert.assertTrue("KeyEvent char mismatch, expected 0x"+Integer.toHexString(keyChar)+", has "+e, keyChar == e.getKeyChar());
}
}
@@ -168,17 +168,17 @@ public class NEWTKeyUtil {
* @param keyAdapter
* @param expPressedCountSI number of single key press events
* @param expReleasedCountSI number of single key release events
- * @param expTypedCountSI number of single key types events
+ * @param expTypedCountSI number of single key types events, set to -1 to ignore
* @param expPressedCountAR number of auto-repeat key press events
* @param expReleasedCountAR number of auto-repeat key release events
- * @param expTypedCountAR number of auto-repeat key types events
+ * @param expTypedCountAR number of auto-repeat key types events, set to -1 to ignore
*/
public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter,
int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI,
int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) {
- final int expTotalCountSI = expPressedCountSI + expReleasedCountSI + expTypedCountSI;
- final int expTotalCountAR = expPressedCountAR + expReleasedCountAR + expTypedCountAR;
- final int expTotalCountALL = expTotalCountSI + expTotalCountAR;
+ final int expPressReleaseCountSI = expPressedCountSI + expReleasedCountSI;
+ final int expPressReleaseCountAR = expPressedCountAR + expReleasedCountAR;
+ final int expPressReleaseCountALL = expPressReleaseCountSI + expPressReleaseCountAR;
final int keyPressedALL = keyAdapter.getKeyPressedCount(false);
final int keyPressedAR = keyAdapter.getKeyPressedCount(true);
@@ -191,35 +191,39 @@ public class NEWTKeyUtil {
final int keyReleasedSI = keyReleasedALL-keyReleasedAR;
final int keyTypedSI = keyTypedALL-keyTypedAR;
- final int totalCountALL = keyPressedALL + keyReleasedALL + keyTypedALL;
- final int totalCountSI = keyPressedSI + keyReleasedSI + keyTypedSI;
- final int totalCountAR = keyPressedAR + keyReleasedAR + keyTypedAR;
+ final int pressReleaseCountALL = keyPressedALL + keyReleasedALL;
+ final int pressReleaseCountSI = keyPressedSI + keyReleasedSI;
+ final int pressReleaseCountAR = keyPressedAR + keyReleasedAR;
- System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI +", Events "+expTotalCountSI);
- System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR +", Events "+expTotalCountAR);
+ System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI);
+ System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR);
- System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+totalCountSI);
- System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+totalCountAR);
- System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+totalCountALL);
+ System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+pressReleaseCountSI);
+ System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+pressReleaseCountAR);
+ System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+pressReleaseCountALL);
- Assert.assertEquals("Internal Error: totalSI != totalALL - totalAR", totalCountSI, totalCountALL - totalCountAR);
+ Assert.assertEquals("Internal Error: pressReleaseSI != pressReleaseALL - pressReleaseAR", pressReleaseCountSI, pressReleaseCountALL - pressReleaseCountAR);
Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR);
- Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR);
+ if( 0 <= expTypedCountAR ) {
+ Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR);
+ }
Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI);
Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI);
- Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI);
+ if( 0 <= expTypedCountSI ) {
+ Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI);
+ }
Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR);
Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR);
- Assert.assertEquals("Key total count failure (SI)", expTotalCountSI, totalCountSI);
- Assert.assertEquals("Key total count failure (AR)", expTotalCountAR, totalCountAR);
+ Assert.assertEquals("Key pressRelease count failure (SI)", expPressReleaseCountSI, pressReleaseCountSI);
+ Assert.assertEquals("Key pressRelease count failure (AR)", expPressReleaseCountAR, pressReleaseCountAR);
final List<EventObject> keyEvents = keyAdapter.getQueued();
- Assert.assertEquals("Key total count failure (ALL) w/ list sum ", expTotalCountALL, totalCountALL);
- Assert.assertEquals("Key total count failure (ALL) w/ list size ", expTotalCountALL, keyEvents.size());
+ Assert.assertEquals("Key pressRelease count failure (ALL) w/ list sum ", expPressReleaseCountALL, pressReleaseCountALL);
+ Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL + keyTypedALL, keyEvents.size());
}
}