29package com.jogamp.opengl.test.junit.jogl.awt;
31import java.awt.BorderLayout;
32import java.awt.Checkbox;
34import java.awt.GridLayout;
36import java.awt.event.ItemEvent;
37import java.awt.event.ItemListener;
38import java.lang.reflect.InvocationTargetException;
40import com.jogamp.opengl.GLCapabilities;
41import com.jogamp.opengl.GLProfile;
42import com.jogamp.opengl.awt.GLCanvas;
44import org.junit.Assert;
45import org.junit.FixMethodOrder;
47import org.junit.runners.MethodSorters;
49import com.jogamp.newt.event.TraceWindowAdapter;
50import com.jogamp.newt.event.awt.AWTWindowAdapter;
51import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
52import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
53import com.jogamp.opengl.test.junit.util.MiscUtils;
54import com.jogamp.opengl.test.junit.util.QuitAdapter;
55import com.jogamp.opengl.test.junit.util.UITestCase;
56import com.jogamp.opengl.util.Animator;
75@FixMethodOrder(MethodSorters.NAME_ASCENDING)
77 static long duration = 1600;
78 static int width=640, height=480;
81 public void test() throws InterruptedException, InvocationTargetException {
84 final Frame frame =
new Frame(
"TestBug816OSXCALayerPos03bAWT");
85 Assert.assertNotNull(frame);
88 Assert.assertNotNull(glCanvas1);
91 final Panel panel =
new Panel(
new GridLayout(1, 1));
95 animator.
add(glCanvas1);
101 final Checkbox checkbox =
new Checkbox(
"Visible canvas",
true);
102 checkbox.addItemListener(
new ItemListener() {
103 public void itemStateChanged(
final ItemEvent ev) {
104 final boolean visible = checkbox.getState();
105 System.err.println(
"XXXX Panel setVisible "+visible);
106 panel.setVisible(visible);
107 System.err.println(
"XXXX Visible: [panel "+panel.isVisible()+
", canvas "+glCanvas1.isVisible()+
"]; Displayable: [panel "+panel.isDisplayable()+
", canvas "+glCanvas1.isDisplayable()+
"]");
108 if( panel.isVisible() ) {
115 frame.setLayout(
new BorderLayout());
116 frame.add(panel, BorderLayout.CENTER);
117 frame.add(checkbox, BorderLayout.NORTH);
119 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
121 frame.setSize(width, height);
122 frame.setVisible(
true);
129 Assert.assertTrue(animator.isAnimating());
131 final long t0 = System.currentTimeMillis();
133 while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
135 t1 = System.currentTimeMillis();
138 Assert.assertNotNull(frame);
139 Assert.assertNotNull(glCanvas1);
141 Assert.assertNotNull(animator);
143 Assert.assertFalse(animator.isAnimating());
144 Assert.assertFalse(animator.
isStarted());
146 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
148 frame.setVisible(
false);
150 Assert.assertEquals(
false, frame.isVisible());
151 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
162 public static void main(
final String args[]) {
163 for(
int i=0; i<args.length; i++) {
164 if(args[i].equals(
"-time")) {
synchronized AWTAdapter addTo(final java.awt.Component awtComponent)
Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one ja...
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getMaxProgrammableCore(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
Returns the highest profile, implementing the programmable shader core pipeline only.
A heavyweight AWT component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
AWT Frame BorderLayout w/ Checkbox North, Panel.GLCanvas Center.
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 long atol(final String str, final long def)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
synchronized boolean isStarted()
Indicates whether this animator has been started.
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.