29package com.jogamp.opengl.test.junit.newt;
32import org.junit.FixMethodOrder;
33import org.junit.runners.MethodSorters;
34import org.junit.Assert;
36import java.lang.reflect.InvocationTargetException;
39import javax.swing.JFrame;
40import javax.swing.SwingUtilities;
41import javax.swing.WindowConstants;
42import com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode;
43import com.jogamp.opengl.GLCapabilities;
44import com.jogamp.opengl.GLProfile;
45import com.jogamp.opengl.awt.GLCanvas;
47import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
48import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
49import com.jogamp.opengl.test.junit.util.TestUtil;
50import com.jogamp.opengl.test.junit.util.TestUtil.WindowClosingListener;
51import com.jogamp.opengl.test.junit.util.UITestCase;
53@FixMethodOrder(MethodSorters.NAME_ASCENDING)
58 final Frame frame =
new Frame(
"testCloseFrameGLCanvas AWT");
64 SwingUtilities.invokeAndWait(
new Runnable() {
68 frame.setSize(512, 512);
70 frame.setVisible(
true);
83 Assert.assertEquals(
true, frame.isDisplayable());
84 Assert.assertEquals(
true, frame.isVisible());
85 Assert.assertEquals(
true, glCanvas.isValid());
86 Assert.assertEquals(
true, glCanvas.isDisplayable());
87 Assert.assertEquals(
true, closingListener.isWindowClosing());
88 Assert.assertEquals(
false, closingListener.isWindowClosed());
101 Assert.assertEquals(
true, frame.isDisplayable());
102 Assert.assertEquals(
true, frame.isVisible());
103 Assert.assertEquals(
true, closingListener.isWindowClosing());
104 Assert.assertEquals(
false, closingListener.isWindowClosed());
105 for (
int wait=0; wait<AWTRobotUtil.POLL_DIVIDER && glCanvas.
isRealized(); wait++) {
108 Assert.assertEquals(
false, glCanvas.
isRealized());
110 SwingUtilities.invokeAndWait(
new Runnable() {
118 final JFrame frame =
new JFrame(
"testCloseJFrameGLCanvas AWT");
125 SwingUtilities.invokeAndWait(
new Runnable() {
127 frame.getContentPane().add(glCanvas);
129 frame.setSize(512, 512);
131 frame.setVisible(
true);
139 Assert.assertEquals(WindowConstants.HIDE_ON_CLOSE, frame.getDefaultCloseOperation());
147 Assert.assertEquals(
true, frame.isDisplayable());
148 Assert.assertEquals(
false, frame.isVisible());
149 Assert.assertEquals(
true, glCanvas.isValid());
150 Assert.assertEquals(
true, glCanvas.isDisplayable());
152 SwingUtilities.invokeAndWait(
new Runnable() {
154 frame.setVisible(
true);
158 Assert.assertEquals(
true, frame.isDisplayable());
159 Assert.assertEquals(
true, frame.isVisible());
164 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
165 Assert.assertEquals(WindowConstants.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation());
171 Assert.assertEquals(
false, frame.isDisplayable());
172 Assert.assertEquals(
false, glCanvas.isValid());
173 Assert.assertEquals(
false, glCanvas.isDisplayable());
174 Assert.assertEquals(
false, glCanvas.
isRealized());
177 public static void main(
final String[] args) {
179 org.junit.runner.JUnitCore.
main(tstname);
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
A heavyweight AWT component which provides OpenGL rendering support.
boolean isRealized()
Returns true if this drawable is realized, otherwise false.
WindowClosingMode setDefaultCloseOperation(final WindowClosingMode op)
WindowClosingMode getDefaultCloseOperation()
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
static void main(final String[] args)
void testCloseFrameGLCanvas()
void testCloseJFrameGLCanvas()
static TestUtil.WindowClosingListener addClosingListener(final java.awt.Window win)
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
static boolean closeWindow(final java.awt.Window win, final boolean willClose, final TestUtil.WindowClosingListener closingListener, final Runnable waitAction)
Programmatically issue windowClosing on AWT or NEWT.
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
static final int TIME_SLICE
Window closing mode if triggered by toolkit close operation.
DO_NOTHING_ON_CLOSE
Do nothing on native window close operation.
DISPOSE_ON_CLOSE
Dispose resources on native window close operation.