From cb6855409590a7229b5191017caad201c271b05c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Jun 2013 11:35:27 +0200 Subject: Tests: Fix enumeration of monitor/screen mode tests, add tests description to class header. --- make/scripts/tests-win.bat | 14 +- make/scripts/tests.sh | 18 +- .../test/junit/newt/ManualScreenMode03NEWT.java | 114 ------ .../test/junit/newt/ManualScreenMode03aNEWT.java | 114 ++++++ .../test/junit/newt/TestScreenMode00NEWT.java | 179 ---------- .../test/junit/newt/TestScreenMode00aNEWT.java | 179 ++++++++++ .../test/junit/newt/TestScreenMode01NEWT.java | 392 --------------------- .../test/junit/newt/TestScreenMode01dNEWT.java | 392 +++++++++++++++++++++ .../test/junit/newt/TestScreenMode02NEWT.java | 197 ----------- .../test/junit/newt/TestScreenMode02aNEWT.java | 197 +++++++++++ 10 files changed, 900 insertions(+), 896 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index ed0241035..0b5f13661 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,6 +61,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 @@ -87,7 +90,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* @@ -110,13 +113,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRo REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01dNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02sNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0ab5f41c..8cf4fb406 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -175,7 +175,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -400,14 +400,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01dNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* @@ -486,7 +486,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -585,7 +585,7 @@ testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCan #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* # test rotation change -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02aNEWT # # regressions diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java deleted file mode 100644 index 875e4fe86..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.util.Animator; - -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.List; -import javax.media.nativewindow.util.Dimension; - -/** - * Manual testing the ScreenImpl shutdown hook, - * which shall reset the ScreenMode to it's original state - * when the application exists (normal or ctrl-c). - */ -public class ManualScreenMode03NEWT extends UITestCase { - static int waitTime = 7000; // 1 sec - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - window.setVisible(true); - return window; - } - - public void run() { - int width = 640; - int height = 480; - GLProfile glp = GLProfile.getDefault(); - GLCapabilities caps = new GLCapabilities(glp); - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - List monitorModes = screen.getMonitorModes(); - if(null==monitorModes) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - return; - } - Animator animator = new Animator(window); - animator.start(); - - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - MonitorMode mmOrig = monitor.getOriginalMode(); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - - MonitorMode mm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+mm); - monitor.setCurrentMode(mm); - - System.err.print("[0] post setting .. wait <"); - try { - Thread.sleep(waitTime); - } catch (InterruptedException e) { - } - System.err.println("done>"); - System.exit(0); - } - - public static void main(String args[]) throws IOException { - ManualScreenMode03NEWT t = new ManualScreenMode03NEWT(); - t.run(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java new file mode 100644 index 000000000..875e4fe86 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java @@ -0,0 +1,114 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Manual testing the ScreenImpl shutdown hook, + * which shall reset the ScreenMode to it's original state + * when the application exists (normal or ctrl-c). + */ +public class ManualScreenMode03NEWT extends UITestCase { + static int waitTime = 7000; // 1 sec + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + window.setVisible(true); + return window; + } + + public void run() { + int width = 640; + int height = 480; + GLProfile glp = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(glp); + Display display = NewtFactory.createDisplay(null); // local display + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + + List monitorModes = screen.getMonitorModes(); + if(null==monitorModes) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + return; + } + Animator animator = new Animator(window); + animator.start(); + + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + MonitorMode mmOrig = monitor.getOriginalMode(); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); + + System.err.print("[0] post setting .. wait <"); + try { + Thread.sleep(waitTime); + } catch (InterruptedException e) { + } + System.err.println("done>"); + System.exit(0); + } + + public static void main(String args[]) throws IOException { + ManualScreenMode03NEWT t = new ManualScreenMode03NEWT(); + t.run(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java deleted file mode 100644 index f64cf2eb8..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.nativewindow.NativeWindowFactory; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.Screen; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.Iterator; -import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Rectangle; -import javax.media.nativewindow.util.SurfaceSize; -import javax.media.opengl.GLProfile; - -import jogamp.newt.MonitorDeviceImpl; -import jogamp.newt.MonitorModeProps; - -public class TestScreenMode00NEWT extends UITestCase { - static int screenIdx = 0; - static int width, height; - - static int waitTimeShort = 4; //1 sec - static int waitTimeLong = 6; //6 sec - - - - @BeforeClass - public static void initClass() { - GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi) - NativeWindowFactory.initSingleton(); - width = 640; - height = 480; - } - - @Test - public void testScreenModeInfo00() throws InterruptedException { - final DimensionImmutable res = new Dimension(640, 480); - final SurfaceSize surfsz = new SurfaceSize(res, 32); - final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0); - System.err.println("00 out: "+modeOut); - final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); - cache.monitorModes.add(modeOut); - { - final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut); - final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); - System.err.println("00 in : "+modeIn); - - Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution()); - - Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize()); - - Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode()); - - Assert.assertEquals(modeOut, modeIn); - } - - final DimensionImmutable sizeMM = new Dimension(50, 50); - final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); - final ArrayHashSet supportedModes = new ArrayHashSet(); - supportedModes.add(modeOut); - final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); - System.err.println("01 out : "+monOut); - cache.monitorDevices.add(monOut); - { - final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); - final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); - System.err.println("01 in : "+monIn); - - Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); - Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); - Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); - Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); - Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); - Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); - Assert.assertEquals(monOut, monIn); - } - } - - @Test - public void testScreenModeInfo01() throws InterruptedException { - 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 allMonitorModes = screen.getMonitorModes(); - Assert.assertTrue(allMonitorModes.size()>0); - { - int i=0; - for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { - System.err.println("All["+i+"]: "+iMode.next()); - } - } - - List monitors = screen.getMonitorDevices(); - Assert.assertTrue(monitors.size()>0); - int j=0; - for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { - MonitorDevice monitor = iMonitor.next(); - System.err.println(j+": "+monitor); - List modes = monitor.getSupportedModes(); - Assert.assertTrue(modes.size()>0); - int i=0; - for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { - System.err.println("["+j+"]["+i+"]: "+iMode.next()); - } - Assert.assertTrue(allMonitorModes.containsAll(modes)); - - MonitorMode sm_o = monitor.getOriginalMode(); - Assert.assertNotNull(sm_o); - MonitorMode sm_c = monitor.queryCurrentMode(); - System.err.println("[0] orig : "+sm_o); - System.err.println("[0] current: "+sm_c); - Assert.assertNotNull(sm_c); - Assert.assertEquals(sm_o, sm_c); - } - - screen.removeReference(); - - 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 supportedModes = new ArrayHashSet(); + supportedModes.add(modeOut); + final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); + System.err.println("01 out : "+monOut); + cache.monitorDevices.add(monOut); + { + final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); + final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); + System.err.println("01 in : "+monIn); + + Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); + Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); + Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); + Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); + Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); + Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); + Assert.assertEquals(monOut, monIn); + } + } + + @Test + public void testScreenModeInfo01() throws InterruptedException { + 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 allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + { + int i=0; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + } + + List monitors = screen.getMonitorDevices(); + Assert.assertTrue(monitors.size()>0); + int j=0; + for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { + MonitorDevice monitor = iMonitor.next(); + System.err.println(j+": "+monitor); + List modes = monitor.getSupportedModes(); + Assert.assertTrue(modes.size()>0); + int i=0; + for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { + System.err.println("["+j+"]["+i+"]: "+iMode.next()); + } + Assert.assertTrue(allMonitorModes.containsAll(modes)); + + MonitorMode sm_o = monitor.getOriginalMode(); + Assert.assertNotNull(sm_o); + MonitorMode sm_c = monitor.queryCurrentMode(); + System.err.println("[0] orig : "+sm_o); + System.err.println("[0] current: "+sm_c); + Assert.assertNotNull(sm_c); + Assert.assertEquals(sm_o, sm_c); + } + + screen.removeReference(); + + 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 - * Also documents NV RANDR/GL bug, see {@link TestScreenMode01NEWT#cleanupGL()}.

