aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-02 02:51:53 +0100
committerSven Gothel <[email protected]>2011-12-02 02:51:53 +0100
commit65dc12ecbaa28f7643ce406860b3f47f53bc29d5 (patch)
tree76c6a4f8d094ee988c09b30a1adbf6cf09753015 /src/test/com/jogamp
parentb6aa455d21fbcfc256ae8f8f4d66493c17e23f4c (diff)
More AWT-EDT invokeAndWait-wrapping for Frame show/dispose
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java15
4 files changed, 54 insertions, 53 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
index 55c9c6812..284122be3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
@@ -30,35 +30,9 @@ package com.jogamp.opengl.test.junit.jogl.awt;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-/**
- * Copyright 2011 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.
- */
import java.awt.image.BufferedImage;
+import java.lang.reflect.InvocationTargetException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
@@ -123,12 +97,19 @@ public class TestBug461OffscreenSupersamplingSwingAWT extends UITestCase impleme
/* @Override */
public void dispose(GLAutoDrawable drawable) {
- jframe.setVisible(false);
- jframe.dispose();
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ jframe.setVisible(false);
+ jframe.dispose();
+ }});
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
@Test
- public void testOffscreenSupersampling() {
+ public void testOffscreenSupersampling() throws InterruptedException, InvocationTargetException {
jframe = new JFrame("Offscreen Supersampling");
Assert.assertNotNull(jframe);
jframe.setSize( 300, 300);
@@ -163,7 +144,10 @@ public class TestBug461OffscreenSupersamplingSwingAWT extends UITestCase impleme
Assert.assertNotNull(offScreenBuffer);
offScreenBuffer.addGLEventListener(this);
offScreenBuffer.display();
- jframe.setVisible( true );
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ jframe.setVisible(true);
+ }});
}
public static void main(String args[]) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
index 6474bb5f6..3c6b3485f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
@@ -41,6 +41,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -65,11 +66,11 @@ public class TestGearsAWT extends UITestCase {
public static void releaseClass() {
}
- protected void runTestGL(GLCapabilities caps) throws InterruptedException {
- Frame frame = new Frame("Gears AWT Test");
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException {
+ final Frame frame = new Frame("Gears AWT Test");
Assert.assertNotNull(frame);
- GLCanvas glCanvas = new GLCanvas(caps);
+ final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
frame.add(glCanvas);
frame.setSize(512, 512);
@@ -82,7 +83,10 @@ public class TestGearsAWT extends UITestCase {
new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas);
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
- frame.setVisible(true);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(true);
+ }});
animator.setUpdateFPSFrames(60, System.err);
animator.start();
@@ -98,14 +102,15 @@ public class TestGearsAWT extends UITestCase {
Assert.assertEquals(false, animator.isAnimating());
frame.setVisible(false);
Assert.assertEquals(false, frame.isVisible());
- frame.remove(glCanvas);
- frame.dispose();
- frame=null;
- glCanvas=null;
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas);
+ frame.dispose();
+ }});
}
@Test
- public void test01() throws InterruptedException {
+ public void test01() throws InterruptedException, InvocationTargetException {
GLCapabilities caps = new GLCapabilities(glp);
runTestGL(caps);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java
index bcc5bb250..4b670f0e1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java
@@ -44,6 +44,7 @@ import java.awt.Frame;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -92,11 +93,11 @@ public class TestGearsAWTAnalyzeBug455 extends UITestCase {
int height) {
}
}
- protected void runTestGL(GLCapabilities caps) throws InterruptedException {
- Frame frame = new Frame("Gears AWT Test");
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException {
+ final Frame frame = new Frame("Gears AWT Test");
Assert.assertNotNull(frame);
- GLCanvas glCanvas = new GLCanvas(caps);
+ final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
glCanvas.setAutoSwapBufferMode(!altSwap);
frame.add(glCanvas);
@@ -111,7 +112,10 @@ public class TestGearsAWTAnalyzeBug455 extends UITestCase {
new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas);
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
- frame.setVisible(true);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(true);
+ }});
animator.setUpdateFPSFrames(60, System.err);
animator.start();
@@ -127,14 +131,15 @@ public class TestGearsAWTAnalyzeBug455 extends UITestCase {
Assert.assertEquals(false, animator.isAnimating());
frame.setVisible(false);
Assert.assertEquals(false, frame.isVisible());
- frame.remove(glCanvas);
- frame.dispose();
- frame=null;
- glCanvas=null;
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.remove(glCanvas);
+ frame.dispose();
+ }});
}
@Test
- public void test01() throws InterruptedException {
+ public void test01() throws InterruptedException, InvocationTargetException {
GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true); // code assumes dbl buffer setup
runTestGL(caps);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
index 429ef59cd..fa7f0f915 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
@@ -42,6 +42,7 @@ import com.jogamp.newt.opengl.*;
import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import com.jogamp.opengl.test.junit.util.*;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -58,7 +59,7 @@ public class TestListenerCom01AWT extends UITestCase {
}
@Test
- public void testListenerStringPassingAndOrder() throws InterruptedException {
+ public void testListenerStringPassingAndOrder() throws InterruptedException, InvocationTargetException {
// setup NEWT GLWindow ..
GLWindow glWindow = GLWindow.create(new GLCapabilities(null));
Assert.assertNotNull(glWindow);
@@ -88,10 +89,13 @@ public class TestListenerCom01AWT extends UITestCase {
// attach NEWT GLWindow to AWT Canvas
NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
- Frame frame = new Frame("AWT Parent Frame");
+ final Frame frame = new Frame("AWT Parent Frame");
frame.add(newtCanvasAWT);
frame.setSize(width, height);
- frame.setVisible(true);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(true);
+ }});
Animator animator1 = new Animator(glWindow);
animator1.setUpdateFPSFrames(1, null);
@@ -104,7 +108,10 @@ public class TestListenerCom01AWT extends UITestCase {
animator1.stop();
Assert.assertEquals(false, animator1.isAnimating());
- frame.dispose();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.dispose();
+ }});
glWindow.destroy();
}