29package com.jogamp.opengl.test.junit.jogl.awt;
31import java.awt.BorderLayout;
32import java.awt.Checkbox;
34import java.awt.event.ItemEvent;
35import java.awt.event.ItemListener;
36import java.lang.reflect.InvocationTargetException;
38import com.jogamp.opengl.GLCapabilities;
39import com.jogamp.opengl.GLProfile;
40import com.jogamp.opengl.awt.GLCanvas;
42import org.junit.Assert;
43import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
47import com.jogamp.newt.event.TraceWindowAdapter;
48import com.jogamp.newt.event.awt.AWTWindowAdapter;
49import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
50import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
51import com.jogamp.opengl.test.junit.util.MiscUtils;
52import com.jogamp.opengl.test.junit.util.QuitAdapter;
53import com.jogamp.opengl.test.junit.util.UITestCase;
54import com.jogamp.opengl.util.Animator;
72@FixMethodOrder(MethodSorters.NAME_ASCENDING)
74 static long duration = 1600;
75 static int width=640, height=480;
78 public void test() throws InterruptedException, InvocationTargetException {
81 final Frame frame =
new Frame(
"TestBug816OSXCALayerPos03aAWT");
82 Assert.assertNotNull(frame);
85 Assert.assertNotNull(glCanvas1);
89 animator.
add(glCanvas1);
95 final Checkbox checkbox =
new Checkbox(
"Visible canvas",
true);
96 checkbox.addItemListener(
new ItemListener() {
97 public void itemStateChanged(
final ItemEvent ev) {
98 final boolean visible = checkbox.getState();
99 System.err.println(
"XXXX Canvas setVisible "+visible);
100 glCanvas1.setVisible(visible);
101 System.err.println(
"XXXX Canvas visible: "+glCanvas1.isVisible());
102 if( glCanvas1.isVisible() ) {
109 frame.setLayout(
new BorderLayout());
110 frame.add(glCanvas1, BorderLayout.CENTER);
111 frame.add(checkbox, BorderLayout.NORTH);
113 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
115 frame.setSize(width, height);
116 frame.setVisible(
true);
123 Assert.assertTrue(animator.isAnimating());
125 final long t0 = System.currentTimeMillis();
127 while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
129 t1 = System.currentTimeMillis();
132 Assert.assertNotNull(frame);
133 Assert.assertNotNull(glCanvas1);
135 Assert.assertNotNull(animator);
137 Assert.assertFalse(animator.isAnimating());
138 Assert.assertFalse(animator.
isStarted());
140 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
142 frame.setVisible(
false);
144 Assert.assertEquals(
false, frame.isVisible());
145 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
147 frame.remove(glCanvas1);
156 public static void main(
final String args[]) {
157 for(
int i=0; i<args.length; i++) {
158 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, 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.