summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java49
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol02NEWT.java32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java37
3 files changed, 39 insertions, 79 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java
index c7ac00934..581877e50 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java
@@ -54,14 +54,18 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
- GLCanvas glCanvas = new GLCanvas(caps);
+ final GLCanvas glCanvas = new GLCanvas(caps);
glCanvas.addGLEventListener(new Gears());
- frame.add(glCanvas);
- frame.pack();
- frame.setSize(512, 512);
- frame.validate();
- frame.setVisible(true);
- Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ frame.add(glCanvas);
+ frame.pack();
+ frame.setSize(512, 512);
+ frame.validate();
+ frame.setVisible(true);
+ } });
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true));
//
// close with op: DO_NOTHING_ON_CLOSE -> NOP (default)
@@ -69,11 +73,10 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
int op = glCanvas.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DO_NOTHING_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(frame);
- Assert.assertEquals(true, frame.isVisible());
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // nop
+ Thread.sleep(100);
Assert.assertEquals(true, frame.isDisplayable());
Assert.assertEquals(true, glCanvas.isValid());
- Assert.assertEquals(true, glCanvas.isVisible());
Assert.assertEquals(true, glCanvas.isDisplayable());
//
@@ -83,12 +86,10 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
op = glCanvas.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DISPOSE_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(frame);
- Assert.assertEquals(true, frame.isVisible());
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // no frame close
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, false));
Assert.assertEquals(true, frame.isDisplayable());
- Assert.assertEquals(false, glCanvas.isValid());
- Assert.assertEquals(true, glCanvas.isVisible());
- Assert.assertEquals(false, glCanvas.isDisplayable());
+ Assert.assertEquals(false, glCanvas.isRealized());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -108,8 +109,12 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
frame.pack();
frame.setSize(512, 512);
frame.validate();
- frame.setVisible(true);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ frame.setVisible(true);
+ } });
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true));
//
// close with op: DO_NOTHING_ON_CLOSE -> NOP / HIDE (default)
@@ -118,11 +123,10 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
int op = glCanvas.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DO_NOTHING_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(frame);
- Assert.assertEquals(false, frame.isVisible());
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // nop
+ Thread.sleep(100);
Assert.assertEquals(true, frame.isDisplayable());
Assert.assertEquals(true, glCanvas.isValid());
- Assert.assertEquals(true, glCanvas.isVisible());
Assert.assertEquals(true, glCanvas.isDisplayable());
SwingUtilities.invokeLater(new Runnable() {
@@ -130,6 +134,7 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
frame.setVisible(true);
} });
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true));
//
// close with op (JFrame): DISPOSE_ON_CLOSE -- GLCanvas --> dispose
@@ -139,12 +144,12 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
op = glCanvas.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DISPOSE_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(frame);
- Assert.assertEquals(false, frame.isVisible());
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, false));
Assert.assertEquals(false, frame.isDisplayable());
Assert.assertEquals(false, glCanvas.isValid());
- Assert.assertEquals(true, glCanvas.isVisible());
Assert.assertEquals(false, glCanvas.isDisplayable());
+ Assert.assertEquals(false, glCanvas.isRealized());
}
public static void main(String[] args) {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol02NEWT.java
index f9a6003e7..8f5baece9 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol02NEWT.java
@@ -28,8 +28,6 @@
package com.jogamp.opengl.test.junit.newt;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import org.junit.Test;
@@ -48,28 +46,13 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestWindowClosingProtocol02NEWT extends UITestCase {
- static class NEWTWindowClosingAdapter extends WindowAdapter {
- volatile boolean windowDestroyNotifyReached = false;
-
- public void reset() {
- windowDestroyNotifyReached = false;
- }
- public boolean windowDestroyNotifyReached() {
- return windowDestroyNotifyReached;
- }
- public void windowDestroyNotify(WindowEvent e) {
- windowDestroyNotifyReached = true;
- }
- }
-
@Test
public void testCloseGLWindow() throws InterruptedException, InvocationTargetException {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
final GLWindow glWindow = GLWindow.create(caps);
- final NEWTWindowClosingAdapter newtWindowClosingAdapter = new NEWTWindowClosingAdapter();
+ final AWTRobotUtil.WindowClosingListener windowClosingListener = AWTRobotUtil.addClosingListener(glWindow);
- glWindow.addWindowListener(newtWindowClosingAdapter);
glWindow.addGLEventListener(new Gears());
glWindow.setSize(512, 512);
glWindow.setVisible(true);
@@ -86,12 +69,11 @@ public class TestWindowClosingProtocol02NEWT extends UITestCase {
op = glWindow.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DO_NOTHING_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(glWindow);
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(glWindow, false)); // nop
Assert.assertEquals(true, glWindow.isValid());
- Assert.assertEquals(true, glWindow.isVisible());
Assert.assertEquals(true, glWindow.isNativeValid());
- Assert.assertEquals(true, newtWindowClosingAdapter.windowDestroyNotifyReached());
- newtWindowClosingAdapter.reset();
+ Assert.assertEquals(true, windowClosingListener.isWindowClosing());
+ windowClosingListener.reset();
//
// close with op (GLCanvas): DISPOSE_ON_CLOSE -> dispose
@@ -100,12 +82,10 @@ public class TestWindowClosingProtocol02NEWT extends UITestCase {
op = glWindow.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DISPOSE_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(glWindow);
- Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow, false));
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(glWindow, true));
Assert.assertEquals(true, glWindow.isValid());
- Assert.assertEquals(false, glWindow.isVisible());
Assert.assertEquals(false, glWindow.isNativeValid());
- Assert.assertEquals(true, newtWindowClosingAdapter.windowDestroyNotifyReached());
+ Assert.assertEquals(true, windowClosingListener.isWindowClosing());
}
public static void main(String[] args) {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java
index e69aae992..a10730680 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java
@@ -29,14 +29,11 @@
package com.jogamp.opengl.test.junit.newt;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import org.junit.Test;
import org.junit.Assert;
import java.lang.reflect.InvocationTargetException;
-import java.awt.Frame;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
@@ -44,7 +41,6 @@ import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
@@ -52,20 +48,6 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestWindowClosingProtocol03NewtAWT extends UITestCase {
- static class NEWTWindowClosingAdapter extends WindowAdapter {
- volatile boolean windowDestroyNotifyReached = false;
-
- public void reset() {
- windowDestroyNotifyReached = false;
- }
- public boolean windowDestroyNotifyReached() {
- return windowDestroyNotifyReached;
- }
- public void windowDestroyNotify(WindowEvent e) {
- windowDestroyNotifyReached = true;
- }
- }
-
@Test
public void testCloseJFrameNewtCanvasAWT() throws InterruptedException, InvocationTargetException {
final JFrame frame = new JFrame("testCloseJFrameNewtCanvasAWT");
@@ -73,9 +55,8 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
final GLWindow glWindow = GLWindow.create(caps);
- final NEWTWindowClosingAdapter newtWindowClosingAdapter = new NEWTWindowClosingAdapter();
+ final AWTRobotUtil.WindowClosingListener windowClosingListener = AWTRobotUtil.addClosingListener(glWindow);
- glWindow.addWindowListener(newtWindowClosingAdapter);
glWindow.addGLEventListener(new Gears());
NewtCanvasAWT newtCanvas = new NewtCanvasAWT(glWindow);
@@ -94,17 +75,14 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase {
int op = newtCanvas.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DO_NOTHING_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(frame);
- Assert.assertEquals(false, frame.isVisible());
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false));
Assert.assertEquals(true, frame.isDisplayable());
Assert.assertEquals(true, newtCanvas.isValid());
- Assert.assertEquals(true, newtCanvas.isVisible());
Assert.assertEquals(true, newtCanvas.isDisplayable());
Assert.assertEquals(true, glWindow.isValid());
- Assert.assertEquals(false, glWindow.isVisible());
Assert.assertEquals(true, glWindow.isNativeValid());
- Assert.assertEquals(true, newtWindowClosingAdapter.windowDestroyNotifyReached());
- newtWindowClosingAdapter.reset();
+ Assert.assertEquals(true, windowClosingListener.isWindowClosing());
+ windowClosingListener.reset();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -120,16 +98,13 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase {
op = newtCanvas.getDefaultCloseOperation();
Assert.assertEquals(WindowClosingProtocol.DISPOSE_ON_CLOSE, op);
- AWTRobotUtil.closeWindow(frame);
- Assert.assertEquals(false, frame.isVisible());
+ Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true));
Assert.assertEquals(false, frame.isDisplayable());
Assert.assertEquals(false, newtCanvas.isValid());
- Assert.assertEquals(true, newtCanvas.isVisible());
Assert.assertEquals(false, newtCanvas.isDisplayable());
Assert.assertEquals(true, glWindow.isValid());
- Assert.assertEquals(false, glWindow.isVisible());
Assert.assertEquals(false, glWindow.isNativeValid());
- Assert.assertEquals(true, newtWindowClosingAdapter.windowDestroyNotifyReached());
+ Assert.assertEquals(true, windowClosingListener.isWindowClosing());
}
public static void main(String[] args) {