aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-01 20:16:23 +0100
committerSven Gothel <[email protected]>2010-11-01 20:16:23 +0100
commit2872350a7586976c9cddb9a9589b471c294ac5d9 (patch)
treecd345f66459f999ba7f6d84bd7fe6e4ae5e74b95
parenteacbe4788a3fa68e072c23fbef62855fdaa209da (diff)
Added Rotation test
-rw-r--r--make/scripts/tests.bat3
-rw-r--r--make/scripts/tests2.sh74
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java6
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java158
4 files changed, 190 insertions, 51 deletions
diff --git a/make/scripts/tests.bat b/make/scripts/tests.bat
index 5d7944abc..925ad8fc0 100644
--- a/make/scripts/tests.bat
+++ b/make/scripts/tests.bat
@@ -16,7 +16,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParentin
REM scripts\java-win64.bat com.jogamp.test.junit.newt.TestFocus02SwingAWTRobot
scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestScreenMode00NEWT
-REM scripts\java-win64.bat com.jogamp.test.junit.newt.TestScreenMode01NEWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestScreenMode01NEWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestScreenMode02NEWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestDisplayLifecycle01NEWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
diff --git a/make/scripts/tests2.sh b/make/scripts/tests2.sh
new file mode 100644
index 000000000..50ab8ec33
--- /dev/null
+++ b/make/scripts/tests2.sh
@@ -0,0 +1,74 @@
+#! /bin/bash
+
+bdir=../build-x86_64
+
+rm -f java-run.log
+
+spath=`dirname $0`
+
+. $spath/setenv-jogl.sh $bdir JOGL_ALL
+
+which java 2>&1 | tee -a java-run.log
+java -version 2>&1 | tee -a java-run.log
+echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a java-run.log
+echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a java-run.log
+echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a java-run.log
+echo java $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
+
+function jrun() {
+ # D_ARGS="-Djogamp.debug.TraceLock"
+ # D_ARGS="-Dnewt.debug.EDT -Dnativewindow.TraceLock -Dnativewindow.debug.NativeWindow"
+ # D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
+ # D_ARGS="-Dnewt.debug.EDT -Dnativewindow.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true"
+ #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock"
+ # D_ARGS="-Dnewt.debug.Window -Dnewt.debug.EDT -Dnewt.debug.Display "
+ #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen"
+ #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas"
+ #D_ARGS="-Dnewt.debug.EDT -Djogl.debug.GLContext"
+ D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT"
+ # D_ARGS="-Djogl.debug=all"
+ java $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
+}
+
+
+function testawt() {
+ jrun $*
+}
+
+#testawt com.jogamp.test.junit.jogl.acore.TestGLProfile01NEWT $*
+#testawt com.jogamp.test.junit.jogl.awt.TestAWT01GLn $*
+#testawt com.jogamp.test.junit.jogl.awt.TestAWT02WindowClosing
+#testawt com.jogamp.test.junit.jogl.awt.TestSwingAWT01GLn
+#testawt com.jogamp.test.junit.jogl.awt.TestSwingAWTRobotUsageBeforeJOGLInitBug411
+#testawt com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsAWT
+#testawt com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsNewtAWTWrapper
+#testawt com.jogamp.test.junit.jogl.texture.TestTexture01AWT
+#testawt com.jogamp.test.junit.newt.TestEventSourceNotAWTBug
+#testawt com.jogamp.test.junit.newt.TestFocus01SwingAWTRobot
+#testawt com.jogamp.test.junit.newt.TestFocus02SwingAWTRobot
+#testawt com.jogamp.test.junit.newt.TestListenerCom01AWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting01aAWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting01bAWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting01cAWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting01cSwingAWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting02AWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting03AWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting03AWT -time 100000
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting03bAWT -time 100000
+#testawt com.jogamp.test.junit.core.TestIteratorIndexCORE
+
+#testawt com.jogamp.test.junit.newt.TestDisplayLifecycle01NEWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
+#testawt com.jogamp.test.junit.newt.parenting.TestParenting02NEWT
+
+#testawt com.jogamp.test.junit.newt.TestScreenMode00NEWT
+#testawt com.jogamp.test.junit.newt.TestScreenMode01NEWT
+testawt com.jogamp.test.junit.newt.TestScreenMode02NEWT
+
+#testawt com.jogamp.test.junit.newt.TestGLWindows01NEWT
+#testawt -Djava.awt.headless=true com.jogamp.test.junit.newt.TestGLWindows01NEWT
+#testawt com.jogamp.test.junit.newt.TestGLWindows02NEWTAnimated
+
+#testawt $*
+
+$spath/count-edt-start.sh java-run.log
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
index 2836a2304..fe17857ef 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
@@ -234,6 +234,12 @@ public class TestScreenMode01NEWT extends UITestCase {
ScreenMode smOrig = screen.getOriginalScreenMode();
List screenModes = screen.getScreenModes();
+ if(null==screenModes) {
+ // no support ..
+ destroyWindow(display, screen, window);
+ return;
+ }
+ Assert.assertTrue(screenModes.size()>0);
screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
index 6aaf4a8d1..98c8fd58c 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
@@ -28,11 +28,12 @@
package com.jogamp.test.junit.newt;
-
import java.io.IOException;
-
-import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.opengl.util.Animator;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -43,48 +44,39 @@ 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.ScreenModeUtil;
+import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
import com.jogamp.test.junit.util.UITestCase;
+import java.util.List;
+import javax.media.nativewindow.util.Dimension;
public class TestScreenMode02NEWT extends UITestCase {
+ static GLProfile glp;
static int width, height;
- static int waitTimeShort = 1000; //1 sec
- static int waitTimeLong = 4000; //4 sec
-
+ static int waitTimeShort = 1000; // 1 sec
+ static int waitTimeLong = 5000; // 5 sec
@BeforeClass
public static void initClass() {
NativeWindowFactory.initSingleton(true);
width = 640;
height = 480;
+ glp = GLProfile.getDefault();
}
- static Window createWindow(Screen screen, Capabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
+ static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
Assert.assertNotNull(caps);
caps.setOnscreen(onscreen);
- // Create native windowing resources .. X11/Win/OSX
- //
- Window window = NewtFactory.createWindow(screen, caps);
- Assert.assertNotNull(window);
- window.setUndecorated(onscreen && undecorated);
+
+ boolean destroyWhenUnused = screen.getDestroyWhenUnused();
+ GLWindow window = GLWindow.create(screen, caps);
window.setSize(width, height);
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
+ window.addGLEventListener(new Gears());
+ Assert.assertNotNull(window);
+ Assert.assertEquals(destroyWhenUnused, window.getScreen().getDestroyWhenUnused());
window.setVisible(true);
- Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(true,window.isNativeValid());
-
- //
- // Create native OpenGL resources .. XGL/WGL/CGL ..
- // equivalent to GLAutoDrawable methods: setVisible(true)
- //
- caps = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- Assert.assertNotNull(caps);
- Assert.assertTrue(caps.getGreenBits()>5);
- Assert.assertTrue(caps.getBlueBits()>5);
- Assert.assertTrue(caps.getRedBits()>5);
- Assert.assertEquals(caps.isOnscreen(),onscreen);
-
return window;
}
@@ -102,34 +94,100 @@ public class TestScreenMode02NEWT extends UITestCase {
@Test
public void testScreenRotationChange01() throws InterruptedException {
- }
+ Thread.sleep(waitTimeShort);
- @Test
- public void testScreenRotationChange02() throws InterruptedException {
- }
+ GLCapabilities caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
+ Assert.assertNotNull(window);
- @Test
- public void testScreenRotationChange03() throws InterruptedException {
- }
-
- @Test
- public void testScreenModeChangeWithRotate01() throws InterruptedException {
- }
+ List screenModes = screen.getScreenModes();
+ if(null==screenModes) {
+ // no support ..
+ destroyWindow(display, screen, window);
+ return;
+ }
+ Assert.assertTrue(screenModes.size()>0);
+
+ Animator animator = new Animator(window);
+ animator.start();
+
+ ScreenMode smCurrent = screen.getCurrentScreenMode();
+ Assert.assertNotNull(smCurrent);
+ ScreenMode smOrig = screen.getOriginalScreenMode();
+ Assert.assertNotNull(smOrig);
+ Assert.assertEquals(smCurrent, smOrig);
+ System.err.println("[0] current/orig: "+smCurrent);
+
+ screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
+ Assert.assertNotNull(screenModes);
+ Assert.assertTrue(screenModes.size()>0);
+ screenModes = ScreenModeUtil.filterByRotation(screenModes, 90);
+ if(null==screenModes) {
+ // no rotation support ..
+ destroyWindow(display, screen, window);
+ return;
+ }
+ Assert.assertTrue(screenModes.size()>0);
+ screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
+ Assert.assertNotNull(screenModes);
+ Assert.assertTrue(screenModes.size()>0);
+ screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
+ Assert.assertNotNull(screenModes);
+ Assert.assertTrue(screenModes.size()>0);
+
+ ScreenMode sm = (ScreenMode) screenModes.get(0);
+ System.err.println("[0] set current: "+sm);
+ screen.setCurrentScreenMode(sm);
+ Assert.assertEquals(sm, screen.getCurrentScreenMode());
+ Assert.assertNotSame(smOrig, screen.getCurrentScreenMode());
+
+ Thread.sleep(waitTimeLong);
+
+ // check reset ..
+
+ ScreenMode saveOrigMode = (ScreenMode) smOrig.clone();
+
+ Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
+ Assert.assertEquals(true,window.isNativeValid());
+ Assert.assertEquals(true,window.isVisible());
+ animator.stop();
+ destroyWindow(null, screen, window);
+
+ Assert.assertEquals(false,window.isVisible());
+ Assert.assertEquals(false,window.isNativeValid());
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(true,display.isNativeValid());
+
+ screen = NewtFactory.createScreen(display, 0); // screen 0
+ screen.addReference(); // trigger native creation
+
+ Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
+
+ smCurrent = screen.getCurrentScreenMode();
+ System.err.println("[1] current/orig: "+smCurrent);
+
+ Assert.assertNotNull(smCurrent);
+ Assert.assertEquals(saveOrigMode, smOrig);
+
+ destroyWindow(display, screen, null);
+
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(false,display.isNativeValid());
+
+ Thread.sleep(waitTimeShort);
+ }
public static void main(String args[]) throws IOException {
String tstname = TestScreenMode02NEWT.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- tstname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
+ org.junit.runner.JUnitCore.main(tstname);
}
}