diff options
author | Sven Gothel <[email protected]> | 2013-07-02 16:37:41 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-07-02 16:37:41 +0200 |
commit | 3a32a59045ced338b2c5098cfb1102f847420efc (patch) | |
tree | b2f243cecbcc081e9f8dedacf243710793475948 | |
parent | 460ad9822b2509865691258be851e62b85626677 (diff) |
Bug 734: Bug could not be reproduced w/ TestScreenMode02bNEWT, however on some X11 tests systems, artifacts could be experienced.
X11 Test systems w/ AMD fglrx and Intel Mesa, the rotated height
is cut off .. probably due to bug of driver code and rotation.
-rwxr-xr-x | make/scripts/tests-win.bat | 4 | ||||
-rw-r--r-- | make/scripts/tests.sh | 4 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java | 6 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java | 236 |
4 files changed, 244 insertions, 6 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index a5d368c48..348b6053a 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -119,8 +119,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0d15b84b..5f0cdf7fa 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -407,8 +407,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index 54c6bdd6c..aee9c28c2 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -34,7 +34,6 @@ 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; @@ -58,6 +57,9 @@ import javax.media.nativewindow.util.Dimension; * Tests MonitorMode change w/ changed rotation, * w/ and w/o fullscreen, pre and post MonitorMode change. * <p> + * MonitorMode change does not use highest resolution. + * </p> + * <p> * Also tests MonitorMode reset after last Screen is dereferenced, * i.e. MonitorMode should be reinstated. * </p> @@ -185,10 +187,10 @@ public class TestScreenMode02aNEWT extends UITestCase { } if( !preVis ) { - window.setVisible(true); if( fullscreen ) { window.setFullscreen(true); } + window.setVisible(true); } Thread.sleep(waitTimeLong); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java new file mode 100644 index 000000000..bd7ac55db --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java @@ -0,0 +1,236 @@ +/** + * 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.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +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.UITestCase; +import com.jogamp.opengl.util.Animator; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Tests MonitorMode change w/ changed rotation and fullscreen. + * <p> + * MonitorMode change uses highest resolution. + * </p> + * <p> + * Bug 734 could not be reproduced, however on tests systems + * here - AMD fglrx and Intel Mesa, the rotated height + * is cut off .. probably due to bug of driver code and rotation. + * </p> + * <p> + * Documents remedy B) for NV RANDR/GL bug + * </p> + * + * @see TestScreenMode01NEWT#cleanupGL() + */ +public class TestScreenMode02bNEWT extends UITestCase { + static GLProfile glp; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2(1)); + Assert.assertNotNull(window); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenModeChange01_PreFull() throws InterruptedException { + testScreenModeChangeImpl(true); + } + + @Test + public void testScreenModeChange02_PostFull() throws InterruptedException { + testScreenModeChangeImpl(false); + } + + void testScreenModeChangeImpl(boolean preVis) 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); + screen.createNative(); // instantiate for resolution query and keep it alive ! + final int swidth = screen.getWidth(); + final int sheight = screen.getHeight(); + + GLWindow window = createWindow(screen, caps, "win0", 0, 0, 640, 480); + if( preVis ) { + window.setVisible(true); + window.setFullscreen(true); + } + window.setUndecorated(true); + Assert.assertNotNull(window); + + List<MonitorMode> allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window); + return; + } + + MonitorDevice monitor = window.getMainMonitor(); + List<MonitorMode> monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + final 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(swidth, sheight)); + 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 mm = monitorModes.get(0); // highest resolution .. + System.err.println("[0] set current: "+mm); + Assert.assertTrue(monitor.setCurrentMode(mm)); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(mm, monitor.queryCurrentMode()); + + if( !preVis ) { + window.setFullscreen(true); + window.setVisible(true); + } + + Thread.sleep(waitTimeLong); + + if( !preVis ) { + window.setFullscreen(false); + } + + monitor.setCurrentMode(mmOrig); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Thread.sleep(waitTimeShort); + + if( preVis ) { + window.setFullscreen(false); + } + + // check auto 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.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode02bNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} |