- */ -public class TestScreenMode01NEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static int waitTimeShort = 2000; // 2 sec - static int waitTimeLong = 8000; // 8 sec - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - /** - * Following configurations results in a SIGSEGV: - *
-     *   Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
-     * 
- * - * Situation: - *
-     *   1 - Create Screen, GLWindow (w/ context)
-     *   2 - ScreenMode change
-     *   3 - Destroy GLWindow (w/ context), Screen
-     *   4 - Create  Screen, GLWindow (w/ context) (*)
-     * 
- * - * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call - * on the the created GL context. - * - * Remedy: - *
-     *   A) Releasing all resources before step 4 .. works.
-     *   B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
-     * 
- * - * Hence there must be some correlations with the screen randr mode - * and some of the glcontext/gldrawables. - * - *
-     * Remedy A) is demonstrated here
-     * Remedy B) is shown in {@link TestScreenMode01bNEWT}
-     * 
- */ - private void cleanupGL() throws InterruptedException { - System.err.println("*** cleanupGL.shutdown"); - GLProfile.shutdown(); - System.err.println("*** cleanupGL.initSingleton"); - GLProfile.initSingleton(); - System.err.println("*** cleanupGL.DONE"); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - Assert.assertNotNull(caps); - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testFullscreenChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - 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 */); - Animator animator = new Animator(window); - animator.start(); - - final MonitorDevice monitor = window.getMainMonitor(); - - Assert.assertEquals(false, window.isFullscreen()); - Assert.assertEquals(width, window.getWidth()); - Assert.assertEquals(height, window.getHeight()); - - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); - Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); - - Thread.sleep(waitTimeShort); - - window.setFullscreen(false); - Assert.assertEquals(false, window.isFullscreen()); - Assert.assertEquals(width, window.getWidth()); - Assert.assertEquals(height, window.getHeight()); - - Thread.sleep(waitTimeShort); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - Assert.assertEquals(false, window.isRealized()); - Assert.assertEquals(false, window.isNativeValid()); - - cleanupGL(); - } - - @Test - public void testScreenModeChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - 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); - - MonitorDevice monitor = window.getMainMonitor(); - - List monitorModes = monitor.getSupportedModes(); - Assert.assertTrue(monitorModes.size()>0); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support, sorry"); - destroyWindow(window); - return; - } - - Animator animator = new Animator(window); - animator.start(); - - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isRealized()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - cleanupGL(); - } - - @Test - public void testScreenModeChangeWithFS01Pre() throws InterruptedException { - Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(true) ; - } - - @Test - public void testScreenModeChangeWithFS01Post() throws InterruptedException { - Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(false) ; - } - - protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glp); - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Animator animator = new Animator(window); - animator.start(); - - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - destroyWindow(window); - return; - } - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - - MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); - Assert.assertNotNull(monitorMode); - - if(preFS) { - System.err.println("[0] set FS pre 0: "+window.isFullscreen()); - window.setFullscreen(true); - System.err.println("[0] set FS pre 1: "+window.isFullscreen()); - Assert.assertEquals(true, window.isFullscreen()); - System.err.println("[0] set FS pre X: "+window.isFullscreen()); - } - - System.err.println("[0] set current: "+monitorMode); - monitor.setCurrentMode(monitorMode); - - if(!preFS) { - System.err.println("[0] set FS post 0: "+window.isFullscreen()); - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - System.err.println("[0] set FS post X: "+window.isFullscreen()); - } - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isRealized()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - cleanupGL(); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode01NEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java new file mode 100644 index 000000000..a2ce7cec0 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java @@ -0,0 +1,392 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Demonstrates fullscreen with and without ScreenMode change. + * + *

