diff options
9 files changed, 177 insertions, 26 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java index 9e5a01ebb..d0fbf0788 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java @@ -31,10 +31,10 @@ package com.jogamp.opengl.test.junit.util; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; -public class AWTFocusAdapter implements EventCountAdapter, FocusListener { +public class AWTFocusAdapter implements FocusEventCountAdapter, FocusListener { String prefix; - int focusGained; + boolean focusGained; boolean wasTemporary; public AWTFocusAdapter(String prefix) { @@ -42,13 +42,12 @@ public class AWTFocusAdapter implements EventCountAdapter, FocusListener { reset(); } - /** @return the balance of focus gained/lost, ie should be 0 or 1 */ - public int getCount() { + public boolean hasFocus() { return focusGained; } - + public void reset() { - focusGained = 0; + focusGained = false; wasTemporary = false; } @@ -59,15 +58,17 @@ public class AWTFocusAdapter implements EventCountAdapter, FocusListener { /* @Override */ public void focusGained(FocusEvent e) { - ++focusGained; + focusGained = true; wasTemporary = e.isTemporary(); System.err.println("FOCUS AWT GAINED "+(wasTemporary?"TEMP":"PERM")+" ["+focusGained+"]: "+prefix+", "+e); } /* @Override */ public void focusLost(FocusEvent e) { - --focusGained; + focusGained = false; wasTemporary = e.isTemporary(); System.err.println("FOCUS AWT LOST "+(wasTemporary?"TEMP":"PERM")+" ["+focusGained+"]: "+prefix+", "+e); } + + public String toString() { return prefix+"[gained "+focusGained +", temp "+wasTemporary+"]"; } } 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 ed09ecd8c..6c0156170 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -28,27 +28,47 @@ package com.jogamp.opengl.test.junit.util; -public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements EventCountAdapter { +import java.awt.event.KeyEvent; + +public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements InputEventCountAdapter { String prefix; int keyTyped; + boolean pressed; public AWTKeyAdapter(String prefix) { this.prefix = prefix; reset(); } + public boolean isPressed() { + return pressed; + } + public int getCount() { return keyTyped; } public void reset() { keyTyped = 0; + pressed = false; + } + + public void keyPressed(KeyEvent e) { + pressed = true; + System.err.println("KEY AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } + + public void keyReleased(KeyEvent e) { + pressed = false; + System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e); } public void keyTyped(java.awt.event.KeyEvent e) { ++keyTyped; System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); } + + public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } } 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 7fa201512..b94802348 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -28,26 +28,46 @@ package com.jogamp.opengl.test.junit.util; -public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements EventCountAdapter { +import java.awt.event.MouseEvent; + +public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements InputEventCountAdapter { String prefix; int mouseClicked; + boolean pressed; public AWTMouseAdapter(String prefix) { this.prefix = prefix; reset(); } + public boolean isPressed() { + return pressed; + } + public int getCount() { return mouseClicked; } - + public void reset() { mouseClicked = 0; + pressed = false; } + public void mousePressed(MouseEvent e) { + pressed = true; + System.err.println("MOUSE AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } + + public void mouseReleased(MouseEvent e) { + pressed = false; + System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } + public void mouseClicked(java.awt.event.MouseEvent e) { mouseClicked+=e.getClickCount(); System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); - } + } + + public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java index 105d2503e..76a1884c8 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java @@ -29,8 +29,6 @@ package com.jogamp.opengl.test.junit.util; public interface EventCountAdapter { - - int getCount(); void reset(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java new file mode 100644 index 000000000..b555515b4 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java @@ -0,0 +1,34 @@ +/** + * 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.util; + +public interface FocusEventCountAdapter extends EventCountAdapter { + boolean hasFocus(); +} + diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java new file mode 100644 index 000000000..27f3d7e29 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java @@ -0,0 +1,35 @@ +/** + * 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.util; + +public interface InputEventCountAdapter extends EventCountAdapter { + int getCount(); + boolean isPressed(); +} + diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java index 9ee74aeff..9f710c4a0 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java @@ -28,37 +28,44 @@ package com.jogamp.opengl.test.junit.util; -import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.event.WindowUpdateEvent; -public class NEWTFocusAdapter extends WindowAdapter implements EventCountAdapter { +public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter { String prefix; - int focusGained; + boolean focusGained; public NEWTFocusAdapter(String prefix) { this.prefix = prefix; reset(); } - public int getCount() { + public boolean hasFocus() { return focusGained; } - + public void reset() { - focusGained = 0; + focusGained = false; } - @Override public void windowGainedFocus(WindowEvent e) { - ++focusGained; + focusGained = true; System.err.println("FOCUS NEWT GAINED ["+focusGained+"]: "+prefix+", "+e); } - @Override public void windowLostFocus(WindowEvent e) { - --focusGained; + focusGained = false; System.err.println("FOCUS NEWT LOST ["+focusGained+"]: "+prefix+", "+e); } + + public void windowResized(WindowEvent e) { } + public void windowMoved(WindowEvent e) { } + public void windowDestroyNotify(WindowEvent e) { } + public void windowDestroyed(WindowEvent e) { } + public void windowRepaint(WindowUpdateEvent e) { } + + public String toString() { return prefix+"[gained "+focusGained+"]"; } } 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 ba1a2f3f5..32b392ca8 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -31,28 +31,46 @@ package com.jogamp.opengl.test.junit.util; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; -public class NEWTKeyAdapter extends KeyAdapter implements EventCountAdapter { +public class NEWTKeyAdapter extends KeyAdapter implements InputEventCountAdapter { String prefix; int keyTyped; + boolean pressed; public NEWTKeyAdapter(String prefix) { this.prefix = prefix; reset(); } + public boolean isPressed() { + return pressed; + } + public int getCount() { return keyTyped; } public void reset() { keyTyped = 0; + pressed = false; } + public void keyPressed(KeyEvent e) { + pressed = true; + System.err.println("NEWT AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } + + public void keyReleased(KeyEvent e) { + pressed = false; + System.err.println("NEWT AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } + @Override public void keyTyped(KeyEvent e) { ++keyTyped; System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); } + + public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } } 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 617d951ec..d98b9ca74 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -31,27 +31,45 @@ package com.jogamp.opengl.test.junit.util; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; -public class NEWTMouseAdapter extends MouseAdapter implements EventCountAdapter { +public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAdapter { String prefix; int mouseClicked; + boolean pressed; public NEWTMouseAdapter(String prefix) { this.prefix = prefix; reset(); } + public boolean isPressed() { + return pressed; + } + public int getCount() { return mouseClicked; } public void reset() { mouseClicked = 0; + pressed = false; } + public void mousePressed(MouseEvent e) { + pressed = true; + System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } + + public void mouseReleased(MouseEvent e) { + pressed = false; + System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } + public void mouseClicked(MouseEvent e) { mouseClicked+=e.getClickCount(); System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); } + + public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } } |