diff options
Diffstat (limited to 'src/junit')
32 files changed, 354 insertions, 146 deletions
diff --git a/src/junit/com/jogamp/test/junit/core/TestIteratorIndexCORE.java b/src/junit/com/jogamp/test/junit/core/TestIteratorIndexCORE.java new file mode 100644 index 000000000..0ed102e40 --- /dev/null +++ b/src/junit/com/jogamp/test/junit/core/TestIteratorIndexCORE.java @@ -0,0 +1,128 @@ +/** + * 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.test.junit.core; + +import com.jogamp.test.junit.util.UITestCase; + +import java.util.*; +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +public class TestIteratorIndexCORE extends UITestCase { + + static int elems = 10; + static int loop = 9999999; + + public void populate(List l, int len) { + while(len>0) { + l.add(new Integer(len--)); + } + } + + @Test + public void test01ArrayListIterator() { + int sum=0; + ArrayList l = new ArrayList(); + populate(l, elems); + + for(int j=loop; j>0; j--) { + for(Iterator iter = l.iterator(); iter.hasNext(); ) { + Integer i = (Integer)iter.next(); + sum+=i.intValue(); + } + } + System.err.println("test01-arraylist-iterator sum: "+sum); + } + + @Test + public void test0ArrayListIndex() { + int sum=0; + ArrayList l = new ArrayList(); + populate(l, elems); + + for(int j=loop; j>0; j--) { + for(int k = 0; k < l.size(); k++) { + Integer i = (Integer)l.get(k); + sum+=i.intValue(); + } + } + System.err.println("test01-arraylist-index sum: "+sum); + } + + @Test + public void test01LinkedListListIterator() { + int sum=0; + LinkedList l = new LinkedList(); + populate(l, elems); + + for(int j=loop; j>0; j--) { + for(Iterator iter = l.iterator(); iter.hasNext(); ) { + Integer i = (Integer)iter.next(); + sum+=i.intValue(); + } + } + System.err.println("test01-linkedlist-iterator sum: "+sum); + } + + @Test + public void test01LinkedListListIndex() { + int sum=0; + LinkedList l = new LinkedList(); + populate(l, elems); + + for(int j=loop; j>0; j--) { + for(int k = 0; k < l.size(); k++) { + Integer i = (Integer)l.get(k); + sum+=i.intValue(); + } + } + System.err.println("test01-linkedlist-index sum: "+sum); + } + + public static void main(String args[]) throws IOException { + String tstname = TestIteratorIndexCORE.class.getName(); + org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { + tstname, + "filtertrace=true", + "haltOnError=false", + "haltOnFailure=false", + "showoutput=true", + "outputtoformatters=true", + "logfailedtests=true", + "logtestlistenerevents=true", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); + } + +} diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java b/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java index 1c563970f..3fa7f111f 100644 --- a/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java +++ b/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java @@ -35,6 +35,7 @@ import org.junit.AfterClass; import org.junit.Test; import javax.media.opengl.*; +import com.jogamp.opengl.util.VersionInfo; import com.jogamp.common.os.Platform; import java.io.IOException; @@ -44,16 +45,9 @@ public class DumpVersion implements GLEventListener { public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL(); - System.err.println(Thread.currentThread()+" Platform: " + Platform.getOS() + " (os), " + Platform.getArch() + " (arch)"); - System.err.println(Thread.currentThread()+" Platform: littleEndian " + Platform.isLittleEndian() + ", 32Bit "+Platform.is32Bit() + ", a-ptr bit-size "+Platform.getPointerSizeInBits()); - System.err.println(Thread.currentThread()+" Platform: JavaSE " + Platform.isJavaSE()); - System.err.println(Thread.currentThread()+" GL Profile " + gl.getGLProfile()); - System.err.println(Thread.currentThread()+" CTX VERSION " + gl.getContext().getGLVersion()); - System.err.println(Thread.currentThread()+" GL " + gl); - System.err.println(Thread.currentThread()+" GL_VERSION " + gl.glGetString(gl.GL_VERSION)); - System.err.println(Thread.currentThread()+" GL_EXTENSIONS "); - System.err.println(Thread.currentThread()+" " + gl.glGetString(gl.GL_EXTENSIONS)); - System.err.println(Thread.currentThread()+" swapInterval " + gl.getSwapInterval()); + String prefix = Thread.currentThread().getName(); + + System.err.println(VersionInfo.getInfo(null, prefix, gl).toString()); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { @@ -64,8 +58,4 @@ public class DumpVersion implements GLEventListener { public void dispose(GLAutoDrawable drawable) { } - - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } - } diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java index 711ac7c87..b42fce9bf 100644 --- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java @@ -44,13 +44,11 @@ import com.jogamp.newt.*; import java.io.IOException; public class TestGLProfile01NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } static GLProfile glp; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glp = GLProfile.getDefault(); Assert.assertNotNull(glp); } 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 5ee3d3814..006010eeb 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java @@ -47,15 +47,12 @@ import org.junit.Test; public class TestAWT01GLn extends UITestCase { - static { - GLProfile.initSingleton(); - } - Frame frame=null; GLCanvas glCanvas=null; @BeforeClass public static void startup() { + GLProfile.initSingleton(true); System.out.println("GLProfile <static> "+GLProfile.glAvailabilityToString()); } diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java index a4726f1c6..9e8cb916a 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java @@ -42,12 +42,14 @@ import org.junit.After; import org.junit.Test; public class TestAWT02WindowClosing extends UITestCase { - static { - GLProfile.initSingleton(); - } static long durationPerTest = 200; // ms + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(true); + } + @Test public void test01WindowClosing() throws InterruptedException { Frame frame = new Frame(); diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWT01GLn.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWT01GLn.java index c3b9e10ab..4559ee936 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWT01GLn.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWT01GLn.java @@ -53,16 +53,12 @@ import static javax.swing.SwingUtilities.*; * @author Michael Bien */ public class TestSwingAWT01GLn extends UITestCase { - static { - GLProfile.initSingleton(); - } - - private Window[] windows; @BeforeClass public static void startup() { + GLProfile.initSingleton(true); System.out.println("GLProfile <static> "+GLProfile.glAvailabilityToString()); } diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java index 9f12b658a..2f4a95646 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java @@ -117,6 +117,9 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { public static void setup() throws InterruptedException, InvocationTargetException, AWTException { int count; + // GLProfile.initSingleton(false); + // GLProfile.initSingleton(true); + // simulate AWT usage before JOGL's initialization of X11 threading windowClosing=false; border = BorderFactory.createLineBorder (Color.yellow, 2); @@ -166,14 +169,18 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { System.err.println("Clean End of Pre-JOGL-Swing"); - GLProfile.initSingleton(); + GLProfile.initSingleton(false); } @AfterClass - public static void release() { + public static void release() throws InterruptedException, InvocationTargetException { robot = null; Assert.assertNotNull(frame); - frame.dispose(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + } + }); frame=null; } diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java index ef5cf134a..3a3823d96 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java @@ -3,10 +3,12 @@ package com.jogamp.test.junit.jogl.demos.gl2.gears; import javax.media.opengl.*; import javax.media.opengl.awt.*; +import com.jogamp.opengl.util.Animator; import com.jogamp.newt.event.*; import com.jogamp.newt.event.awt.*; import java.awt.Component; +import java.awt.Frame; import com.jogamp.newt.Window; /** @@ -24,8 +26,44 @@ public class Gears implements GLEventListener { private int prevMouseX, prevMouseY; private boolean mouseRButtonDown = false; + public static void main(String[] args) { + // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example + // <application-desc main-class="demos.j2d.TextCube"/> + // <argument>NotFirstUIActionOnProcess</argument> + // </application-desc> + boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ; + GLProfile.initSingleton(firstUIActionOnProcess); + + Frame frame = new Frame("Gear Demo"); + GLCanvas canvas = new GLCanvas(); + // GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + // GLCanvas canvas = new GLCanvas(caps); + + final Gears gears = new Gears(); + canvas.addGLEventListener(gears); + + frame.add(canvas); + frame.setSize(300, 300); + final Animator animator = new Animator(canvas); + frame.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent e) { + // Run this on another thread than the AWT event queue to + // make sure the call to Animator.stop() completes before + // exiting + new Thread(new Runnable() { + public void run() { + animator.stop(); + System.exit(0); + } + }).start(); + } + }); + frame.setVisible(true); + animator.start(); + } + public void init(GLAutoDrawable drawable) { - System.out.println("Gears: Init"); + System.err.println("Gears: Init"); // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); @@ -78,7 +116,7 @@ public class Gears implements GLEventListener { } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - System.out.println("Gears: Reshape"); + System.err.println("Gears: Reshape"); GL2 gl = drawable.getGL().getGL2(); float h = (float)height / (float)width; @@ -93,7 +131,7 @@ public class Gears implements GLEventListener { } public void dispose(GLAutoDrawable drawable) { - System.out.println("Gears: Dispose"); + System.err.println("Gears: Dispose"); } public void display(GLAutoDrawable drawable) { @@ -103,14 +141,13 @@ public class Gears implements GLEventListener { // Get the GL corresponding to the drawable we are animating GL2 gl = drawable.getGL().getGL2(); - /** // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content if ((drawable instanceof GLJPanel) && !((GLJPanel) drawable).isOpaque() && ((GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { gl.glClear(GL2.GL_DEPTH_BUFFER_BIT); - } else */ { + } else { gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); } diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java index 52a4885b4..60435cb4a 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java @@ -48,15 +48,12 @@ import org.junit.After; import org.junit.Test; public class TestGearsAWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static int width, height; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glp = GLProfile.getDefault(); Assert.assertNotNull(glp); width = 512; diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java index 88cfa9c95..1589be84c 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java @@ -46,15 +46,12 @@ import org.junit.After; import org.junit.Test; public class TestGearsNEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static int width, height; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glp = GLProfile.getDefault(); Assert.assertNotNull(glp); width = 512; diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java index 47cdd4bfa..27c353942 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java @@ -46,15 +46,12 @@ import org.junit.After; import org.junit.Test; public class TestGearsNewtAWTWrapper extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static int width, height; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glp = GLProfile.getDefault(); Assert.assertNotNull(glp); width = 512; diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java index 243c9e8a7..95db913ab 100644 --- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java @@ -42,10 +42,6 @@ import com.jogamp.newt.*; import java.io.IOException; public class TestDrawable01NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static GLDrawableFactory factory; static int width, height; @@ -56,6 +52,7 @@ public class TestDrawable01NEWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glp = GLProfile.getDefault(); Assert.assertNotNull(glp); factory = GLDrawableFactory.getFactory(glp); diff --git a/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java b/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java index bedea39ad..0d9a595aa 100644 --- a/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java @@ -16,6 +16,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Assume; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; @@ -32,13 +33,14 @@ import java.io.IOException; */ public class TestTransformFeedbackVeryingsBug407NEWT extends UITestCase { - static { - //NativeUtil.preloadNativeLibs(); // internal method - GLProfile.initSingleton(); - } private GLContext context; private String VERTEX_SHADER_TEXT; + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(true); + } + @Before public void setUp() { if(!GLProfile.isGL3Available()) { diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java index e72d5e506..1d699a1aa 100644 --- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java @@ -54,10 +54,6 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import java.io.IOException; public class TestOffscreen01NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glpDefault; static GLDrawableFactory glDrawableFactory; static int width, height; @@ -65,6 +61,7 @@ public class TestOffscreen01NEWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glpDefault = GLProfile.getDefault(); Assert.assertNotNull(glpDefault); glDrawableFactory = GLDrawableFactory.getFactory(glpDefault); diff --git a/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java b/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java index 7d6b4d7e3..2eb66663c 100644 --- a/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java @@ -54,16 +54,13 @@ import org.junit.BeforeClass; import org.junit.Test; public class TestTexture01AWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static GLCapabilities caps; BufferedImage textureImage; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); glp = GLProfile.get(GLProfile.GL2GL3); Assert.assertNotNull(glp); caps = new GLCapabilities(glp); diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java index 7f70d1f8b..072ebafd6 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java @@ -1,33 +1,29 @@ -/* - * Copyright (c) 2010 Sven Gothel. All Rights Reserved. +/** + * 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: * - * 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. * - * - Redistribution 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. * - * - Redistribution 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. * - * Neither the name Sven Gothel or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * 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.test.junit.newt; @@ -57,10 +53,6 @@ import com.jogamp.test.junit.util.MiscUtils; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestDisplayLifecycle01NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static GLCapabilities caps; static int width, height; @@ -68,6 +60,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glp = GLProfile.getDefault(); diff --git a/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java b/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java new file mode 100644 index 000000000..8776b7be8 --- /dev/null +++ b/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java @@ -0,0 +1,110 @@ +/** + * 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.test.junit.newt; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Test; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; +import com.jogamp.test.junit.util.*; + +/** + * This simple program will throw a {@link RuntimeException} when the application is closed. + */ +public class TestEventSourceNotAWTBug extends UITestCase { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(true); + } + + @Test + public void testEventSourceNotNewtBug() throws InterruptedException { + JFrame jf = new JFrame(); + + jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + final GLWindow glWindow = GLWindow.create(caps); + final NewtCanvasAWT canvas = new NewtCanvasAWT(glWindow); + jf.getContentPane().add(canvas); + + // The following line isn't event necessary to see the problem. + glWindow.addGLEventListener(new Gears()); + + final JFrame f_jf = jf; + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + f_jf.setSize(800, 600); + f_jf.setVisible(true); + } + }); + + Thread.sleep(500); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + f_jf.dispose(); + } + }); + glWindow.destroy(true); + } + + public static void main(String args[]) throws IOException { + String tstname = TestEventSourceNotAWTBug.class.getName(); + /* + org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { + tstname, + "filtertrace=true", + "haltOnError=false", + "haltOnFailure=false", + "showoutput=true", + "outputtoformatters=true", + "logfailedtests=true", + "logtestlistenerevents=true", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */ + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java index 6ae0ee9d3..656783740 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -68,11 +68,6 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.util.*; public class TestFocus01SwingAWTRobot extends UITestCase { - - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 800; @@ -81,6 +76,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glCaps = new GLCapabilities(null); diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java index 1ca5e6cd7..8d262fc3f 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -75,7 +75,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase { f.dispose(); f=null; - GLProfile.initSingleton(); + GLProfile.initSingleton(false); glCaps = new GLCapabilities(null); } diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java index df073d0f8..aad61565f 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java @@ -53,16 +53,13 @@ import com.jogamp.test.junit.util.MiscUtils; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestGLWindows01NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static int width, height; static long durationPerTest = 100; // ms @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glp = GLProfile.getDefault(); diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java index f5474c0ec..7a8bc1db0 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -54,16 +54,13 @@ import com.jogamp.test.junit.util.MiscUtils; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestGLWindows02NEWTAnimated extends UITestCase { - static { - GLProfile.initSingleton(); - } - static GLProfile glp; static int width, height; static long durationPerTest = 100; // ms @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glp = GLProfile.getDefault(); diff --git a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java index a3310f513..39eb47ca9 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java @@ -61,16 +61,13 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestListenerCom01AWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 500; static boolean verbose = false; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; } diff --git a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java index ae01b14ed..88edd89ba 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java @@ -52,6 +52,7 @@ public class TestWindows01NEWT extends UITestCase { @BeforeClass public static void initClass() { + NativeWindowFactory.initSingleton(true); width = 640; height = 480; } diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java index c07601eb6..2d1bb82a6 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java @@ -56,16 +56,13 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 500; static GLCapabilities glCaps; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glCaps = new GLCapabilities(null); diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java index 3d3f5234d..931cf2d5f 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java @@ -63,20 +63,18 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01aAWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 800; static long waitReparent = 0; static GLCapabilities glCaps; @BeforeClass - public static void initClass() { + public static void initClass() throws InterruptedException { + GLProfile.initSingleton(true); width = 640; height = 480; glCaps = new GLCapabilities(null); + // Thread.sleep(10000); } @Test diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java index 11d25822a..9eecf31a1 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java @@ -63,10 +63,6 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01bAWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 800; static long waitReparent = 0; @@ -74,6 +70,7 @@ public class TestParenting01bAWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glCaps = new GLCapabilities(null); diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java index 24ee30bc0..2dcc7af9b 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java @@ -62,16 +62,13 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01cAWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 800; static GLCapabilities glCaps; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glCaps = new GLCapabilities(null); diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java index ece99c0be..3fc39a3f1 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -66,10 +66,6 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01cSwingAWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 800; static long waitReparent = 0; @@ -77,6 +73,7 @@ public class TestParenting01cSwingAWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; glCaps = new GLCapabilities(null); diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java index a4b8c183d..3311bc691 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java @@ -61,10 +61,6 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting02AWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 500; static long waitReparent = 300; @@ -72,6 +68,7 @@ public class TestParenting02AWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; } diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java index 8d1c7594c..3d9efcf82 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java @@ -56,15 +56,12 @@ import com.jogamp.test.junit.jogl.demos.es1.RedSquare; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting02NEWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static int width, height; static long durationPerTest = 500; @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); width = 640; height = 480; } diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java index f7374a98b..6130a5fcd 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java @@ -64,10 +64,6 @@ import com.jogamp.test.junit.util.*; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting03AWT extends UITestCase { - static { - GLProfile.initSingleton(); - } - static Dimension size; static long durationPerTest = 800; static long waitAdd2nd = 500; @@ -75,6 +71,7 @@ public class TestParenting03AWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(true); size = new Dimension(400,200); glCaps = new GLCapabilities(null); } diff --git a/src/junit/com/jogamp/test/junit/util/UITestCase.java b/src/junit/com/jogamp/test/junit/util/UITestCase.java index 5bf76234d..e169405b0 100644 --- a/src/junit/com/jogamp/test/junit/util/UITestCase.java +++ b/src/junit/com/jogamp/test/junit/util/UITestCase.java @@ -55,6 +55,7 @@ public abstract class UITestCase { @AfterClass public static void oneTimeTearDown() { // one-time cleanup code + System.gc(); // force cleanup singletonInstance.unlock(); } |