29package com.jogamp.opengl.test.junit.jogl.awt;
31import java.awt.Dimension;
32import java.awt.Window;
33import java.lang.reflect.InvocationTargetException;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLProfile;
37import com.jogamp.opengl.awt.GLCanvas;
38import javax.swing.JFrame;
39import javax.swing.SwingUtilities;
41import org.junit.Assert;
42import org.junit.Assume;
44import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
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.UITestCase;
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
56 static long durationPerTest = 150;
58 static class Cleanup
implements Runnable {
61 public Cleanup(
final Window w) {
66 System.err.println(
"cleaning up...");
67 window.setVisible(
false);
70 }
catch (
final Throwable t) {
71 Assume.assumeNoException(t);
78 private void testRealizeGLCanvas(
final boolean onAWTEDT,
final boolean setFrameSize)
throws InterruptedException, InvocationTargetException {
79 final Window window =
new JFrame(this.getSimpleTestName(
" - "));
88 final Runnable realizeAction =
new Runnable() {
95 window.setSize(512, 512);
98 final Dimension size =
new Dimension(512, 512);
99 glCanvas.setPreferredSize(size);
100 glCanvas.setMinimumSize(size);
103 window.setVisible(
true);
107 SwingUtilities.invokeAndWait( realizeAction );
119 Assert.assertTrue(
"GLCanvas didn't become displayable", glCanvas.isDisplayable());
120 Assert.assertTrue(
"GLCanvas didn't become realized", glCanvas.
isRealized());
123 System.err.println(
"XXXX-1 reshapeCount "+snapshooter.
getReshapeCount());
124 System.err.println(
"XXXX-1 displayCount "+snapshooter.
getDisplayCount());
127 for (
int wait=0; wait<AWTRobotUtil.POLL_DIVIDER &&
132 System.err.println(
"XXXX-2 reshapeCount "+snapshooter.
getReshapeCount());
133 System.err.println(
"XXXX-2 displayCount "+snapshooter.
getDisplayCount());
135 Assert.assertTrue(
"GLCanvas didn't reshape", snapshooter.
getReshapeCount()>0);
136 Assert.assertTrue(
"GLCanvas didn't display", snapshooter.
getDisplayCount()>0);
138 Thread.sleep(durationPerTest);
144 SwingUtilities.invokeAndWait(
new Cleanup(window));
147 @Test(timeout = 10000)
148 public
void test01RealizeGLCanvasOnAWTEDTUseFrameSize() throws InterruptedException, InvocationTargetException {
149 testRealizeGLCanvas(
true,
true);
152 @Test(timeout = 10000)
153 public
void test02RealizeGLCanvasOnAWTEDTUseGLCanvasSize() throws InterruptedException, InvocationTargetException {
154 testRealizeGLCanvas(
true,
false);
157 @Test(timeout = 10000)
158 public
void test11RealizeGLCanvasOnMainTUseFrameSize() throws InterruptedException, InvocationTargetException {
159 testRealizeGLCanvas(
false,
true);
162 @Test(timeout = 10000)
163 public
void test12RealizeGLCanvasOnMainTUseGLCanvasSize() throws InterruptedException, InvocationTargetException {
164 testRealizeGLCanvas(
false,
false);
167 public static void main(
final String args[]) {
168 org.junit.runner.JUnitCore.main(
TestBug572AWT.class.getName());
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.
final GLDrawable getDelegatedDrawable()
If the implementation uses delegation, return the delegated GLDrawable instance, otherwise return thi...
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Test realize GLCanvas and setVisible(true) AWT-Frames on AWT-EDT and on current thread (non AWT-EDT)
static void main(final String args[])
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
static final int TIME_SLICE
void setMakeSnapshotAlways(final boolean v)
boolean isRealized()
Returns true if this drawable is realized, otherwise false.