diff options
Diffstat (limited to 'src/test')
9 files changed, 436 insertions, 26 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java index 7813482e1..6a5f76ff9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java @@ -137,17 +137,6 @@ public class TestGLProfile01NEWT extends UITestCase { dumpVersion(glp); } - @Test - public void test06GLProfileShutdownRecreate() throws InterruptedException { - GLProfile.shutdown(); - GLProfile.initSingleton(true); - System.out.println("GLProfile.getDefault(): "+GLProfile.getDefault()); - System.out.println("GLProfile.getDefaultDesktopDevice(): "+GLProfile.getDefaultDesktopDevice()); - System.out.println("GLProfile.getDefaultEGLDevice(): "+GLProfile.getDefaultEGLDevice()); - System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice()); - } - - protected void dumpVersion(GLProfile glp) throws InterruptedException { GLCapabilities caps = new GLCapabilities(glp); GLWindow glWindow = GLWindow.create(caps); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java new file mode 100644 index 000000000..6b7f1454d --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java @@ -0,0 +1,117 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestShutdownCompleteAWT extends UITestCase { + + static long duration = 300; // ms + + protected void runTestGL() throws InterruptedException, InvocationTargetException { + final Frame frame = new Frame("Gears AWT Test"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault())); + Assert.assertNotNull(glCanvas); + frame.add(glCanvas); + frame.setSize(256, 256); + + glCanvas.addGLEventListener(new Gears(1)); + + Animator animator = new Animator(glCanvas); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(true); + }}); + + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + Assert.assertEquals(true, glCanvas.isVisible()); + Assert.assertEquals(true, glCanvas.isDisplayable()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { + Thread.sleep(100); + } + Assert.assertEquals(true, glCanvas.isRealized()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + frame.setVisible(false); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas); + frame.dispose(); + }}); + } + + protected void oneLife() throws InterruptedException, InvocationTargetException { + GLProfile.initSingleton(false); + runTestGL(); + GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE); + } + + @Test + public void test01OneLife() throws InterruptedException, InvocationTargetException { + oneLife(); + } + + @Test + public void test01AnotherLife() throws InterruptedException, InvocationTargetException { + oneLife(); + } + + @Test + public void test01TwoLifes() throws InterruptedException, InvocationTargetException { + oneLife(); + oneLife(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestShutdownCompleteAWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java new file mode 100644 index 000000000..e1b1946b0 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java @@ -0,0 +1,101 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestShutdownCompleteNEWT extends UITestCase { + + static long duration = 300; // ms + + protected void runTestGL() throws InterruptedException { + GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault())); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test"); + + glWindow.addGLEventListener(new Gears()); + + Animator animator = new Animator(glWindow); + + glWindow.setSize(256, 256); + glWindow.setVisible(true); + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + Assert.assertEquals(true, glWindow.isVisible()); + Assert.assertEquals(true, glWindow.isNativeValid()); + Assert.assertEquals(true, glWindow.isRealized()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { + Thread.sleep(100); + } + + animator.stop(); + glWindow.destroy(); + } + + protected void oneLife() throws InterruptedException { + GLProfile.initSingleton(false); + runTestGL(); + GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE); + } + + @Test + public void test01OneLife() throws InterruptedException { + oneLife(); + } + + @Test + public void test01AnotherLife() throws InterruptedException { + oneLife(); + } + + @Test + public void test01TwoLifes() throws InterruptedException { + oneLife(); + oneLife(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestShutdownCompleteNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java new file mode 100644 index 000000000..3ee276854 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java @@ -0,0 +1,116 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestShutdownSharedAWT extends UITestCase { + + static long duration = 300; // ms + + protected void runTestGL() throws InterruptedException, InvocationTargetException { + final Frame frame = new Frame("Gears AWT Test"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault())); + Assert.assertNotNull(glCanvas); + frame.add(glCanvas); + frame.setSize(256, 256); + + glCanvas.addGLEventListener(new Gears(1)); + + Animator animator = new Animator(glCanvas); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(true); + }}); + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + Assert.assertEquals(true, glCanvas.isVisible()); + Assert.assertEquals(true, glCanvas.isDisplayable()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { + Thread.sleep(100); + } + Assert.assertEquals(true, glCanvas.isRealized()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + frame.setVisible(false); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas); + frame.dispose(); + }}); + } + + protected void oneLife() throws InterruptedException, InvocationTargetException { + GLProfile.initSingleton(false); + runTestGL(); + GLProfile.shutdown(GLProfile.ShutdownType.SHARED_ONLY); + } + + @Test + public void test01OneLife() throws InterruptedException, InvocationTargetException { + oneLife(); + } + + @Test + public void test01AnotherLife() throws InterruptedException, InvocationTargetException { + oneLife(); + } + + @Test + public void test01TwoLifes() throws InterruptedException, InvocationTargetException { + oneLife(); + oneLife(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestShutdownSharedAWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java new file mode 100644 index 000000000..8ce13d237 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java @@ -0,0 +1,101 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestShutdownSharedNEWT extends UITestCase { + + static long duration = 300; // ms + + protected void runTestGL() throws InterruptedException { + GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault())); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test"); + + glWindow.addGLEventListener(new Gears()); + + Animator animator = new Animator(glWindow); + + glWindow.setSize(256, 256); + glWindow.setVisible(true); + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + Assert.assertEquals(true, glWindow.isVisible()); + Assert.assertEquals(true, glWindow.isNativeValid()); + Assert.assertEquals(true, glWindow.isRealized()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { + Thread.sleep(100); + } + + animator.stop(); + glWindow.destroy(); + } + + protected void oneLife() throws InterruptedException { + GLProfile.initSingleton(false); + runTestGL(); + GLProfile.shutdown(GLProfile.ShutdownType.SHARED_ONLY); + } + + @Test + public void test01OneLife() throws InterruptedException { + oneLife(); + } + + @Test + public void test01AnotherLife() throws InterruptedException { + oneLife(); + } + + @Test + public void test01TwoLifes() throws InterruptedException { + oneLife(); + oneLife(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestShutdownSharedNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java index b683cb2e7..c102dc310 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java @@ -60,13 +60,6 @@ public class TestGLSLSimple01NEWT extends UITestCase { GLProfile.initSingleton(true); } - @AfterClass - public static void tearDownClass() { - System.err.println("class tear down .."); - GLProfile.shutdown(); - System.err.println("class tear down end"); - } - @Test(timeout=60000) public void testGLSLCompilation01() { GLProfile glp = GLProfile.get(GLProfile.GL2ES2); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java index a6d04cf24..94980a3a3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java @@ -34,11 +34,6 @@ public class TestTransformFeedbackVaryingsBug407NEWT extends UITestCase { GLProfile.initSingleton(true); } - @AfterClass - public static void tearDownClass() { - GLProfile.shutdown(); - } - class MyShader { int shaderProgram; int vertShader; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java index 664cab03b..4ebb7dddd 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java @@ -110,8 +110,6 @@ public class TestCloseNewtAWT extends UITestCase { Thread.sleep(500); Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true)); - - GLProfile.shutdown(); } public static void main(String[] args) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java index 5f14fc466..e4d73647b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java @@ -112,7 +112,7 @@ public class TestScreenMode01NEWT extends UITestCase { */ @After public void cleanupGL() throws InterruptedException { - GLProfile.shutdown(); + GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE); GLProfile.initSingleton(true); } |