29package com.jogamp.opengl.test.junit.newt;
31import org.junit.Assert;
32import org.junit.BeforeClass;
34import org.junit.FixMethodOrder;
35import org.junit.runners.MethodSorters;
37import com.jogamp.opengl.*;
39import com.jogamp.newt.*;
40import com.jogamp.newt.event.*;
41import com.jogamp.newt.opengl.*;
42import java.io.IOException;
44import com.jogamp.opengl.test.junit.util.UITestCase;
45import com.jogamp.opengl.test.junit.util.MiscUtils;
46import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
48@FixMethodOrder(MethodSorters.NAME_ASCENDING)
51 static int width, height;
52 static long durationPerTest = 100;
62 final int width,
final int height,
final boolean onscreen,
final boolean addGLEventListenerAfterVisible)
63 throws InterruptedException
65 Assert.assertNotNull(caps);
66 caps.setOnscreen(onscreen);
75 Assert.assertNotNull(glWindow);
78 Assert.assertNotNull(glWindow);
81 Assert.assertEquals(
false,glWindow.
isVisible());
85 setDemoFields(demo, glWindow);
86 if(!addGLEventListenerAfterVisible) {
91 glWindow.
setSize(width, height);
95 Assert.assertEquals(
true,glWindow.
isVisible());
97 System.out.println(
"Frames for initial setVisible(true): "+glWindow.
getTotalFPSFrames());
105 Assert.assertNotNull(caps2);
109 Assert.assertEquals(caps2.
isOnscreen(),onscreen);
111 if(addGLEventListenerAfterVisible) {
119 static void destroyWindow(
final GLWindow glWindow) {
123 Assert.assertEquals(
false,glWindow.
isVisible());
131 Assert.assertNotNull(caps);
132 final GLWindow window = createWindow(
null, caps, width, height,
134 System.out.println(
"Created: "+window);
136 for(state=0; state*100<durationPerTest; state++) {
140 destroyWindow(window);
146 Assert.assertNotNull(caps);
147 final GLWindow window = createWindow(
null, caps, width, height,
149 System.out.println(
"Created: "+window);
151 for(state=0; state*100<durationPerTest; state++) {
155 destroyWindow(window);
161 Assert.assertNotNull(caps);
162 final GLWindow window = createWindow(
null, caps, width, height,
166 Assert.assertEquals(
true,window.
isVisible());
169 Assert.assertEquals(
false,window.
isVisible());
173 Assert.assertEquals(
false,window.
isVisible());
177 Assert.assertEquals(
true,window.
isVisible());
181 Assert.assertEquals(
false,window.
isVisible());
183 destroyWindow(window);
189 Assert.assertNotNull(caps);
190 final GLWindow window = createWindow(
null, caps, width, height,
194 Assert.assertEquals(
true,window.
isVisible());
197 Assert.assertEquals(
false,window.
isVisible());
201 Assert.assertEquals(
false,window.
isVisible());
205 Assert.assertEquals(
true,window.
isVisible());
209 Assert.assertEquals(
false,window.
isVisible());
211 destroyWindow(window);
217 Assert.assertNotNull(caps);
218 final GLWindow window = createWindow(
null, caps, width, height,
221 for(state=0; state*100<durationPerTest; state++) {
225 destroyWindow(window);
231 Assert.assertNotNull(caps);
234 Assert.assertNotNull(display);
237 Assert.assertNotNull(screen);
238 final GLWindow window1 = createWindow(screen, caps, width, height,
240 Assert.assertNotNull(window1);
242 final GLWindow window2 = createWindow(screen, caps, width, height,
244 Assert.assertNotNull(window2);
256 for(state=0; state*100<durationPerTest; state++) {
262 destroyWindow(window1);
263 destroyWindow(window2);
279 Assert.assertNotNull(caps);
282 Assert.assertNotNull(display1);
284 Assert.assertNotNull(display2);
285 Assert.assertNotSame(display1, display2);
288 Assert.assertNotNull(screen1);
289 final GLWindow window1 = createWindow(screen1, caps, width, height,
291 Assert.assertNotNull(window1);
294 Assert.assertNotNull(screen2);
295 final GLWindow window2 = createWindow(screen2, caps, width, height,
297 Assert.assertNotNull(window2);
316 for(state=0; state*100<durationPerTest; state++) {
328 destroyWindow(window1);
329 destroyWindow(window2);
349 Assert.assertNotNull(demo);
350 Assert.assertNotNull(glWindow);
356 static int atoi(
final String a) {
359 i = Integer.parseInt(a);
360 }
catch (
final Exception ex) { ex.printStackTrace(); }
364 public static void main(
final String args[])
throws IOException {
365 for(
int i=0; i<args.length; i++) {
366 if(args[i].equals(
"-time")) {
367 durationPerTest = atoi(args[++i]);
370 System.out.println(
"durationPerTest: "+durationPerTest);
372 org.junit.runner.JUnitCore.
main(tstname);
abstract int getReferenceCount()
static int getActiveDisplayNumber()
abstract EDTUtil getEDTUtil()
abstract boolean isNativeValid()
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.
abstract int getReferenceCount()
abstract boolean isNativeValid()
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final boolean isNativeValid()
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final boolean isVisible()
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 destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
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.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
static void setDemoFields(final GLEventListener demo, final GLWindow glWindow)
void test23WindowTwoWinTwoDisplays()
void test10WindowNativeRecreateSimple()
static void main(final String args[])
void test02WindowSimple()
void test21WindowDestroyWinTwiceA()
void test22WindowTwoWinOneDisplay()
void test11WindowNativeRecreateSimple()
void test01WindowSimple()
static boolean setFieldIfExists(final Object instance, final String fieldName, final Object value)
int getBlueBits()
Returns the number of bits for the color buffer's blue component.
int getRedBits()
Returns the number of bits for the color buffer's red component.
int getGreenBits()
Returns the number of bits for the color buffer's green component.
boolean isOnscreen()
Returns whether an on- or offscreen surface is requested, available or chosen.
long getTotalFPSDuration()
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.