From 13168c99ff9e8bf71c83f1be7afee270a3db4074 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Dec 2012 15:36:09 +0100 Subject: Fix commit 811e3791b98fea0dfa3b7d301cb532c54df8dc82: Make AWT usage Java6 clean (was using Java7 stuff); Note: Need to test! --- .../junit/newt/event/TestNewtEventModifiers.java | 39 +++++++++++++++++----- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java index 36185f8ce..81e1939b9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java @@ -216,6 +216,23 @@ public abstract class TestNewtEventModifiers extends UITestCase { 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 getFailures() { return _failures ; } @@ -282,18 +299,24 @@ public abstract class TestNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// + public static int getAWTButtonMask(int button) { + int m; + switch(button) { + case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; + case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break; + case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break; + default: throw new IllegalArgumentException("Only buttons 1-3 have a MASK value, requested button "+button); + } + return m; + } + @BeforeClass public static void beforeClass() throws Exception { // 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. - - if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { - _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; - } else { - _numButtonsToTest = 3 ; - } + // _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; // Then again, maybe not: @@ -320,7 +343,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { _awtButtonMasks = new int[_numButtonsToTest] ; for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { - _awtButtonMasks[n] = java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; + _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); } _newtButtonMasks = new int[_numButtonsToTest] ; @@ -726,7 +749,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { } for (int n = 0 ; n < _numButtonsToTest ; ++n) { - if ((awtExtendedModifiers & java.awt.event.InputEvent.getMaskForButton(n+1)) != 0) { + if ((awtExtendedModifiers & getAWTButtonMask(n+1)) != 0) { mask |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; } } -- cgit v1.2.3