diff options
author | Sven Gothel <[email protected]> | 2012-12-23 23:33:19 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-12-23 23:33:19 +0100 |
commit | 7ec58d773535e86e413e3c581a5e5bd734cb1269 (patch) | |
tree | ae203b875be32f58de6e2e02f690219e3d122104 /src/test/com/jogamp | |
parent | 13168c99ff9e8bf71c83f1be7afee270a3db4074 (diff) |
Fix 13168c99ff9e8bf71c83f1be7afee270a3db4074 / 811e3791b98fea0dfa3b7d301cb532c54df8dc82: AWT-NEWT Modifier mapping - part-2
AWTNewtEventFactory:
- getAWTButtonMask() -> getAWTButtonDownMask()
- using proper _DOWN_MASK values (regression of commit 13168c99ff9e8bf71c83f1be7afee270a3db4074)
- com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER buttons
- adding 'ModifierMappings.txt' to API doc header
- remove obsolete 'int awtModifiers2Newt(int awtMods, boolean mouseHint)'
- 'int awtButton2Newt(int awtButton)' 1:1 button name mapping
Tests:
- rename TestNewtEventModifiers -> BaseNewtEventModifiers
to avoid being picked up by our junit testing framework.
The latter tests all classes starting w/ 'Test*'
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java) | 75 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt | 37 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java | 6 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java | 6 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java | 6 |
5 files changed, 36 insertions, 94 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 81e1939b9..1dfdc4021 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -44,6 +44,8 @@ import org.junit.Before ; import org.junit.BeforeClass ; import org.junit.Test ; +import com.jogamp.common.os.Platform; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.test.junit.util.UITestCase ; /** @@ -52,7 +54,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase ; * and canvas up to subclasses. */ -public abstract class TestNewtEventModifiers extends UITestCase { +public abstract class BaseNewtEventModifiers extends UITestCase { static { @@ -162,9 +164,12 @@ public abstract class TestNewtEventModifiers extends UITestCase { if( _debug ) { _debugPrintStream.println( ", checking modifiers..." ) ; _debugPrintStream.println( " expected NEWT Modifiers:" ) ; - _printModifiers( _expectedModifiers ) ; + { + final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); + _debugPrintStream.println(" "+exp.getModifiersString(null).toString()); + } _debugPrintStream.println( " current NEWT Modifiers:" ) ; - _printModifiers( event.getModifiers() ) ; + _debugPrintStream.println(" "+event.getModifiersString(null).toString()); } _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; @@ -195,44 +200,17 @@ public abstract class TestNewtEventModifiers extends UITestCase { } if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { - _failures.add( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + StringBuilder sb = new StringBuilder(); + sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ).append(": "); + final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); + sb.append("Expected:").append(Platform.NEWLINE); + exp.getModifiersString(sb).append(Platform.NEWLINE); + sb.append(", Have: ").append(Platform.NEWLINE); + event.getModifiersString(sb).append(Platform.NEWLINE); + _failures.add( sb.toString() ) ; } } - private void _printModifiers( int modifiers ) { - if( ( modifiers & com.jogamp.newt.event.InputEvent.SHIFT_MASK ) != 0 ) { _debugPrintStream.println( " SHIFT" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.CTRL_MASK ) != 0 ) { _debugPrintStream.println( " CTRL" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.META_MASK ) != 0 ) { _debugPrintStream.println( " META" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_MASK ) != 0 ) { _debugPrintStream.println( " ALT" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { _debugPrintStream.println( " ALT_GRAPH" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON1_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON1" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON2_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON2" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON3_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON3" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON4_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON4" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON5_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON5" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON6_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON6" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON7_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON7" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON8_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON8" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON9_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON9" ) ; } - } - - private static void _printAwtModifiers( int awtMods, int awtModsEx ) { - if( ( awtMods & java.awt.event.InputEvent.SHIFT_MASK ) != 0 ) { System.err.println( "SHIFT" ) ; } - if( ( awtMods & java.awt.event.InputEvent.CTRL_MASK ) != 0 ) { System.err.println( "CTRL" ) ; } - if( ( awtMods & java.awt.event.InputEvent.META_MASK ) != 0 ) { System.err.println( "META" ) ; } - if( ( awtMods & java.awt.event.InputEvent.ALT_MASK ) != 0 ) { System.err.println( "ALT" ) ; } - if( ( awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { System.err.println( "ALT_GRAPH" ) ; } - - if( ( awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { System.err.println( "SHIFT Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { System.err.println( "CTRL Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { System.err.println( "META Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { System.err.println( "ALT Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { System.err.println( "ALT_GRAPH Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON1" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON2_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON2" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON3_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON3" ) ; } - } - public ArrayList<String> getFailures() { return _failures ; } @@ -291,7 +269,6 @@ public abstract class TestNewtEventModifiers extends UITestCase { private static int _numButtonsToTest ; private static int _awtButtonMasks[] ; - private static int _newtButtonMasks[] ; private static java.awt.Robot _robot ; @@ -300,6 +277,8 @@ public abstract class TestNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// public static int getAWTButtonMask(int button) { + // Java7: java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; -> using InputEvent.BUTTON1_DOWN_MASK .. etc + // Java6: Only use BUTTON1_MASK, .. int m; switch(button) { case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; @@ -316,7 +295,13 @@ public abstract class TestNewtEventModifiers extends UITestCase { // Who know how many buttons the AWT will say exist on given platform. // We'll test the smaller of what NEWT supports and what the // AWT says is available. - // _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; + /** Java7: + if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { + _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; + } else { + _numButtonsToTest = 3 ; + } */ + _numButtonsToTest = 3 ; // Then again, maybe not: @@ -327,7 +312,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { // up weren't even delivered to the listeners. // // So... for now we're only going to test 3 buttons since - // that's the common case. + // that's the common case _and_ Java6 safe. _numButtonsToTest = 3 ; @@ -344,13 +329,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); - } - - _newtButtonMasks = new int[_numButtonsToTest] ; - - for( int n = 0 ; n < _newtButtonMasks.length ; ++n ) { - _newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ; - } + } } _robot = new java.awt.Robot() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt b/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt deleted file mode 100644 index 1bd9102b5..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt +++ /dev/null @@ -1,37 +0,0 @@ -Modifier AWT Constant AWT Bit AWT Ex NEWT Constant NEWT Bit -------------- ------------------------------- ------- ------ ------------------------- -------- -Shift Event.SHIFT_MASK 0 -Ctrl Event.CTRL_MASK 1 -Meta Event.META_MASK 2 -Alt Event.ALT_MASK 3 -Button1 InputEvent.BUTTON1_MASK 4 -Button2 InputEvent.BUTTON2_MASK 3 -Button3 InputEvent.BUTTON3_MASK 2 -Shift Down InputEvent.SHIFT_DOWN_MASK 6 * InputEvent.SHIFT_MASK 0 -Ctrl Down InputEvent.CTRL_DOWN_MASK 7 * InputEvent.CTRL_MASK 1 -Meta Down InputEvent.META_DOWN_MASK 8 * InputEvent.META_MASK 2 -Alt Down InputEvent.ALT_DOWN_MASK 9 * InputEvent.ALT_MASK 3 -Button1 Down InputEvent.BUTTON1_DOWN_MASK 10 * InputEvent.BUTTON1_MASK 5 -Button2 Down InputEvent.BUTTON2_DOWN_MASK 11 * InputEvent.BUTTON2_MASK 6 -Button3 Down InputEvent.BUTTON3_DOWN_MASK 12 * InputEvent.BUTTON3_MASK 7 -AltGraph Down InputEvent.ALT_GRAPH_DOWN_MASK 13 * InputEvent.ALT_GRAPH_MASK 4 -Button4 Down -- 14 * InputEvent.BUTTON4_MASK 8 -Button5 Down -- 15 * InputEvent.BUTTON5_MASK 9 -Button6 Down -- 16 * InputEvent.BUTTON6_MASK 10 -Button7 Down -- 17 * InputEvent.BUTTON7_MASK 11 -Button8 Down -- 18 * InputEvent.BUTTON8_MASK 12 -Button9 Down -- 19 * InputEvent.BUTTON9_MASK 13 -Button10 Down -- 20 * -Button11 Down -- 21 * -Button12 Down -- 22 * -Button13 Down -- 23 * -Button14 Down -- 24 * -Button15 Down -- 25 * -Button16 Down -- 26 * InputEvent.BUTTONLAST_MASK 20 -Button17 Down -- 27 * -Button18 Down -- 28 * -Button19 Down -- 29 * -Button20 Down -- 30 * -Autorepeat -- - InputEvent.AUTOREPEAT_MASK 29 -Confined -- - InputEvent.CONFINED_MASK 30 -Invisible -- - InputEvent.INVISIBLE_MASK 31 diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index 3aa016d56..fd68ace73 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -44,7 +44,7 @@ import com.jogamp.newt.event.awt.AWTMouseAdapter ; * the source is an AWT canvas. */ -public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { +public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { private static JFrame _testFrame ; @@ -53,7 +53,7 @@ public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; final GLCanvas canvas = new GLCanvas() ; canvas.addGLEventListener( new BigGreenXGLEventListener() ) ; @@ -76,7 +76,7 @@ public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java index a2c1d3364..44f116ea1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -48,7 +48,7 @@ import com.jogamp.newt.opengl.GLWindow ; * the canvas is a NewtCanvasAWT. */ -public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers { +public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers { private static JFrame _testFrame ; private static GLWindow _glWindow ; @@ -58,7 +58,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; SwingUtilities.invokeAndWait( new Runnable() { public void run() { @@ -89,7 +89,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; SwingUtilities.invokeAndWait( new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index e6139bb37..501e0d1bd 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -47,7 +47,7 @@ import com.jogamp.newt.swt.NewtCanvasSWT ; * the canvas is a NewtCanvasSWT. */ -public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers { +public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers { private static Shell _testShell ; private static GLWindow _glWindow ; @@ -87,7 +87,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; _displayThread = new DisplayThread() ; _displayThread.start() ; @@ -127,7 +127,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; _glWindow.destroy() ; |