+ * Also documents NV RANDR/GL bug, see {@link TestScreenMode01NEWT#cleanupGL()}.

+ */ +public class TestScreenMode01NEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + /** + * Following configurations results in a SIGSEGV: + *
+     *   Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
+     * 
+ * + * Situation: + *
+     *   1 - Create Screen, GLWindow (w/ context)
+     *   2 - ScreenMode change
+     *   3 - Destroy GLWindow (w/ context), Screen
+     *   4 - Create  Screen, GLWindow (w/ context) (*)
+     * 
+ * + * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call + * on the the created GL context. + * + * Remedy: + *
+     *   A) Releasing all resources before step 4 .. works.
+     *   B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
+     * 
+ * + * Hence there must be some correlations with the screen randr mode + * and some of the glcontext/gldrawables. + * + *
+     * Remedy A) is demonstrated here
+     * Remedy B) is shown in {@link TestScreenMode01bNEWT}
+     * 
+ */ + private void cleanupGL() throws InterruptedException { + System.err.println("*** cleanupGL.shutdown"); + GLProfile.shutdown(); + System.err.println("*** cleanupGL.initSingleton"); + GLProfile.initSingleton(); + System.err.println("*** cleanupGL.DONE"); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + Assert.assertNotNull(caps); + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testFullscreenChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + 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 */); + Animator animator = new Animator(window); + animator.start(); + + final MonitorDevice monitor = window.getMainMonitor(); + + Assert.assertEquals(false, window.isFullscreen()); + Assert.assertEquals(width, window.getWidth()); + Assert.assertEquals(height, window.getHeight()); + + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); + Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); + + Thread.sleep(waitTimeShort); + + window.setFullscreen(false); + Assert.assertEquals(false, window.isFullscreen()); + Assert.assertEquals(width, window.getWidth()); + Assert.assertEquals(height, window.getHeight()); + + Thread.sleep(waitTimeShort); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertEquals(false, window.isRealized()); + Assert.assertEquals(false, window.isNativeValid()); + + cleanupGL(); + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + 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); + + MonitorDevice monitor = window.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support, sorry"); + destroyWindow(window); + return; + } + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + cleanupGL(); + } + + @Test + public void testScreenModeChangeWithFS01Pre() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(true) ; + } + + @Test + public void testScreenModeChangeWithFS01Post() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(false) ; + } + + protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Display display = NewtFactory.createDisplay(null); // local display + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Animator animator = new Animator(window); + animator.start(); + + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); + Assert.assertNotNull(monitorMode); + + if(preFS) { + System.err.println("[0] set FS pre 0: "+window.isFullscreen()); + window.setFullscreen(true); + System.err.println("[0] set FS pre 1: "+window.isFullscreen()); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS pre X: "+window.isFullscreen()); + } + + System.err.println("[0] set current: "+monitorMode); + monitor.setCurrentMode(monitorMode); + + if(!preFS) { + System.err.println("[0] set FS post 0: "+window.isFullscreen()); + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS post X: "+window.isFullscreen()); + } + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + cleanupGL(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode01NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java deleted file mode 100644 index 58bce4cc9..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.util.Animator; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.os.Platform; -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.Window; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.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 = 2000; // 2 sec - static int waitTimeLong = 8000; // 8 sec - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - Assert.assertNotNull(caps); - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - Assert.assertTrue(window.isVisible()); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testScreenRotationChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - 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); - - MonitorDevice monitor = window.getMainMonitor(); - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - destroyWindow(window); - return; - } - Assert.assertTrue(monitorModes.size()>0); - - Animator animator = new Animator(window); - animator.start(); - - MonitorMode mmCurrent = monitor.getCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); - if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { - // no rotation support .. - System.err.println("Your platform has no rotation support, sorry"); - destroyWindow(window); - return; - } - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - destroyWindow(window); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - screen.destroy(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode02NEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java new file mode 100644 index 000000000..58bce4cc9 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java @@ -0,0 +1,197 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.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 = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + Assert.assertNotNull(caps); + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + Assert.assertTrue(window.isVisible()); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenRotationChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + 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); + + MonitorDevice monitor = window.getMainMonitor(); + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { + // no rotation support .. + System.err.println("Your platform has no rotation support, sorry"); + destroyWindow(window); + return; + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + destroyWindow(window); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + screen.destroy(); + + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode02NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} -- cgit v1.2.3