29package com.jogamp.opengl.test.junit.newt;
31import com.jogamp.newt.awt.NewtCanvasAWT;
32import com.jogamp.newt.opengl.GLWindow;
35import org.junit.FixMethodOrder;
36import org.junit.runners.MethodSorters;
37import org.junit.Assert;
39import java.lang.reflect.InvocationTargetException;
41import javax.swing.JFrame;
42import javax.swing.SwingUtilities;
43import javax.swing.WindowConstants;
44import com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode;
45import com.jogamp.opengl.GLCapabilities;
46import com.jogamp.opengl.GLProfile;
48import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
49import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
50import com.jogamp.opengl.test.junit.util.NewtTestUtil;
51import com.jogamp.opengl.test.junit.util.TestUtil;
52import com.jogamp.opengl.test.junit.util.UITestCase;
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
59 final JFrame frame =
new JFrame(
"testCloseJFrameNewtCanvasAWT");
71 SwingUtilities.invokeAndWait(
new Runnable() {
73 frame.getContentPane().add(newtCanvas);
75 frame.setSize(512, 512);
77 frame.setVisible(
true);
81 Assert.assertEquals(
true, frame.isDisplayable());
82 Assert.assertEquals(
true, frame.isVisible());
83 Assert.assertEquals(
true, newtCanvas.isValid());
84 Assert.assertEquals(
true, newtCanvas.isDisplayable());
91 Assert.assertEquals(WindowConstants.HIDE_ON_CLOSE, frame.getDefaultCloseOperation());
100 Assert.assertEquals(
true, frame.isDisplayable());
101 Assert.assertEquals(
false, frame.isVisible());
102 Assert.assertEquals(
true, newtCanvas.isValid());
103 Assert.assertEquals(
true, newtCanvas.isDisplayable());
105 Assert.assertEquals(
true, awtClosingListener.isWindowClosing());
106 Assert.assertEquals(
false, awtClosingListener.isWindowClosed());
107 Assert.assertEquals(
true, newtClosingListener.isWindowClosing());
108 Assert.assertEquals(
false, newtClosingListener.isWindowClosed());
109 awtClosingListener.reset();
110 newtClosingListener.reset();
112 SwingUtilities.invokeAndWait(
new Runnable() {
114 frame.setVisible(
true);
118 Assert.assertEquals(
true, frame.isDisplayable());
119 Assert.assertEquals(
true, frame.isVisible());
125 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
126 Assert.assertEquals(WindowConstants.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation());
135 Assert.assertEquals(
false, frame.isDisplayable());
136 Assert.assertEquals(
false, frame.isVisible());
137 Assert.assertEquals(
false, newtCanvas.isValid());
138 Assert.assertEquals(
false, newtCanvas.isDisplayable());
140 Assert.assertEquals(
true, awtClosingListener.isWindowClosing());
141 Assert.assertEquals(
true, awtClosingListener.isWindowClosed());
142 Assert.assertEquals(
true, newtClosingListener.isWindowClosing());
143 Assert.assertEquals(
true, newtClosingListener.isWindowClosed());
146 public static void main(
final String[] args) {
148 org.junit.runner.JUnitCore.
main(tstname);
AWT Canvas containing a NEWT Window using native parenting.
WindowClosingMode getDefaultCloseOperation()
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final boolean isNativeValid()
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
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.
static void main(final String[] args)
void testCloseJFrameNewtCanvasAWT()
static TestUtil.WindowClosingListener addClosingListener(final java.awt.Window win)
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 TestUtil.WindowClosingListener addClosingListener(final Window win)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
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.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.