JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestBug675BeansInDesignTimeAWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2013 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.jogl.awt;
30
31import java.awt.BorderLayout;
32import java.awt.Dimension;
33import java.awt.Window;
34import java.beans.Beans;
35import java.lang.reflect.InvocationTargetException;
36
37import com.jogamp.opengl.GLCapabilities;
38import com.jogamp.opengl.GLProfile;
39import com.jogamp.opengl.awt.GLCanvas;
40import javax.swing.JFrame;
41import javax.swing.SwingUtilities;
42
43import org.junit.Assert;
44import org.junit.Test;
45import org.junit.FixMethodOrder;
46import org.junit.runners.MethodSorters;
47
48import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
49import com.jogamp.opengl.test.junit.util.MiscUtils;
50import com.jogamp.opengl.test.junit.util.UITestCase;
51
52@FixMethodOrder(MethodSorters.NAME_ASCENDING)
54 static boolean waitForKey = false;
55 static long durationPerTest = 200;
56
57 @Test
58 public void test01() throws InterruptedException, InvocationTargetException {
59 Beans.setDesignTime(true);
60
62 final GLCanvas glCanvas = new GLCanvas(caps);
63 final Dimension preferredGLSize = new Dimension(400,200);
64 glCanvas.setPreferredSize(preferredGLSize);
65 glCanvas.setMinimumSize(preferredGLSize);
66 glCanvas.setSize(preferredGLSize);
67
68 glCanvas.addGLEventListener(new GearsES2());
69
70 final Window window = new JFrame(this.getSimpleTestName(" - "));
71 window.setLayout(new BorderLayout());
72 window.add(glCanvas, BorderLayout.CENTER);
73
74 // trigger realization on AWT-EDT, otherwise it won't immediatly ..
75 SwingUtilities.invokeAndWait(new Runnable() {
76 @Override
77 public void run() {
78 window.pack();
79 window.validate();
80 window.setVisible(true);
81 }
82 } );
83
84 // Immediately displayable after issuing initial setVisible(true) on AWT-EDT!
85 Assert.assertTrue("GLCanvas didn't become displayable", glCanvas.isDisplayable());
86 if( !Beans.isDesignTime() ) {
87 Assert.assertTrue("GLCanvas didn't become realized", glCanvas.isRealized());
88 }
89
90 Thread.sleep(durationPerTest);
91
92 SwingUtilities.invokeAndWait(new Runnable() {
93 @Override
94 public void run() {
95 window.dispose();
96 }
97 } );
98 }
99
100 public static void main(final String args[]) {
101 for(int i=0; i<args.length; i++) {
102 if(args[i].equals("-time")) {
103 durationPerTest = MiscUtils.atol(args[++i], durationPerTest);
104 } else if(args[i].equals("-wait")) {
105 waitForKey = true;
106 }
107 }
108 if(waitForKey) {
109 UITestCase.waitForKey("Start");
110 }
111 org.junit.runner.JUnitCore.main(TestBug675BeansInDesignTimeAWT.class.getName());
112 }
113}
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Definition: GLProfile.java:913
A heavyweight AWT component which provides OpenGL rendering support.
Definition: GLCanvas.java:170
boolean isRealized()
Returns true if this drawable is realized, otherwise false.
Definition: GLCanvas.java:480
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Definition: GLCanvas.java:1065
static long atol(final String str, final long def)
Definition: MiscUtils.java:66
void setSize(int width, int height)
Requests a new width and height for this AWTGLAutoDrawable.