29package com.jogamp.opengl.test.junit.jogl.awt;
31import java.awt.BorderLayout;
32import java.awt.Container;
33import java.awt.GridLayout;
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;
41import javax.swing.JCheckBox;
42import javax.swing.JFrame;
43import javax.swing.JPanel;
45import org.junit.Assert;
46import org.junit.FixMethodOrder;
48import org.junit.runners.MethodSorters;
50import com.jogamp.newt.event.TraceWindowAdapter;
51import com.jogamp.newt.event.awt.AWTWindowAdapter;
52import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
53import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
54import com.jogamp.opengl.test.junit.util.MiscUtils;
55import com.jogamp.opengl.test.junit.util.QuitAdapter;
56import com.jogamp.opengl.test.junit.util.UITestCase;
57import com.jogamp.opengl.util.Animator;
76@FixMethodOrder(MethodSorters.NAME_ASCENDING)
78 static long duration = 1600;
79 static int width=640, height=480;
82 public void test() throws InterruptedException, InvocationTargetException {
85 final JFrame frame =
new JFrame(
"TestBug816OSXCALayerPos03cAWT");
86 Assert.assertNotNull(frame);
87 final Container framePane = frame.getContentPane();
90 Assert.assertNotNull(glCanvas1);
93 final JPanel panel =
new JPanel(
new GridLayout(1, 1));
97 animator.
add(glCanvas1);
103 final JCheckBox checkbox =
new JCheckBox(
"Visible canvas",
true);
104 checkbox.addItemListener(
new ItemListener() {
105 public void itemStateChanged(
final ItemEvent ev) {
106 final boolean visible = checkbox.getSelectedObjects()!=
null;
107 System.err.println(
"XXXX Panel setVisible "+visible);
108 panel.setVisible(visible);
109 System.err.println(
"XXXX Visible: [panel "+panel.isVisible()+
", canvas "+glCanvas1.isVisible()+
"]; Displayable: [panel "+panel.isDisplayable()+
", canvas "+glCanvas1.isDisplayable()+
"]");
110 if( panel.isVisible() ) {
117 framePane.setLayout(
new BorderLayout());
118 framePane.add(panel, BorderLayout.CENTER);
119 framePane.add(checkbox, BorderLayout.NORTH);
121 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
123 frame.setSize(width, height);
124 frame.setVisible(
true);
131 Assert.assertTrue(animator.isAnimating());
133 final long t0 = System.currentTimeMillis();
135 while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
137 t1 = System.currentTimeMillis();
140 Assert.assertNotNull(frame);
141 Assert.assertNotNull(glCanvas1);
143 Assert.assertNotNull(animator);
145 Assert.assertFalse(animator.isAnimating());
146 Assert.assertFalse(animator.
isStarted());
148 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
150 frame.setVisible(
false);
152 Assert.assertEquals(
false, frame.isVisible());
153 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
155 framePane.remove(panel);
164 public static void main(
final String args[]) {
165 for(
int i=0; i<args.length; i++) {
166 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 JFrame BorderLayout w/ Checkbox North, JPanel.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.