29package com.jogamp.opengl.test.junit.newt.parenting;
31import java.awt.BorderLayout;
32import java.awt.Button;
34import java.io.IOException;
35import java.lang.reflect.InvocationTargetException;
37import com.jogamp.opengl.GLCapabilities;
38import com.jogamp.opengl.GLEventListener;
39import javax.swing.SwingUtilities;
41import org.junit.Assert;
42import org.junit.BeforeClass;
44import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
47import com.jogamp.newt.Window;
48import com.jogamp.newt.awt.NewtCanvasAWT;
49import com.jogamp.newt.opengl.GLWindow;
50import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
51import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
52import com.jogamp.opengl.test.junit.util.MiscUtils;
53import com.jogamp.opengl.test.junit.util.UITestCase;
54import com.jogamp.opengl.util.Animator;
59@FixMethodOrder(MethodSorters.NAME_ASCENDING)
61 static int width, height;
62 static long durationPerTest = 800;
75 winHopFrame2Frame(
false);
81 winHopFrame2Frame(
true);
84 protected void winHopFrame2Frame(
final boolean detachFirst)
throws InterruptedException, InvocationTargetException {
87 setDemoFields(demo1, glWindow1,
false);
93 setDemoFields(demo2, glWindow2,
false);
100 final Frame frame1 =
new Frame(
"AWT Parent Frame");
101 frame1.setLayout(
new BorderLayout());
102 frame1.add(
new Button(
"North"), BorderLayout.NORTH);
103 frame1.add(
new Button(
"South"), BorderLayout.SOUTH);
104 frame1.add(
new Button(
"East"), BorderLayout.EAST);
105 frame1.add(
new Button(
"West"), BorderLayout.WEST);
106 SwingUtilities.invokeAndWait(
new Runnable() {
108 frame1.setSize(width, height);
109 frame1.setLocation(0, 0);
110 frame1.setVisible(
true);
115 SwingUtilities.invokeAndWait(
new Runnable() {
117 frame1.add(canvas1, BorderLayout.CENTER);
123 final Frame frame2 =
new Frame(
"AWT Parent Frame");
124 frame2.setLayout(
new BorderLayout());
125 frame2.add(
new Button(
"North"), BorderLayout.NORTH);
126 frame2.add(
new Button(
"South"), BorderLayout.SOUTH);
127 frame2.add(
new Button(
"East"), BorderLayout.EAST);
128 frame2.add(
new Button(
"West"), BorderLayout.WEST);
129 SwingUtilities.invokeAndWait(
new Runnable() {
131 frame2.setSize(width, height);
132 frame2.setLocation(width+50, 0);
133 frame2.setVisible(
true);
138 SwingUtilities.invokeAndWait(
new Runnable() {
140 frame2.add(canvas2, BorderLayout.CENTER);
150 for(state=0; state<3; state++) {
151 Thread.sleep(durationPerTest);
154 SwingUtilities.invokeAndWait(
new Runnable() {
173 SwingUtilities.invokeAndWait(
new Runnable() {
194 SwingUtilities.invokeAndWait(
new Runnable() {
206 Assert.assertNotNull(demo);
207 Assert.assertNotNull(glWindow);
218 static int atoi(
final String a) {
221 i = Integer.parseInt(a);
222 }
catch (
final Exception ex) { ex.printStackTrace(); }
226 public static void main(
final String args[])
throws IOException {
227 for(
int i=0; i<args.length; i++) {
228 if(args[i].equals(
"-time")) {
229 durationPerTest = atoi(args[++i]);
233 org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
main(
new String[] {
237 "haltOnFailure=false",
239 "outputtoformatters=true",
240 "logfailedtests=true",
241 "logtestlistenerevents=true",
242 "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
243 "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+
".xml" } );
AWT Canvas containing a NEWT Window using native parenting.
Window setNEWTChild(final Window newChild)
Sets a new NEWT child, provoking reparenting.
NativeWindow getNativeWindow()
Returns the associated NativeWindow of this NativeWindowHolder, which is identical to getNativeSurfac...
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final NativeWindow getParent()
final boolean isNativeValid()
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
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.
Using NewtCanvasAWT#setNEWTChild(Window) for reparenting, i.e.
void winHopFrame2Frame(final boolean detachFirst)
static void setDemoFields(final GLEventListener demo, final GLWindow glWindow, final boolean debug)
static void main(final String args[])
void test02WinHopFrame2FrameDetachFirst()
void test01WinHopFrame2FrameDirectHop()
static boolean setFieldIfExists(final Object instance, final String fieldName, final Object value)
final synchronized boolean start()
Starts this animator, if not running.
Specifying NEWT's Window functionality:
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.