summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-02-17 03:25:34 +0100
committerSven Gothel <[email protected]>2013-02-17 03:25:34 +0100
commit8edaa9780455b60f6034a78970cab4f516d4b061 (patch)
tree9f088885da8c3690be871a720dfcd254f569d2ef /src/test/com/jogamp/opengl
parent674004cd67105b27b63c7ac2f05738f21864bdc0 (diff)
NEWT/OSX: Fix Memory Leak ; Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread.
- Fix Memory Leak - NewtWindow::dealloc -> [NewtView release]: Fixes NewtView leak - NewtView::dealloc -> removeTrackingRect: Removes occasional crash (double free of TrackingRect) - Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread. Perform OSX WindowDriver ops on Main-Thread: - close0 - changeContentView0 - createWindow0 - Cleaned up AddRemove unit tests, added TestAddRemove03GLWindowNEWT
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java130
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java4
4 files changed, 176 insertions, 30 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java
index a14364e05..ce8f9adc8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java
@@ -50,13 +50,14 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
static long durationPerTest = 50;
static int addRemoveCount = 15;
- static boolean shallUseOffscreenFBOLayer = false;
+ static boolean noOnscreenTest = false;
+ static boolean noOffscreenTest = false;
static boolean shallUseOffscreenPBufferLayer = false;
static GLProfile glp;
static int width, height;
@@ -64,8 +65,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
@BeforeClass
public static void initClass() {
- if(GLProfile.isAvailable(GLProfile.GL2)) {
- glp = GLProfile.get(GLProfile.GL2);
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
Assert.assertNotNull(glp);
width = 640;
height = 480;
@@ -139,6 +140,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
{
for(int i=0; i<addRemoveOpCount; i++) {
+ System.err.println("Loop # "+i+" / "+addRemoveCount);
final GLCanvas glc = new GLCanvas(caps);
Assert.assertNotNull(glc);
if( !onscreen ) {
@@ -148,7 +150,9 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
glc.setMinimumSize(glc_sz);
glc.setPreferredSize(glc_sz);
glc.setSize(glc_sz);
- glc.addGLEventListener(new Gears());
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glc.addGLEventListener(gears);
final JFrame[] top = new JFrame[] { null };
final Container glcCont = create(top, width, height, i);
@@ -172,11 +176,11 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
public void test01Onscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( shallUseOffscreenFBOLayer || shallUseOffscreenPBufferLayer || JAWTUtil.isOffscreenLayerRequired() ) {
- System.err.println("Offscreen test requested or platform requires it.");
+ if( noOnscreenTest || JAWTUtil.isOffscreenLayerRequired() ) {
+ System.err.println("No onscreen test requested or platform doesn't support onscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -188,11 +192,11 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
public void test02Offscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( !JAWTUtil.isOffscreenLayerSupported() ) {
- System.err.println("Platform doesn't support offscreen test.");
+ if( noOffscreenTest || !JAWTUtil.isOffscreenLayerSupported() ) {
+ System.err.println("No offscreen test requested or platform doesn't support offscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -212,8 +216,10 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
try {
addRemoveCount = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
- } else if(args[i].equals("-layeredFBO")) {
- shallUseOffscreenFBOLayer = true;
+ } else if(args[i].equals("-noOnscreen")) {
+ noOnscreenTest = true;
+ } else if(args[i].equals("-noOffscreen")) {
+ noOffscreenTest = true;
} else if(args[i].equals("-layeredPBuffer")) {
shallUseOffscreenPBufferLayer = true;
} else if(args[i].equals("-wait")) {
@@ -224,7 +230,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase {
System.err.println("addRemoveCount "+addRemoveCount);
- System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
+ System.err.println("noOnscreenTest "+noOnscreenTest);
+ System.err.println("noOffscreenTest "+noOffscreenTest);
System.err.println("shallUseOffscreenPBufferLayer "+shallUseOffscreenPBufferLayer);
if(waitForKey) {
UITestCase.waitForKey("Start");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java
index d67662116..3d78943f9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java
@@ -52,13 +52,14 @@ import org.junit.Test;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
static long durationPerTest = 50;
static int addRemoveCount = 15;
- static boolean shallUseOffscreenFBOLayer = false;
+ static boolean noOnscreenTest = false;
+ static boolean noOffscreenTest = false;
static boolean shallUseOffscreenPBufferLayer = false;
static GLProfile glp;
static int width, height;
@@ -66,8 +67,8 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
@BeforeClass
public static void initClass() {
- if(GLProfile.isAvailable(GLProfile.GL2)) {
- glp = GLProfile.get(GLProfile.GL2);
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
Assert.assertNotNull(glp);
width = 640;
height = 480;
@@ -141,8 +142,9 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
{
for(int i=0; i<addRemoveOpCount; i++) {
+ System.err.println("Loop # "+i+" / "+addRemoveCount);
final GLWindow glw = GLWindow.create(caps);
-
+ Assert.assertNotNull(glw);
final NewtCanvasAWT glc = new NewtCanvasAWT(glw);
Assert.assertNotNull(glc);
if( !onscreen ) {
@@ -152,7 +154,9 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
glc.setMinimumSize(glc_sz);
glc.setPreferredSize(glc_sz);
glc.setSize(glc_sz);
- glw.addGLEventListener(new Gears());
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glw.addGLEventListener(gears);
final JFrame[] top = new JFrame[] { null };
final Container glcCont = create(top, width, height, i);
@@ -177,11 +181,11 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
public void test01Onscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( shallUseOffscreenFBOLayer || shallUseOffscreenPBufferLayer || JAWTUtil.isOffscreenLayerRequired() ) {
- System.err.println("Offscreen test requested or platform requires it.");
+ if( noOnscreenTest || JAWTUtil.isOffscreenLayerRequired() ) {
+ System.err.println("No onscreen test requested or platform doesn't support onscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -193,11 +197,11 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
public void test02Offscreen()
throws AWTException, InterruptedException, InvocationTargetException
{
- if( !JAWTUtil.isOffscreenLayerSupported() ) {
- System.err.println("Platform doesn't support offscreen test.");
+ if( noOffscreenTest || !JAWTUtil.isOffscreenLayerSupported() ) {
+ System.err.println("No offscreen test requested or platform doesn't support offscreen rendering.");
return;
}
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
if(shallUseOffscreenPBufferLayer) {
caps.setPBuffer(true);
caps.setOnscreen(true); // simulate normal behavior ..
@@ -217,8 +221,10 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
try {
addRemoveCount = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
- } else if(args[i].equals("-layeredFBO")) {
- shallUseOffscreenFBOLayer = true;
+ } else if(args[i].equals("-noOnscreen")) {
+ noOnscreenTest = true;
+ } else if(args[i].equals("-noOffscreen")) {
+ noOffscreenTest = true;
} else if(args[i].equals("-layeredPBuffer")) {
shallUseOffscreenPBufferLayer = true;
} else if(args[i].equals("-wait")) {
@@ -229,7 +235,8 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase {
System.err.println("addRemoveCount "+addRemoveCount);
- System.err.println("shallUseOffscreenFBOLayer "+shallUseOffscreenFBOLayer);
+ System.err.println("noOnscreenTest "+noOnscreenTest);
+ System.err.println("noOffscreenTest "+noOffscreenTest);
System.err.println("shallUseOffscreenPBufferLayer "+shallUseOffscreenPBufferLayer);
if(waitForKey) {
UITestCase.waitForKey("Start");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java
new file mode 100644
index 000000000..9d7a4026b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java
@@ -0,0 +1,130 @@
+/**
+ * Copyright 2013 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 java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestAddRemove03GLWindowNEWT extends UITestCase {
+ static long durationPerTest = 50;
+ static int addRemoveCount = 15;
+ static GLProfile glp;
+ static int width, height;
+ static boolean waitForKey = false;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ width = 640;
+ height = 480;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps, int addRemoveOpCount)
+ throws InterruptedException, InvocationTargetException
+ {
+
+ for(int i=0; i<addRemoveOpCount; i++) {
+ System.err.println("Loop # "+i+" / "+addRemoveCount);
+ final GLWindow glw = GLWindow.create(caps);
+ Assert.assertNotNull(glw);
+ glw.setTitle("GLWindow #"+i);
+ glw.setSize(width, height);
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glw.addGLEventListener(gears);
+
+ glw.setVisible(true);
+
+ final long t0 = System.currentTimeMillis();
+ do {
+ glw.display();
+ Thread.sleep(10);
+ } while ( ( System.currentTimeMillis() - t0 ) < durationPerTest ) ;
+
+ System.err.println("GLWindow: "+glw.getChosenGLCapabilities());
+
+ glw.destroy();
+ }
+ }
+
+ @Test
+ public void test01Onscreen()
+ throws InterruptedException, InvocationTargetException
+ {
+ GLCapabilities caps = new GLCapabilities(glp);
+ runTestGL(caps, addRemoveCount);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ durationPerTest = Long.parseLong(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-loops")) {
+ i++;
+ try {
+ addRemoveCount = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
+ }
+ }
+ System.err.println("waitForKey "+waitForKey);
+
+ System.err.println("addRemoveCount "+addRemoveCount);
+
+ if(waitForKey) {
+ UITestCase.waitForKey("Start");
+ }
+ org.junit.runner.JUnitCore.main(TestAddRemove03GLWindowNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java
index f2fae293b..52fa83b65 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java
@@ -172,7 +172,9 @@ public class TestBug664GLCanvasSetVisibleSwingAWT extends UITestCase {
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
});
- glc.addGLEventListener(new GearsES2());
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glc.addGLEventListener(gears);
final JFrame[] top = new JFrame[] { null };
final Container glcCont = create(top, width, height, i);