29package com.jogamp.opengl.test.junit.newt.parenting;
31import java.io.IOException;
32import java.lang.reflect.InvocationTargetException;
34import com.jogamp.opengl.GLCapabilities;
35import com.jogamp.opengl.GLEventListener;
37import org.eclipse.swt.SWT;
38import org.eclipse.swt.layout.FillLayout;
39import org.eclipse.swt.widgets.Composite;
40import org.eclipse.swt.widgets.Display;
41import org.eclipse.swt.widgets.Shell;
42import org.junit.After;
43import org.junit.Assert;
44import org.junit.Assume;
45import org.junit.Before;
46import org.junit.BeforeClass;
48import org.junit.FixMethodOrder;
49import org.junit.runners.MethodSorters;
51import com.jogamp.nativewindow.swt.SWTAccessor;
52import com.jogamp.newt.NewtFactory;
53import com.jogamp.newt.Window;
54import com.jogamp.newt.opengl.GLWindow;
55import com.jogamp.newt.swt.NewtCanvasSWT;
56import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
57import com.jogamp.opengl.test.junit.util.MiscUtils;
58import com.jogamp.opengl.test.junit.util.SWTTestUtil;
59import com.jogamp.opengl.test.junit.util.UITestCase;
64@FixMethodOrder(MethodSorters.NAME_ASCENDING)
66 static int width, height;
67 static long durationPerTest = 800;
70 Display display =
null;
72 Composite composite1 =
null;
86 display =
new Display();
87 Assert.assertNotNull( display );
92 shell =
new Shell( display );
93 Assert.assertNotNull( shell );
94 shell.setLayout(
new FillLayout() );
95 composite1 =
new Composite( shell, SWT.NONE );
96 composite1.setLayout(
new FillLayout() );
97 Assert.assertNotNull( composite1 );
104 Assert.assertNotNull( display );
105 Assert.assertNotNull( shell );
106 Assert.assertNotNull( composite1 );
110 composite1.dispose();
115 catch(
final Throwable throwable ) {
116 throwable.printStackTrace();
117 Assume.assumeNoException( throwable );
119 swtNewtDisplay =
null;
130 Assert.assertNotNull(glWindow1);
131 Assert.assertEquals(
false, glWindow1.
isVisible());
133 Assert.assertNull(glWindow1.
getParent());
134 glWindow1.
setTitle(
"testWindowParenting01CreateVisibleDestroy");
136 setDemoFields(demo1, glWindow1,
false);
140 Assert.assertNotNull(canvas1);
141 Assert.assertEquals(
false, glWindow1.
isVisible());
143 Assert.assertNull(glWindow1.
getParent());
147 shell.setText( getSimpleTestName(
".") );
148 shell.setSize( 640, 480 );
158 for(
int i=0; i*10<durationPerTest; i++) {
159 generalWaitAction.
run();
164 canvas1.setVisible(
false);
171 canvas1.setVisible(
true);
185 Assert.assertNotNull(demo);
186 Assert.assertNotNull(glWindow);
197 static int atoi(
final String a) {
200 i = Integer.parseInt(a);
201 }
catch (
final Exception ex) { ex.printStackTrace(); }
205 public static void main(
final String args[])
throws IOException {
206 for(
int i=0; i<args.length; i++) {
207 if(args[i].equals(
"-time")) {
208 durationPerTest = atoi(args[++i]);
static void invokeOnOSTKThread(final boolean blocking, final Runnable runnable)
Runs the specified action in an SWT compatible OS toolkit thread, which is:
static void invokeOnSWTThread(final org.eclipse.swt.widgets.Display display, final boolean blocking, final Runnable runnable)
Runs the specified action on the SWT UI thread.
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final NativeWindow getParent()
final boolean isNativeValid()
final void setTitle(final String title)
final boolean isVisible()
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...
SWT Canvas containing a NEWT Window using native parenting.
NativeWindow getNativeWindow()
Returns the associated NativeWindow of this NativeWindowHolder, which is identical to getNativeSurfac...
static NewtCanvasSWT create(final Composite parent, final int style, final Window child)
Creates an instance using NewtCanvasSWT(Composite, int, Window) on the SWT thread.
void dispose()
Destroys this resource:
Specifies a set of OpenGL capabilities.
static void setDemoFields(final GLEventListener demo, final GLWindow glWindow, final boolean debug)
static void main(final String args[])
void testWindowParenting01CreateVisibleDestroy1()
static boolean setFieldIfExists(final Object instance, final String fieldName, final Object value)
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.