aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-12-25 05:18:14 +0100
committerSven Gothel <[email protected]>2012-12-25 05:18:14 +0100
commit3cb2d5c1714b7b371ebd979304bb1e09a193f228 (patch)
tree989012e80bb8242172bcaabe8737d56a22c82772 /src/test
parentb0be3d764fc6ff90457fcb96ea81d53ba04cd420 (diff)
Test*NewtEventModifiers*: Clear 'clearing' events on thread - @Before/@After -> execOffThreadWithOnThreadEventDispatch
Remaining 'clearing' events from _releaseModifiers() and escape() broke test case.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java74
1 files changed, 32 insertions, 42 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java
index 6cbbc675f..31fa11e9d 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java
@@ -33,9 +33,7 @@ import java.util.ArrayList ;
import javax.media.opengl.GLProfile ;
-import org.junit.After ;
import org.junit.Assert ;
-import org.junit.Before ;
import org.junit.BeforeClass ;
import org.junit.Test ;
@@ -64,7 +62,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
protected static final int MS_ROBOT_KEY_PRESS_DELAY = 50 ;
protected static final int MS_ROBOT_KEY_RELEASE_DELAY = 50 ;
- protected static final int MS_ROBOT_MOUSE_MOVE_DELAY = 100 ;
+ protected static final int MS_ROBOT_MOUSE_MOVE_DELAY = 200 ;
protected static final int MS_ROBOT_AUTO_DELAY = 50 ;
protected static final int MS_ROBOT_POST_TEST_DELAY = 100;
@@ -320,22 +318,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
}
////////////////////////////////////////////////////////////////////////////
-
- @Before
- public void baseBeforeTest() throws Exception {
-
- _testMouseListener.setModifierCheckEnabled( false ) ;
- _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ;
-
- // Make sure all the buttons and modifier keys are released.
-
- _releaseModifiers() ;
- _escape() ;
-
- _testMouseListener.setModifierCheckEnabled( true ) ;
- }
-
- ////////////////////////////////////////////////////////////////////////////
// Following both methods are mandatory to deal with SWT's requirement
// to run the SWT event dispatch on the TK thread - which must be the main thread on OSX.
// We spawn off the actual test-action into another thread,
@@ -348,19 +330,38 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
} catch (InterruptedException e) { }
}
- private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) {
+ private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) throws Exception {
+ _testMouseListener.setModifierCheckEnabled( false ) ;
+ _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ;
+ {
+ // Make sure all the buttons and modifier keys are released.
+ _releaseModifiers() ;
+ _escape() ;
+ eventDispatch(); eventDispatch(); eventDispatch();
+ Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ;
+ eventDispatch(); eventDispatch(); eventDispatch();
+ }
+ _testMouseListener.setModifierCheckEnabled( true ) ;
+
Throwable throwable = null;
final Object sync = new Object();
- final RunnableTask rt = new RunnableTask( testAction, sync, true );
- new Thread(rt, "Test-Thread").start();
- while( !rt.isExecuted() && null == throwable ) {
- eventDispatch();
- }
- if(null==throwable) {
- throwable = rt.getThrowable();
- }
- if(null!=throwable) {
- throw new RuntimeException(throwable);
+ final RunnableTask rt = new RunnableTask( testAction, sync, true );
+ try {
+ new Thread(rt, "Test-Thread").start();
+ while( !rt.isExecuted() && null == throwable ) {
+ eventDispatch();
+ }
+ if(null==throwable) {
+ throwable = rt.getThrowable();
+ }
+ if(null!=throwable) {
+ throw new RuntimeException(throwable);
+ }
+ } finally {
+ _testMouseListener.setModifierCheckEnabled( false ) ;
+ eventDispatch(); eventDispatch(); eventDispatch();
+ Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ;
+ eventDispatch(); eventDispatch(); eventDispatch();
}
}
@@ -676,18 +677,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
////////////////////////////////////////////////////////////////////////////
- @After
- public void baseAfterTest() throws Exception {
-
- _testMouseListener.setModifierCheckEnabled( false ) ;
-
- Thread.sleep( 500 ) ;
-
- _robot.setAutoDelay( MS_ROBOT_POST_TEST_DELAY ) ;
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
public static void baseAfterClass() throws Exception {
// Make sure all modifiers are released, otherwise the user's
@@ -695,6 +684,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
_releaseModifiers() ;
_escape() ;
+ Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ;
}
////////////////////////////////////////////////////////////////////////////