JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestNewtEventModifiersNEWTWindowAWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 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.newt.event;
30
31import com.jogamp.opengl.GLCapabilities;
32import com.jogamp.opengl.GLProfile;
33
34import org.junit.AfterClass ;
35import org.junit.Assert;
36import org.junit.BeforeClass ;
37import org.junit.FixMethodOrder;
38import org.junit.runners.MethodSorters;
39
40import com.jogamp.newt.opengl.GLWindow;
41import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
42import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
43import com.jogamp.opengl.test.junit.util.NewtTestUtil;
44
45/**
46 * Test whether or not event modifiers are properly delivered by NEWT.
47 */
48@FixMethodOrder(MethodSorters.NAME_ASCENDING)
50
51 private static GLWindow _glWindow;
52
53 ////////////////////////////////////////////////////////////////////////////
54
55 @BeforeClass
56 public static void beforeClass() throws Exception {
58
59 _glWindow = GLWindow.create( new GLCapabilities( GLProfile.getGL2ES2() ) );
60 _glWindow.setTitle("Event Modifier Test GLWindow");
61 _glWindow.addGLEventListener( new RedSquareES2() ) ;
62 _glWindow.addMouseListener(_testMouseListener);
63 _glWindow.setSize(TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT);
64 _glWindow.setPosition(TEST_FRAME_X, TEST_FRAME_Y);
65 _glWindow.setVisible(true);
66
67 Assert.assertTrue(NewtTestUtil.waitForVisible(_glWindow, true, null));
68 final GLWindow obj = _glWindow;
69 Assert.assertTrue(NewtTestUtil.waitForRealized(obj, true, null));
70
71 AWTRobotUtil.assertRequestFocusAndWait(null, _glWindow, _glWindow, null, null); // programmatic
72 Assert.assertNotNull(_robot);
73 AWTRobotUtil.requestFocus(_robot, _glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input
74 }
75
76 ////////////////////////////////////////////////////////////////////////////
77
78 @AfterClass
79 public static void afterClass() throws Exception {
80 _glWindow.destroy();
81 }
82
83 ////////////////////////////////////////////////////////////////////////////
84
85 public static void main(final String args[]) throws Exception {
86 final String testName = TestNewtEventModifiersNEWTWindowAWT.class.getName() ;
87 org.junit.runner.JUnitCore.main( testName ) ;
88 }
89
90 ////////////////////////////////////////////////////////////////////////////
91}
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
Definition: GLWindow.java:927
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:525
final void setTitle(final String title)
Definition: GLWindow.java:297
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
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
Test whether or not event modifiers are preserved by NEWT.
static void baseBeforeClass()
Must be called from subclass @BeforeClass code, allowing it to perform its specific initialization fi...
Test whether or not event modifiers are properly delivered by NEWT.
static void requestFocus(final Robot robot, final Object obj)
FIXME: AWTRobotUtil Cleanup: Use specific type for argument object.
static void assertRequestFocusAndWait(final Robot robot, final Object requestFocus, final Object waitForFocus, final FocusEventCountAdapter gain, final FocusEventCountAdapter lost)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final Window win, final boolean visible, final Runnable waitAction)
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.