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.nativewindow.util.RectangleImmutable;
38import com.jogamp.opengl.*;
40import com.jogamp.newt.*;
41import com.jogamp.newt.event.*;
42import com.jogamp.newt.opengl.*;
44import java.io.IOException;
46import com.jogamp.opengl.test.junit.util.UITestCase;
47import com.jogamp.opengl.test.junit.util.MiscUtils;
48import com.jogamp.opengl.test.junit.util.NewtTestUtil;
49import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
51@FixMethodOrder(MethodSorters.NAME_ASCENDING)
55 static final int width = 500, height = 500, xy_pos=100;
56 static long durationPerTest = 100;
65 throws InterruptedException
67 Assert.assertNotNull(caps);
76 setDemoFields(demo, glWindow);
79 glWindow.
setSize(width, height);
83 private void testDisplayCreate01Impl() throws InterruptedException {
88 final GLWindow window = createWindow(caps, width, height);
93 Assert.assertEquals(screen,window.
getScreen());
102 Assert.assertEquals(
false,window.
isVisible());
103 Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
109 Assert.assertEquals(screen,window.
getScreen());
118 Assert.assertEquals(
true,window.
isVisible());
119 Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
120 System.err.println(
"Frames for setVisible(true) 1: "+window.
getTotalFPSFrames());
124 System.err.println(
"screenBoundsInWinU: "+screenBoundsInWinU);
135 Assert.assertEquals(
false,window.
isVisible());
142 Assert.assertEquals(
true,window.
isVisible());
143 Assert.assertTrue(NewtTestUtil.hasPositionMax2xInsetsOr64Pix(window, xy_pos, xy_pos));
144 System.err.println(
"Frames for setVisible(true) 1: "+window.
getTotalFPSFrames());
155 Assert.assertTrue(NewtTestUtil.waitForRealized(window,
false,
null));
156 Assert.assertTrue(NewtTestUtil.waitForRealized(screen,
false,
null));
158 Assert.assertEquals(screen,window.
getScreen());
167 Assert.assertNotNull(window.
getScreen());
169 Assert.assertEquals(
false,window.
isVisible());
178 Assert.assertEquals(
false,window.
isVisible());
183 Assert.assertEquals(screen,window.
getScreen());
192 Assert.assertEquals(
true,window.
isVisible());
193 System.err.println(
"Frames for setVisible(true) 2: "+window.
getTotalFPSFrames());
203 Assert.assertTrue(NewtTestUtil.waitForRealized(window,
false,
null));
204 Assert.assertTrue(NewtTestUtil.waitForRealized(screen,
false,
null));
206 Assert.assertEquals(screen,window.
getScreen());
208 Assert.assertEquals(
false,window.
isVisible());
228 System.err.println(
"Pass - 1");
229 testDisplayCreate01Impl();
230 System.err.println(
"Pass - 2");
231 testDisplayCreate01Impl();
236 private void testDisplayCreate02Impl() throws InterruptedException {
241 final GLWindow window1 = createWindow(caps, width, height);
254 Assert.assertEquals(
false,window1.
isVisible());
255 Assert.assertEquals(xy_pos,window1.
getX());
256 Assert.assertEquals(xy_pos,window1.
getY());
270 Assert.assertEquals(
true,window1.
isVisible());
271 Assert.assertEquals(xy_pos,window1.
getX());
272 Assert.assertEquals(xy_pos,window1.
getY());
273 System.err.println(
"Frames for setVisible(true) 1: "+window1.
getTotalFPSFrames());
277 System.err.println(
"screenBoundsInWinU: "+screenBoundsInWinU);
278 final int x_pos2 = screenBoundsInWinU.
getWidth()-xy_pos-width;
280 final GLWindow window2 = createWindow(caps, width, height);
281 Assert.assertSame(screen, window2.
getScreen());
286 Assert.assertEquals(
false,window2.
isVisible());
287 Assert.assertEquals(x_pos2,window2.
getX());
288 Assert.assertEquals(xy_pos,window2.
getY());
300 Assert.assertEquals(
true,window2.
isVisible());
301 Assert.assertEquals(x_pos2,window2.
getX());
302 Assert.assertEquals(xy_pos,window2.
getY());
303 System.err.println(
"Frames for setVisible(true) 2: "+window2.
getTotalFPSFrames());
315 Assert.assertEquals(
false,window1.
isVisible());
316 Assert.assertEquals(xy_pos,window1.
getX());
317 Assert.assertEquals(xy_pos,window1.
getY());
321 Assert.assertTrue(NewtTestUtil.waitForRealized(window1,
false,
null));
323 Assert.assertNotNull(window1.
getScreen());
325 Assert.assertEquals(
false,window1.
isVisible());
338 Assert.assertTrue(NewtTestUtil.waitForRealized(window2,
false,
null));
339 Assert.assertTrue(NewtTestUtil.waitForRealized(screen,
false,
null));
341 Assert.assertNotNull(window2.
getScreen());
343 Assert.assertEquals(
false,window2.
isVisible());
358 Assert.assertEquals(
false,window1.
isVisible());
363 Assert.assertEquals(
false,window2.
isVisible());
372 System.err.println(
"Pass - 1");
373 testDisplayCreate02Impl();
374 System.err.println(
"Pass - 2");
375 testDisplayCreate02Impl();
381 Assert.assertNotNull(demo);
382 Assert.assertNotNull(glWindow);
388 static int atoi(
final String a) {
391 i = Integer.parseInt(a);
392 }
catch (
final Exception ex) { ex.printStackTrace(); }
396 public static void main(
final String args[])
throws IOException {
397 for(
int i=0; i<args.length; i++) {
398 if(args[i].equals(
"-time")) {
399 durationPerTest = atoi(args[++i]);
402 System.err.println(
"durationPerTest: "+durationPerTest);
404 org.junit.runner.JUnitCore.
main(tstname);
abstract int getReferenceCount()
static int getActiveDisplayNumber()
abstract EDTUtil getEDTUtil()
abstract boolean isNativeValid()
static void dumpDisplayList(final String prefix)
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract Display getDisplay()
abstract RectangleImmutable getViewportInWindowUnits()
See Coordinate System.
static int getActiveScreenNumber()
abstract int getReferenceCount()
abstract boolean isNativeValid()
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final boolean isNativeValid()
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.
final int getX()
Returns the current x position of this window, relative to it's parent.
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
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)
static void main(final String args[])
void testDisplayCreate02()
void testDisplayCreate01()
static boolean setFieldIfExists(final Object instance, final String fieldName, final Object value)
Immutable Rectangle interface, with its position on the top-left.
void setUpdateFPSFrames(int frames, PrintStream out)
void resetFPSCounter()
Reset all performance counter (startTime, currentTime, frame number)
long getTotalFPSDuration()
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.