diff options
-rw-r--r-- | make/build-junit.xml | 3 | ||||
-rwxr-xr-x | src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java | 112 |
2 files changed, 73 insertions, 42 deletions
diff --git a/make/build-junit.xml b/make/build-junit.xml index 749e73dbd..6c4f42811 100644 --- a/make/build-junit.xml +++ b/make/build-junit.xml @@ -93,6 +93,7 @@ <batchtest todir="${results.junit}"> <fileset dir="${classes}"> <include name="${java.dir.test}/**/Test*CORE*"/> + <exclude name="**/*$$*"/> </fileset> <formatter usefile="false" type="brief"/> <formatter usefile="true" type="xml"/> @@ -110,6 +111,7 @@ <!-- results in absolute path --> <fileset dir="${classes}"> <include name="${java.dir.test}/**/Test*NEWT*"/> + <exclude name="**/*$$*"/> </fileset> <sequential> <var name="test.class.path" unset="true"/> @@ -178,6 +180,7 @@ <batchtest todir="${results.junit}"> <fileset dir="${classes}"> <include name="${java.dir.test}/**/Test*AWT*"/> + <exclude name="**/*$$*"/> </fileset> <formatter usefile="false" type="brief"/> <formatter usefile="true" type="xml"/> diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java index 1652acd82..291fa6ad9 100755 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java @@ -32,6 +32,7 @@ package com.jogamp.test.junit.jogl.awt; +import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLCapabilities; import javax.media.opengl.awt.GLCanvas; @@ -39,17 +40,21 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import java.awt.Frame; +import java.awt.Window; +import javax.swing.JFrame; -import org.junit.Assert; -import org.junit.Assume; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; import org.junit.Test; +import static org.junit.Assume.*; +import static org.junit.Assert.*; +import static javax.swing.SwingUtilities.*; + public class TestAWT01GLn { - Frame frame=null; - GLCanvas glCanvas=null; + + private Window[] windows; + @BeforeClass public static void startup() { @@ -58,47 +63,70 @@ public class TestAWT01GLn { @Before public void init() { - frame = new Frame("Texture Test"); - Assert.assertNotNull(frame); + windows = new Window[]{ + new Window(null), + new Frame("Frame GL test"), + new JFrame("JFrame GL test") + }; } - @After - public void release() { - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas); - frame.setVisible(false); - try { - frame.remove(glCanvas); - } catch (Throwable t) { - t.printStackTrace(); - Assume.assumeNoException(t); + protected void runTestGL(final GLCapabilities caps) throws InterruptedException, InvocationTargetException { + + for (final Window window : windows) { + + System.out.println("testing with "+window.getClass().getName()); + + // final array as mutable container hack + final GLCanvas[] glCanvas = new GLCanvas[1]; + + Runnable test = new Runnable() { + public void run() { + glCanvas[0] = new GLCanvas(caps); + glCanvas[0].addGLEventListener(new Gears()); + window.add(glCanvas[0]); + window.setSize(512, 512); + glCanvas[0].display(); + window.setVisible(true); + } + }; + + Runnable cleanup = new Runnable() { + public void run() { + System.out.println("cleaning up..."); + window.setVisible(false); + try { + window.removeAll(); + } catch (Throwable t) { + assumeNoException(t); + t.printStackTrace(); + } + window.dispose(); + } + + }; + + //swing on EDT.. + if(window instanceof JFrame) { + invokeAndWait(test); + }else{ + test.run(); + } + + Animator animator = new Animator(glCanvas[0]); + animator.start(); + Thread.sleep(500); + animator.stop(); + + if(window instanceof JFrame) { + invokeAndWait(cleanup); + }else{ + cleanup.run(); + } } - frame.dispose(); - frame=null; - glCanvas=null; - } - - protected void runTestGL(GLCapabilities caps) throws InterruptedException { - glCanvas = new GLCanvas(caps); - Assert.assertNotNull(glCanvas); - frame.add(glCanvas); - frame.setSize(512, 512); - - glCanvas.addGLEventListener(new Gears()); - - glCanvas.display(); // one in process display - - Animator animator = new Animator(glCanvas); - frame.setVisible(true); - animator.start(); - - Thread.sleep(500); // 500 ms - - animator.stop(); } @Test - public void test01GLDefault() throws InterruptedException { + public void test01GLDefault() throws InterruptedException, InvocationTargetException { GLProfile glp = GLProfile.getDefault(); System.out.println("GLProfile Default: "+glp); GLCapabilities caps = new GLCapabilities(glp); @@ -106,7 +134,7 @@ public class TestAWT01GLn { } @Test - public void test03GLMaxFixed() throws InterruptedException { + public void test03GLMaxFixed() throws InterruptedException, InvocationTargetException { GLProfile maxFixed = GLProfile.getMaxFixedFunc(); System.out.println("GLProfile MaxFixed: "+maxFixed); GLCapabilities caps = new GLCapabilities(maxFixed); @@ -119,7 +147,7 @@ public class TestAWT01GLn { if(maxFixed.equals(GLProfile.GL3bc) || maxFixed.equals(GLProfile.GL4bc)) { t.printStackTrace(); - Assume.assumeNoException(t); + assumeNoException(t); } // else .. serious unexpected exception } |