29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.awt.AWTException;
33import java.io.IOException;
34import java.lang.reflect.InvocationTargetException;
36import com.jogamp.opengl.GLAutoDrawable;
37import com.jogamp.opengl.GLCapabilities;
38import com.jogamp.opengl.GLException;
39import com.jogamp.opengl.GLProfile;
41import org.junit.Assert;
43import org.junit.FixMethodOrder;
44import org.junit.runners.MethodSorters;
46import com.jogamp.common.util.InterruptSource;
47import com.jogamp.newt.event.KeyEvent;
48import com.jogamp.newt.event.KeyListener;
49import com.jogamp.newt.event.MouseAdapter;
50import com.jogamp.newt.event.MouseEvent;
51import com.jogamp.newt.event.MouseListener;
52import com.jogamp.newt.event.WindowAdapter;
53import com.jogamp.newt.event.WindowEvent;
54import com.jogamp.newt.opengl.GLWindow;
55import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
56import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
57import com.jogamp.opengl.test.junit.util.NewtTestUtil;
58import com.jogamp.opengl.test.junit.util.UITestCase;
59import com.jogamp.opengl.util.Animator;
61@FixMethodOrder(MethodSorters.NAME_ASCENDING)
64 static long duration = 100;
66 static void destroyGLAD(
final GLAutoDrawable glad,
final int mode) {
67 final String tname = Thread.currentThread().toString();
68 System.err.println(tname+
": Destroy mode "+mode+
": Start: Realised "+glad.
isRealized());
70 System.err.println(tname+
": Destroy mode "+mode+
": End: Realised "+glad.
isRealized());
80 protected void runTestGL(
final int destroyMode)
throws InterruptedException, InvocationTargetException, AWTException {
81 final Robot robot =
new Robot();
82 robot.setAutoWaitForIdle(
true);
87 Assert.assertNotNull(glWindow);
88 glWindow.
setTitle(
"TestDestroyGLAutoDrawableNewtAWT Mode "+destroyMode);
95 public void windowDestroyNotify(
final WindowEvent e) {
96 System.err.println(
"Window DestroyNotify: "+e);
101 System.err.println(
"Window Destroyed: "+e);
105 public void windowGainedFocus(
final WindowEvent e) {
106 System.err.println(
"Window Focus Gained: "+e);
111 System.err.println(
"Window Focus Lost: "+e);
116 public void keyPressed(
final KeyEvent e) {
117 System.err.println(
"KEY PRESSED: "+e);
120 public void keyReleased(
final KeyEvent e) {
121 System.err.println(
"KEY RELEASED: "+e);
127 destroyGLAD(glWindow, 10);
134 public void mousePressed(
final MouseEvent e) {
135 System.err.println(
"MOUSE PRESSED: "+e);
138 public void mouseReleased(
final MouseEvent e) {
139 System.err.println(
"MOUSE RELEASED: "+e);
142 public void mouseClicked(
final MouseEvent e) {
143 System.err.println(
"MOUSE CLICKED: "+e);
144 destroyGLAD(glWindow, 11);
160 System.err.println(
"AWT Robot Init");
161 final java.awt.Point objCenter;
164 objCenter =
new java.awt.Point(oc[0], oc[1]);
170 System.err.println(
"AWT Robot OK");
172 switch( destroyMode ) {
184 System.err.println(
"Expected exception: "+gle.getMessage());
193 new InterruptSource.Thread( () -> { destroyGLAD(glWindow, 3); } ).start();
210 destroyGLAD(glWindow, 0);
217 Assert.assertEquals(
false, animator.isAnimating());
221 public void test00OnThread() throws InterruptedException, InvocationTargetException, AWTException {
226 public void test01RenderThread() throws InterruptedException, InvocationTargetException, AWTException {
231 public void test02EDTThread() throws InterruptedException, InvocationTargetException, AWTException {
236 public void test03ExtThread() throws InterruptedException, InvocationTargetException, AWTException {
241 public void test10EDTKeyEvent() throws InterruptedException, InvocationTargetException, AWTException {
250 public static void main(
final String args[])
throws IOException {
252 org.junit.runner.JUnitCore.
main(tstname);
static final short VK_Q
See VK_A.
final short getKeyCode()
Returns the virtual key code using a fixed mapping to the US keyboard layout.
Pointer event of type PointerType.
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final boolean isNativeValid()
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
final void setTitle(final String title)
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
final void runOnEDTIfAvail(final boolean wait, final Runnable task)
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
static void main(final String args[])
void test01RenderThread()
void runTestGL(final int destroyMode)
void test11EDTMouseEvent()
static final int ROBOT_DELAY
static void awtRobotMouseMove(final Robot robot, final int x, final int y)
static int newtKeyPress(final int i, final Robot robot, final boolean press, final short newtKeyCode, final int msDelay)
No validation is performed .
static int[] getCenterLocation(final Object obj, final boolean onTitleBarIfWindow)
static void mouseClick(final Robot robot, final Point pos, final int moveIter, final int moveDelay, final int actionDelay)
static void assertRequestFocusAndWait(final Robot robot, final Object requestFocus, final Object waitForFocus, final FocusEventCountAdapter gain, final FocusEventCountAdapter lost)
static void waitForIdle(final Robot robot)
Issuing validateAWTEDTIsAlive() before calling Robot#waitForIdle().
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
final long getTotalFPSDuration()
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Listener for MouseEvents.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
boolean invoke(boolean wait, GLRunnable glRunnable)
Enqueues a one-shot GLRunnable, which will be executed within the next display() call after all regis...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
boolean isRealized()
Returns true if this drawable is realized, otherwise false.