summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-23 00:31:14 +0100
committerSven Gothel <[email protected]>2011-12-23 00:31:14 +0100
commitf3f794fe37a7e33a771a4a702f3f46ead4dc6d03 (patch)
treeb51202da10c96444f7744e4e66864bcf957f2d50 /src/test/com
parentd225d0a8a16e362ddb14cb93c124eb06cf0ff05e (diff)
NEWT Multi-Monitor 1/2: Allow negative window position; Validate Screen-Index;
- Allow negative window position, using flag 'autoPosition' to mark a custom user position. This impacts Windows and X11 window creation code, which supports native auto positioning. - Screen: Validate Screen-Index. In 'big-desktop' mode the Screen index is always 0. This is true for X11 with Xinerama enabled and MS-Windows in general. Platforms w/o multiple Screen support always use index 0. - X11: Separate X11 Display/Screen/Window native code in their respective C files - Windows test scripts: use '%*' to catch all arguments - Add missing (c)
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java114
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java33
2 files changed, 112 insertions, 35 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index e57b26f76..faa7eb311 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -32,8 +32,13 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import com.jogamp.newt.Display;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
@@ -42,6 +47,11 @@ import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.PointImmutable;
+import javax.media.nativewindow.util.DimensionImmutable;
+
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
@@ -55,8 +65,23 @@ import org.junit.Test;
public class TestGearsES2NEWT extends UITestCase {
static GLProfile glp;
- static int width, height;
+
+ static int screenIdx = 0;
+ static PointImmutable wpos;
+ static DimensionImmutable wsize;
+ static long duration = 500; // ms
+ static boolean opaque = true;
+ static boolean undecorated = false;
+ static boolean alwaysOnTop = false;
+ static boolean fullscreen = false;
+ static boolean pmvUseBackingArray = true;
+ static boolean vsync = false;
+ static boolean waitForKey = false;
+ static boolean mouseVisible = true;
+ static boolean mouseConfined = false;
+ static boolean showFPS = false;
+
@BeforeClass
public static void initClass() {
/*if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES2)) {
@@ -67,10 +92,9 @@ public class TestGearsES2NEWT extends UITestCase {
glp = GLProfile.getGL2ES2();
}
Assert.assertNotNull(glp);
- // width = 512;
- // height = 512;
- width = 200;
- height = 200;
+ if(null == wsize) {
+ wsize = new Dimension(200, 200);
+ }
}
@AfterClass
@@ -79,11 +103,15 @@ public class TestGearsES2NEWT extends UITestCase {
protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException {
System.err.println("requested: "+caps);
- final GLWindow glWindow = GLWindow.create(caps);
+ Display dpy = NewtFactory.createDisplay(null);
+ Screen screen = NewtFactory.createScreen(dpy, screenIdx);
+ final GLWindow glWindow = GLWindow.create(screen, caps);
Assert.assertNotNull(glWindow);
- glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+")");
- glWindow.setSize(width, height);
- glWindow.setPosition(100, 100);
+ glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), size "+wsize+", pos "+wpos);
+ glWindow.setSize(wsize.getWidth(), wsize.getHeight());
+ if(null != wpos) {
+ glWindow.setPosition(wpos.getX(), wpos.getY());
+ }
glWindow.setUndecorated(undecorated);
glWindow.setAlwaysOnTop(alwaysOnTop);
glWindow.setFullscreen(fullscreen);
@@ -122,6 +150,15 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.addKeyListener(quitAdapter);
glWindow.addWindowListener(quitAdapter);
+ glWindow.addWindowListener(new WindowAdapter() {
+ public void windowResized(WindowEvent e) {
+ System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
+ }
+ public void windowMoved(WindowEvent e) {
+ System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
+ }
+ });
+
glWindow.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
if(e.getKeyChar()=='f') {
@@ -188,14 +225,14 @@ public class TestGearsES2NEWT extends UITestCase {
}
});
- animator.setUpdateFPSFrames(60, System.err);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
animator.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
- System.err.println("size/pos: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
System.err.println("chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
@@ -212,25 +249,22 @@ public class TestGearsES2NEWT extends UITestCase {
runTestGL(caps, undecorated);
}
- static long duration = 500; // ms
- static boolean opaque = true;
- static boolean undecorated = false;
- static boolean alwaysOnTop = false;
- static boolean fullscreen = false;
- static boolean pmvUseBackingArray = true;
- static boolean vsync = false;
- static boolean waitForKey = false;
- static boolean mouseVisible = true;
- static boolean mouseConfined = false;
-
+ static int atoi(String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (Exception ex) { throw new RuntimeException(ex); }
+ }
+
public static void main(String args[]) throws IOException {
+ int x=0, y=0, w=200, h=200;
+ boolean useSize = false;
+ boolean usePos = false;
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
- try {
- duration = Integer.parseInt(args[i]);
- } catch (Exception ex) { ex.printStackTrace(); }
+ duration = atoi(args[i]);
} else if(args[i].equals("-translucent")) {
opaque = false;
} else if(args[i].equals("-undecorated")) {
@@ -249,8 +283,38 @@ public class TestGearsES2NEWT extends UITestCase {
mouseVisible = false;
} else if(args[i].equals("-mouseConfine")) {
mouseConfined = true;
+ } else if(args[i].equals("-showFPS")) {
+ showFPS = true;
+ } else if(args[i].equals("-width")) {
+ i++;
+ w = atoi(args[i]);
+ useSize = true;
+ } else if(args[i].equals("-height")) {
+ i++;
+ h = atoi(args[i]);
+ useSize = true;
+ } else if(args[i].equals("-x")) {
+ i++;
+ x = atoi(args[i]);
+ usePos = true;
+ } else if(args[i].equals("-y")) {
+ i++;
+ y = atoi(args[i]);
+ usePos = true;
+ } else if(args[i].equals("-screen")) {
+ i++;
+ screenIdx = atoi(args[i]);
}
}
+ if(useSize) {
+ wsize = new Dimension(w, h);
+ }
+ if(usePos) {
+ wpos = new Point(x, y);
+ }
+ System.err.println("position "+wpos);
+ System.err.println("size "+wsize);
+ System.err.println("screen "+screenIdx);
System.err.println("translucent "+(!opaque));
System.err.println("undecorated "+undecorated);
System.err.println("atop "+alwaysOnTop);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
index 985affa92..7bd421234 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
@@ -35,10 +35,12 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.util.MonitorMode;
import com.jogamp.newt.util.ScreenModeUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -50,6 +52,7 @@ import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.SurfaceSize;
public class TestScreenMode00NEWT extends UITestCase {
+ static int screenIdx = 0;
static int width, height;
static int waitTimeShort = 4; //1 sec
@@ -64,7 +67,7 @@ public class TestScreenMode00NEWT extends UITestCase {
height = 480;
}
- @Test
+ // @Test
public void testScreenModeInfo00() throws InterruptedException {
DimensionImmutable res = new Dimension(640, 480);
SurfaceSize surfsz = new SurfaceSize(res, 32);
@@ -95,12 +98,12 @@ public class TestScreenMode00NEWT extends UITestCase {
@Test
public void testScreenModeInfo01() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Window window = NewtFactory.createWindow(caps);
- window.setSize(width, height);
- window.setVisible(true);
-
- Screen screen = window.getScreen();
+ Display dpy = NewtFactory.createDisplay(null);
+ Screen screen = NewtFactory.createScreen(dpy, screenIdx);
+ screen.addReference();
+ Assert.assertEquals(true,screen.isNativeValid());
+ Assert.assertEquals(true,screen.getDisplay().isNativeValid());
+ System.err.println("Screen: "+screen.toString());
List<ScreenMode> screenModes = screen.getScreenModes();
Assert.assertTrue(screenModes.size()>0);
@@ -119,15 +122,25 @@ public class TestScreenMode00NEWT extends UITestCase {
Assert.assertEquals(sm_c.getRotatedWidth(), screen.getWidth());
Assert.assertEquals(sm_c.getRotatedHeight(), screen.getHeight());
- window.destroy();
+ screen.removeReference();
- Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,screen.getDisplay().isNativeValid());
}
+ static int atoi(String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (Exception ex) { throw new RuntimeException(ex); }
+ }
+
public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-screen")) {
+ i++;
+ screenIdx = atoi(args[i]);
+ }
+ }
String tstname = TestScreenMode00NEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}