diff options
author | Sven Gothel <[email protected]> | 2010-10-26 04:35:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-10-26 04:35:15 +0200 |
commit | a34d04ad4d9a46a30772b3984baf692a59e8b608 (patch) | |
tree | a0c6e9d958554c09479fa078f494001140d3776b /src/junit/com | |
parent | 61e6325eed2337d791479ddcd2eb8da928b4f94c (diff) |
NEWT: ScreenMode changes
- New type definition:
ScreenMode { MonitorMode { SurfaceSize { Resolution, bpp }, ScreenSizeMM, refreshRate }, rotation },
where Resolution and ScreenSizeMM are of type DimensionReadOnly
- ScreenMute instance is
- immutable
- hashable
- cloneable
The above allows fast query and storage w/o redundancies.
More than 300 modes via permutation could be expected.
ScreenMode impl. changes:
ScreenImpl:
To be implemented methods by native specialization:
- protected int[] getScreenModeFirstImpl()
- protected int[] getScreenModeNextImpl()
- protected ScreenMode getCurrentScreenModeImpl()
- protected boolean setCurrentScreenModeImpl(ScreenMode screenMode)
The data unification etc is implemented generic using ScreenModeUtil
and the 'int[]' streaming.
ScreenModeStatus holds all ScreenMode related data
and provides a locking strategy.
ScreenModeListener provides a callback facility for ScreenMode change events.
- Screens listen to ScreenModeStatus, so all FQN referenced Screen's receive the change.
- Windows listen to Screen, to take appropriate action for the event (fullscreen, reshape).
Misc:
- Screen/Display: promoting 'addReference'/'removeReference' to public interface,
so a user may trigger construction/destruction (-> junit tests, plus other clients than WindowImpl).
- Gears: 'setSwapInterval' at 'reshape' instead of 'init',
so it's reset when ScreenMode is changing.
-
Diffstat (limited to 'src/junit/com')
5 files changed, 289 insertions, 397 deletions
diff --git a/src/junit/com/jogamp/test/junit/core/TestIteratorIndexCORE.java b/src/junit/com/jogamp/test/junit/core/TestIteratorIndexCORE.java deleted file mode 100644 index 0ed102e40..000000000 --- a/src/junit/com/jogamp/test/junit/core/TestIteratorIndexCORE.java +++ /dev/null @@ -1,128 +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.test.junit.core; - -import com.jogamp.test.junit.util.UITestCase; - -import java.util.*; -import java.io.IOException; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -public class TestIteratorIndexCORE extends UITestCase { - - static int elems = 10; - static int loop = 9999999; - - public void populate(List l, int len) { - while(len>0) { - l.add(new Integer(len--)); - } - } - - @Test - public void test01ArrayListIterator() { - int sum=0; - ArrayList l = new ArrayList(); - populate(l, elems); - - for(int j=loop; j>0; j--) { - for(Iterator iter = l.iterator(); iter.hasNext(); ) { - Integer i = (Integer)iter.next(); - sum+=i.intValue(); - } - } - System.err.println("test01-arraylist-iterator sum: "+sum); - } - - @Test - public void test0ArrayListIndex() { - int sum=0; - ArrayList l = new ArrayList(); - populate(l, elems); - - for(int j=loop; j>0; j--) { - for(int k = 0; k < l.size(); k++) { - Integer i = (Integer)l.get(k); - sum+=i.intValue(); - } - } - System.err.println("test01-arraylist-index sum: "+sum); - } - - @Test - public void test01LinkedListListIterator() { - int sum=0; - LinkedList l = new LinkedList(); - populate(l, elems); - - for(int j=loop; j>0; j--) { - for(Iterator iter = l.iterator(); iter.hasNext(); ) { - Integer i = (Integer)iter.next(); - sum+=i.intValue(); - } - } - System.err.println("test01-linkedlist-iterator sum: "+sum); - } - - @Test - public void test01LinkedListListIndex() { - int sum=0; - LinkedList l = new LinkedList(); - populate(l, elems); - - for(int j=loop; j>0; j--) { - for(int k = 0; k < l.size(); k++) { - Integer i = (Integer)l.get(k); - sum+=i.intValue(); - } - } - System.err.println("test01-linkedlist-index sum: "+sum); - } - - public static void main(String args[]) throws IOException { - String tstname = TestIteratorIndexCORE.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" } ); - } - -} diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java index e8d07682c..d0f915e03 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java @@ -78,8 +78,6 @@ public class Gears implements GLEventListener { GL2 gl = drawable.getGL().getGL2(); - gl.setSwapInterval(swapInterval); - float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; float red[] = { 0.8f, 0.1f, 0.0f, 0.7f }; float green[] = { 0.0f, 0.8f, 0.2f, 0.7f }; @@ -128,6 +126,8 @@ public class Gears implements GLEventListener { System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height); GL2 gl = drawable.getGL().getGL2(); + gl.setSwapInterval(swapInterval); + float h = (float)height / (float)width; gl.glMatrixMode(GL2.GL_PROJECTION); diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java new file mode 100644 index 000000000..06911e82b --- /dev/null +++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java @@ -0,0 +1,137 @@ +/** + * 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.test.junit.newt; + +import java.io.IOException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorMode; +import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; +import com.jogamp.test.junit.util.UITestCase; +import java.util.Iterator; +import java.util.List; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionReadOnly; +import javax.media.nativewindow.util.SurfaceSize; + +public class TestScreenMode00NEWT extends UITestCase { + static int width, height; + + static int waitTimeShort = 4; //1 sec + static int waitTimeLong = 6; //6 sec + + + + @BeforeClass + public static void initClass() { + NativeWindowFactory.initSingleton(true); + width = 640; + height = 480; + } + + @Test + public void testScreenModeInfo00() throws InterruptedException { + DimensionReadOnly res = new Dimension(640, 480); + SurfaceSize surfsz = new SurfaceSize(res, 32); + DimensionReadOnly mm = new Dimension(500, 400); + MonitorMode mon = new MonitorMode(surfsz, mm, 60); + ScreenMode sm_out = new ScreenMode(mon, 90); + System.err.println("00 out: "+sm_out); + + int[] props = ScreenModeUtil.streamOut(sm_out); + ScreenMode sm_in = ScreenModeUtil.streamIn(props, 0); + System.err.println("00 in : "+sm_in); + + Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize().getResolution(), + sm_out.getMonitorMode().getSurfaceSize().getResolution()); + + Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize(), + sm_out.getMonitorMode().getSurfaceSize()); + + Assert.assertEquals(sm_in.getMonitorMode().getScreenSizeMM(), + sm_out.getMonitorMode().getScreenSizeMM()); + + Assert.assertEquals(sm_in.getMonitorMode(), sm_out.getMonitorMode()); + + Assert.assertEquals(sm_in, sm_out); + + Assert.assertEquals(sm_out.hashCode(), sm_in.hashCode()); + } + + @Test + public void testScreenModeInfo01() throws InterruptedException { + Capabilities caps = new Capabilities(); + Window window = NewtFactory.createWindow(caps); + window.setSize(width, height); + window.setVisible(true); + + Screen screen = window.getScreen(); + + List screenModes = screen.getScreenModes(); + if(null != screenModes) { + Assert.assertTrue(screenModes.size()>0); + int i=0; + for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { + System.err.println(i+": "+iter.next()); + } + ScreenMode sm_o = screen.getOriginalScreenMode(); + Assert.assertNotNull(sm_o); + ScreenMode sm_c = screen.getOriginalScreenMode(); + Assert.assertNotNull(sm_c); + System.err.println("orig: "+sm_o); + System.err.println("curr: "+sm_c); + } + + window.destroy(true); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,screen.getDisplay().isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode00NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java index ec6414402..2836a2304 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java @@ -33,6 +33,8 @@ 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; import org.junit.Test; @@ -43,15 +45,18 @@ 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 TestScreenMode01NEWT extends UITestCase { - static GLProfile glp; + static GLProfile glp; static int width, height; - static int waitTimeShort = 4; //1 sec - static int waitTimeLong = 6; //6 sec + static int waitTimeShort = 1000; // 1 sec + static int waitTimeLong = 5000; // 5 sec @@ -69,6 +74,7 @@ public class TestScreenMode01NEWT extends UITestCase { boolean destroyWhenUnused = screen.getDestroyWhenUnused(); GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); window.addGLEventListener(new Gears()); Assert.assertNotNull(window); Assert.assertEquals(destroyWhenUnused, window.getScreen().getDestroyWhenUnused()); @@ -98,168 +104,184 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertNotNull(screen); GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Animator animator = new Animator(window); + animator.start(); window.setFullscreen(true); Assert.assertEquals(true, window.isFullscreen()); - for(int state=0; state<waitTimeShort; state++) { - Thread.sleep(100); - } + Thread.sleep(waitTimeShort); + window.setFullscreen(false); Assert.assertEquals(false, window.isFullscreen()); + Thread.sleep(waitTimeShort); + + animator.stop(); destroyWindow(display, screen, window); } @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); - ScreenMode[] screenModes = screen.getScreenModes(); - Assert.assertNotNull(screenModes); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - - int modeIndex = 1; - - ScreenMode screenMode = screenModes[modeIndex]; - Assert.assertNotNull(screenMode); - - short modeRate = screenMode.getRates()[0]; - screen.setScreenMode(modeIndex, modeRate); - - Assert.assertEquals(modeIndex, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(modeRate, screen.getCurrentScreenRate()); - - for(int state=0; state<waitTimeLong; state++) { - Thread.sleep(100); + List screenModes = screen.getScreenModes(); + if(null==screenModes) { + // no support .. + destroyWindow(display, screen, window); + return; } - - screen.setScreenMode(-1, (short)-1); - Assert.assertEquals(originalScreenMode, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(originalScreenRate, screen.getCurrentScreenRate()); - - destroyWindow(display, screen, window); - } + Assert.assertTrue(screenModes.size()>0); - @Test - public void testScreenModeChangeWithFS01() 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); + Animator animator = new Animator(window); + animator.start(); - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - ScreenMode[] screenModes = screen.getScreenModes(); + 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); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - - int modeIndex = 1; - - ScreenMode screenMode = screenModes[modeIndex]; - Assert.assertNotNull(screenMode); - - short modeRate = screenMode.getRates()[0]; - screen.setScreenMode(modeIndex, modeRate); - - Assert.assertEquals(modeIndex, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(modeRate, screen.getCurrentScreenRate()); - - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - - for(int state=0; state<waitTimeLong; state++) { - Thread.sleep(100); - } - - window.setFullscreen(false); - Assert.assertEquals(false, window.isFullscreen()); - - screen.setScreenMode(-1, (short)-1); - Assert.assertEquals(originalScreenMode, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(originalScreenRate, screen.getCurrentScreenRate()); - - destroyWindow(display, screen, window); + Assert.assertTrue(screenModes.size()>0); + screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); + Assert.assertNotNull(screenModes); + 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); } - + @Test - public void testScreenModeChangeWithFS02() throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); + public void testScreenModeChangeWithFS01Pre() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(true) ; + Thread.sleep(waitTimeShort); + } + + @Test + public void testScreenModeChangeWithFS01Post() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(false) ; + Thread.sleep(waitTimeShort); + } + + protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); 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(); - ScreenMode[] screenModes = screen.getScreenModes(); - Assert.assertNotNull(screenModes); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - - int modeIndex = 1; - - ScreenMode screenMode = screenModes[modeIndex]; + ScreenMode smOrig = screen.getOriginalScreenMode(); + List screenModes = screen.getScreenModes(); + screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); + screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); + screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); + screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); + + ScreenMode screenMode = (ScreenMode) screenModes.get(0); Assert.assertNotNull(screenMode); - short modeRate = screenMode.getRates()[0]; - screen.setScreenMode(modeIndex, modeRate); - - Assert.assertEquals(modeIndex, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(modeRate, screen.getCurrentScreenRate()); - - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - - for(int state=0; state<waitTimeLong; state++) { - Thread.sleep(100); + if(preFS) { + System.err.println("[0] set FS pre 0: "+window.isFullscreen()); + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS pre X: "+window.isFullscreen()); } + + System.err.println("[0] set current: "+screenMode); + screen.setCurrentScreenMode(screenMode); + + 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); - screen.setScreenMode(-1, (short)-1); - Assert.assertEquals(originalScreenMode, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(originalScreenRate, screen.getCurrentScreenRate()); - - window.setFullscreen(false); - Assert.assertEquals(false, window.isFullscreen()); - - destroyWindow(display, screen, window); + // check reset .. + + ScreenMode saveOrigMode = (ScreenMode) smOrig.clone(); + + animator.stop(); + destroyWindow(null, screen, window); + + screen = NewtFactory.createScreen(display, 0); // screen 0 + screen.addReference(); // trigger native creation + + ScreenMode smCurrent = screen.getCurrentScreenMode(); + System.err.println("[1] current/orig: "+smCurrent); + + Assert.assertNotNull(smCurrent); + Assert.assertEquals(saveOrigMode, smOrig); + + destroyWindow(display, screen, null); } public static void main(String args[]) throws IOException { String tstname = TestScreenMode01NEWT.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); } } diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java index c46820ffd..6aaf4a8d1 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java @@ -102,157 +102,18 @@ public class TestScreenMode02NEWT extends UITestCase { @Test public void testScreenRotationChange01() throws InterruptedException { - Capabilities caps = new Capabilities(); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - ScreenMode[] screenModes = screen.getScreenModes(); - Assert.assertNotNull(screenModes); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - int originalScreenRotation = screen.getCurrentScreenRotation(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - Assert.assertNotSame(-1, originalScreenRotation); - - screen.setScreenRotation(ScreenMode.ROTATE_90); - Assert.assertEquals(ScreenMode.ROTATE_90, screen.getCurrentScreenRotation()); - - Thread.sleep(waitTimeShort); - - screen.setScreenRotation(originalScreenRotation); - Assert.assertEquals(originalScreenRotation, screen.getCurrentScreenRotation()); - - destroyWindow(display, screen, window); } @Test public void testScreenRotationChange02() throws InterruptedException { - Capabilities caps = new Capabilities(); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - ScreenMode[] screenModes = screen.getScreenModes(); - Assert.assertNotNull(screenModes); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - int originalScreenRotation = screen.getCurrentScreenRotation(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - Assert.assertNotSame(-1, originalScreenRotation); - - screen.setScreenRotation(ScreenMode.ROTATE_180); - Assert.assertEquals(ScreenMode.ROTATE_180, screen.getCurrentScreenRotation()); - - Thread.sleep(waitTimeShort); - - screen.setScreenRotation(originalScreenRotation); - Assert.assertEquals(originalScreenRotation, screen.getCurrentScreenRotation()); - - destroyWindow(display, screen, window); } @Test public void testScreenRotationChange03() throws InterruptedException { - Capabilities caps = new Capabilities(); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - ScreenMode[] screenModes = screen.getScreenModes(); - Assert.assertNotNull(screenModes); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - int originalScreenRotation = screen.getCurrentScreenRotation(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - Assert.assertNotSame(-1, originalScreenRotation); - - screen.setScreenRotation(ScreenMode.ROTATE_270); - Assert.assertEquals(ScreenMode.ROTATE_270, screen.getCurrentScreenRotation()); - - Thread.sleep(waitTimeShort); - - screen.setScreenRotation(originalScreenRotation); - Assert.assertEquals(originalScreenRotation, screen.getCurrentScreenRotation()); - - destroyWindow(display, screen, window); } @Test public void testScreenModeChangeWithRotate01() throws InterruptedException { - Capabilities caps = new Capabilities(); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - ScreenMode[] screenModes = screen.getScreenModes(); - Assert.assertNotNull(screenModes); - - int originalScreenMode = screen.getDesktopScreenModeIndex(); - short originalScreenRate = screen.getCurrentScreenRate(); - int originalScreenRotation = screen.getCurrentScreenRotation(); - - Assert.assertNotSame(-1, originalScreenMode); - Assert.assertNotSame(-1, originalScreenRate); - Assert.assertNotSame(-1, originalScreenRotation); - - - int modeIndex = 1; - if(screenModes.length > 4) - { - modeIndex = screenModes.length - 2; - } - ScreenMode screenMode = screenModes[modeIndex]; - Assert.assertNotNull(screenMode); - - short modeRate = screenMode.getRates()[0]; - screen.setScreenMode(modeIndex, modeRate); - - Assert.assertEquals(modeIndex, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(modeRate, screen.getCurrentScreenRate()); - - Thread.sleep(waitTimeLong); - - screen.setScreenRotation(ScreenMode.ROTATE_180); - Assert.assertEquals(ScreenMode.ROTATE_180, screen.getCurrentScreenRotation()); - - Thread.sleep(waitTimeShort); - - screen.setScreenRotation(originalScreenRotation); - Assert.assertEquals(originalScreenRotation, screen.getCurrentScreenRotation()); - - Thread.sleep(waitTimeShort); - - screen.setScreenMode(-1, (short)-1); - Assert.assertEquals(originalScreenMode, screen.getDesktopScreenModeIndex()); - Assert.assertEquals(originalScreenRate, screen.getCurrentScreenRate()); - - destroyWindow(display, screen, window); } |