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.*;
39import com.jogamp.newt.*;
40import java.io.IOException;
42import com.jogamp.opengl.test.junit.util.MiscUtils;
43import com.jogamp.opengl.test.junit.util.UITestCase;
45@FixMethodOrder(MethodSorters.NAME_ASCENDING)
47 static int width, height;
48 static long durationPerTest = 100;
57 static Window createWindow(
final Capabilities caps,
final int x,
final int y,
final int width,
final int height,
final boolean onscreen,
final boolean undecorated)
throws InterruptedException {
58 final boolean userPos = x>=0 && y>=0 ;
60 Assert.assertNotNull(caps);
61 caps.setOnscreen(onscreen);
68 Assert.assertNotNull(window);
77 Assert.assertEquals(
false,window.
isVisible());
83 Assert.assertEquals(
true,window.
isVisible());
85 Assert.assertEquals(width, window.
getWidth());
86 Assert.assertEquals(height, window.
getHeight());
89 Assert.assertNotNull(chosenCapabilities);
91 Assert.assertTrue(chosenCapabilities.
getBlueBits()>=5);
92 Assert.assertTrue(chosenCapabilities.
getRedBits()>=5);
93 Assert.assertEquals(chosenCapabilities.
isOnscreen(),onscreen);
98 static void destroyWindow(
final Window window,
final boolean last) {
114 Assert.assertEquals(
false,window.
isVisible());
121 Assert.assertNotNull(caps);
123 final Window window = createWindow(caps, -1, -1, width, height,
true ,
false );
125 System.err.println(
"XXX: "+chosenCapabilities);
126 for(
int state=0; state*100<durationPerTest; state++) {
129 destroyWindow(window,
true);
135 Assert.assertNotNull(caps);
138 final Window window = createWindow(caps, -1, -1, width, height,
true ,
false );
140 System.err.println(
"XXX: "+chosenCapabilities);
141 for(
int state=0; state*100<durationPerTest; state++) {
144 destroyWindow(window,
true);
147 public static void main(
final String args[])
throws IOException {
148 for(
int i=0; i<args.length; i++) {
149 if(args[i].equals(
"-time")) {
150 durationPerTest =
MiscUtils.
atol(args[++i], durationPerTest);
153 System.out.println(
"durationPerTest: "+durationPerTest);
155 org.junit.runner.JUnitCore.
main(tstname);
Specifies a set of capabilities that a window's rendering context must support, such as color depth p...
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
static synchronized void initSingleton()
Static one time initialization of this factory.
abstract boolean isNativeValid()
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract Display getDisplay()
abstract boolean isNativeValid()
static void main(final String args[])
void test01WindowDefault()
void test02WindowDefault()
static long atol(final String str, final long def)
CapabilitiesImmutable getChosenCapabilities()
Return the capabilities reflecting this graphics configuration, which may differ from the capabilitie...
Specifies an immutable set of capabilities that a window's rendering context must support,...
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.
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
Specifying NEWT's Window functionality:
void setSize(int width, int height)
Sets the size of the window's client area in window units, excluding decorations.
void setVisible(boolean visible)
Calls setVisible(true, visible), i.e.
void setPosition(int x, int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
void setUndecorated(boolean value)
void destroy()
Destroys this window incl.releasing all related resources.