summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-23 01:21:30 +0200
committerSven Gothel <[email protected]>2013-06-23 01:21:30 +0200
commit2d32b056c7b1b6b3d071d79fb4c2d4e9113b59d5 (patch)
tree65bd4a21fa8263a05d90edbd1ee6b4c23052a2d8 /src/test/com
parent41c626d8a27981e694b3b728a9a2f2bc8def939d (diff)
Fix Bug 761 (part 2/2): NEWT registers one customShutdownHook @ NativeWindowFactory.shutdownHook head, allowing proper resource cleanup.
1 WindowImpl.shutdownAll(): - For all instances: - mark invalid (causes any user thread to disregard the window) 2 ScreenImpl.shutdownAll(): - Removed own shutdown-hook! - For all instances: - Reset ScreenMonitorState 3 DisplayImpl.shutdownAll(): - For all instances: - Remove EDT - closeNativeImpl Manually tested on X11 w/ NV and ATI Catalyst (fglrx) - DFLAGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" - java $DFLAGS com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -time 2000 -sysExit testExit - valid arguments for sysExit: testExit, testError, displayExit, displayError
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index 0756399c1..a876b5c96 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -90,6 +90,8 @@ public class TestGearsES2NEWT extends UITestCase {
static boolean mainRun = false;
static boolean exclusiveContext = false;
static boolean useAnimator = true;
+ static enum SysExit { none, testExit, testError, displayExit, displayError };
+ static SysExit sysExit = SysExit.none;
@BeforeClass
public static void initClass() {
@@ -272,6 +274,36 @@ public class TestGearsES2NEWT extends UITestCase {
Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
}
+ if( SysExit.displayError == sysExit || SysExit.displayExit == sysExit ) {
+ glWindow.addGLEventListener(new GLEventListener() {
+
+ @Override
+ public void init(GLAutoDrawable drawable) {}
+
+ @Override
+ public void dispose(GLAutoDrawable drawable) { }
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ final GLAnimatorControl anim = drawable.getAnimator();
+ if( null != anim && anim.isAnimating() ) {
+ if( anim.getTotalFPSDuration() >= duration/2 ) {
+ if( SysExit.displayError == sysExit ) {
+ throw new Error("test error send from GLEventListener");
+ } else if ( SysExit.displayExit == sysExit ) {
+ System.err.println("exit(0) send from GLEventListener");
+ System.exit(0);
+ }
+ }
+ } else {
+ System.exit(0);
+ }
+ }
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+ }
+
glWindow.setVisible(true);
if( useAnimator ) {
animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
@@ -296,6 +328,16 @@ public class TestGearsES2NEWT extends UITestCase {
while(!quitAdapter.shouldQuit() && t1-t0<duration) {
Thread.sleep(100);
t1 = System.currentTimeMillis();
+ if( t1-t0 >= duration/2 ) {
+ if( SysExit.testError == sysExit || SysExit.testExit == sysExit ) {
+ if( SysExit.testError == sysExit ) {
+ throw new Error("test error send from test thread");
+ } else if ( SysExit.testExit == sysExit ) {
+ System.err.println("exit(0) send from test thread");
+ System.exit(0);
+ }
+ }
+ }
}
if( useAnimator ) {
@@ -429,6 +471,9 @@ public class TestGearsES2NEWT extends UITestCase {
loops = MiscUtils.atoi(args[i], 1);
} else if(args[i].equals("-loop-shutdown")) {
loop_shutdown = true;
+ } else if(args[i].equals("-sysExit")) {
+ i++;
+ sysExit = SysExit.valueOf(args[i]);
}
}
wsize = new Dimension(w, h);
@@ -458,6 +503,7 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("swapInterval "+swapInterval);
System.err.println("exclusiveContext "+exclusiveContext);
System.err.println("useAnimator "+useAnimator);
+ System.err.println("sysExitWithin "+sysExit);
if(waitForKey) {
UITestCase.waitForKey("Start");