aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java68
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java79
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java5
5 files changed, 82 insertions, 78 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
index f431e099b..8846812e5 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
@@ -46,6 +46,7 @@ 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;
@@ -105,16 +106,16 @@ public class TestScreenMode01aNEWT extends UITestCase {
public void testScreenModeChange01() throws InterruptedException {
Thread.sleep(waitTimeShort);
- GLCapabilities caps = new GLCapabilities(glp);
+ final GLCapabilities caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
+ final Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
Assert.assertNotNull(screen);
- Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height);
+ final Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height);
Assert.assertNotNull(window0);
- List<MonitorMode> allMonitorModes = screen.getMonitorModes();
+ final List<MonitorMode> allMonitorModes = screen.getMonitorModes();
Assert.assertTrue(allMonitorModes.size()>0);
if(allMonitorModes.size()==1) {
// no support ..
@@ -123,7 +124,7 @@ public class TestScreenMode01aNEWT extends UITestCase {
return;
}
- MonitorDevice monitor = window0.getMainMonitor();
+ final MonitorDevice monitor = screen.getMonitorDevices().get(0);
List<MonitorMode> monitorModes = monitor.getSupportedModes();
Assert.assertTrue(monitorModes.size()>0);
@@ -135,13 +136,13 @@ public class TestScreenMode01aNEWT extends UITestCase {
}
Assert.assertTrue(allMonitorModes.containsAll(monitorModes));
- MonitorMode mmCurrent = monitor.queryCurrentMode();
- Assert.assertNotNull(mmCurrent);
- MonitorMode mmOrig = monitor.getOriginalMode();
+ final MonitorMode mmSet0 = monitor.queryCurrentMode();
+ Assert.assertNotNull(mmSet0);
+ final MonitorMode mmOrig = monitor.getOriginalMode();
Assert.assertNotNull(mmOrig);
System.err.println("[0] orig : "+mmOrig);
- System.err.println("[0] current: "+mmCurrent);
- Assert.assertEquals(mmCurrent, mmOrig);
+ System.err.println("[0] current: "+mmSet0);
+ Assert.assertEquals(mmSet0, mmOrig);
monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
@@ -171,44 +172,43 @@ public class TestScreenMode01aNEWT extends UITestCase {
Thread.sleep(waitTimeShort);
- // check manual reset ..
-
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window0.isNativeValid());
Assert.assertEquals(true,window0.isVisible());
- screen.addReference(); // keep it alive !
- Assert.assertTrue(monitor.setCurrentMode(mmOrig));
- Assert.assertFalse(monitor.isModeChangedByUs());
- Assert.assertEquals(mmOrig, monitor.getCurrentMode());
- Assert.assertNotSame(mm, monitor.getCurrentMode());
- Assert.assertEquals(mmOrig, monitor.queryCurrentMode());
-
+ // Auto reset by destruction!
destroyWindow(window0);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window0, false));
+
Assert.assertEquals(false,window0.isVisible());
Assert.assertEquals(false,window0.isNativeValid());
- Assert.assertEquals(true,screen.isNativeValid()); // alive !
- Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(false,display.isNativeValid());
Thread.sleep(waitTimeShort);
-
- Window window1 = createWindow(screen, caps, "win1",
- width+window0.getInsets().getTotalWidth(), 0,
- width, height);
- Assert.assertNotNull(window1);
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(true,window1.isVisible());
- Thread.sleep(waitTimeShort);
+ validateScreenModeReset(mmOrig, 0);
+ }
+
+ void validateScreenModeReset(final MonitorMode mmOrig, int mmIdx) {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Assert.assertEquals(false,display.isNativeValid());
+ Assert.assertEquals(false,screen.isNativeValid());
+ screen.addReference();
+ Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(true,screen.isNativeValid());
- destroyWindow(window1);
- Assert.assertEquals(false,window1.isNativeValid());
- Assert.assertEquals(false,window1.isVisible());
+ final MonitorDevice monitor = screen.getMonitorDevices().get(0);
+ Assert.assertEquals(mmOrig, monitor.getCurrentMode());
screen.removeReference();
+ Assert.assertEquals(false,display.isNativeValid());
Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,display.isNativeValid());
}
public static void main(String args[]) throws IOException {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
index c80760c1f..fbd08b619 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
@@ -46,6 +46,7 @@ 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.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
@@ -230,6 +231,8 @@ public class TestScreenMode01bNEWT extends UITestCase {
Thread.sleep(duration);
anim.stop();
destroyWindow(window0);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window0, false));
+
Assert.assertEquals(false,window0.isVisible());
Assert.assertEquals(false,window0.isNativeValid());
Assert.assertEquals(true,display.isNativeValid());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
index 48ebaf86e..afb26d75c 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
@@ -53,11 +53,17 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.util.List;
import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.Rectangle;
+import javax.media.nativewindow.util.RectangleImmutable;
/**
* Demonstrates fullscreen without MonitorMode change
* and fullscreen before and after MonitorMode change.
* <p>
+ * Also tests MonitorMode reset, by destroying the last Screen (reference),
+ * i.e. the original MonitorMode should get reinstated!
+ * </p>
+ * <p>
* Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.</p>
*/
public class TestScreenMode01dNEWT extends UITestCase {
@@ -137,7 +143,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
}
@Test
- public void testFullscreenChange01() throws InterruptedException {
+ public void test01FullscreenChange01() throws InterruptedException {
Thread.sleep(waitTimeShort);
GLCapabilities caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
@@ -183,7 +189,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
}
@Test
- public void testScreenModeChange01() throws InterruptedException {
+ public void test02ScreenModeChange01() throws InterruptedException {
Thread.sleep(waitTimeShort);
GLCapabilities caps = new GLCapabilities(glp);
@@ -195,7 +201,8 @@ public class TestScreenMode01dNEWT extends UITestCase {
GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
Assert.assertNotNull(window);
- MonitorDevice monitor = window.getMainMonitor();
+ final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight());
+ final MonitorDevice monitor = screen.getMainMonitor(winRect);
List<MonitorMode> monitorModes = monitor.getSupportedModes();
Assert.assertTrue(monitorModes.size()>0);
@@ -244,8 +251,6 @@ public class TestScreenMode01dNEWT extends UITestCase {
Thread.sleep(waitTimeLong);
- // check reset ..
-
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
@@ -265,33 +270,20 @@ public class TestScreenMode01dNEWT extends UITestCase {
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);
-
+ validateScreenModeReset(mmOrig, winRect);
cleanupGL();
}
@Test
- public void testScreenModeChangeWithFS01Pre() throws InterruptedException {
+ public void test03ScreenModeChangeWithFS01Post() throws InterruptedException {
Thread.sleep(waitTimeShort);
- testScreenModeChangeWithFS01Impl(true) ;
+ testScreenModeChangeWithFS01Impl(false) ;
}
@Test
- public void testScreenModeChangeWithFS01Post() throws InterruptedException {
+ public void test04ScreenModeChangeWithFS01Pre() throws InterruptedException {
Thread.sleep(waitTimeShort);
- testScreenModeChangeWithFS01Impl(false) ;
+ testScreenModeChangeWithFS01Impl(true) ;
}
protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException {
@@ -302,7 +294,8 @@ public class TestScreenMode01dNEWT extends UITestCase {
Animator animator = new Animator(window);
animator.start();
- MonitorDevice monitor = window.getMainMonitor();
+ final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight());
+ final MonitorDevice monitor = screen.getMainMonitor(winRect);
MonitorMode mmCurrent = monitor.queryCurrentMode();
Assert.assertNotNull(mmCurrent);
MonitorMode mmOrig = monitor.getOriginalMode();
@@ -347,8 +340,14 @@ public class TestScreenMode01dNEWT extends UITestCase {
Thread.sleep(waitTimeLong);
- // check reset ..
-
+ if(!preFS) {
+ System.err.println("[0] set !FS post 0: "+window.isFullscreen());
+ window.setFullscreen(false);
+ Assert.assertEquals(false, window.isFullscreen());
+ System.err.println("[0] set !FS post X: "+window.isFullscreen());
+ Thread.sleep(waitTimeShort);
+ }
+
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
@@ -368,23 +367,29 @@ public class TestScreenMode01dNEWT extends UITestCase {
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
- screen.createNative(); // trigger native re-creation
+ validateScreenModeReset(mmOrig, winRect);
+ cleanupGL();
+ }
+ void validateScreenModeReset(final MonitorMode mmOrig, final RectangleImmutable rect) {
+ final Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Assert.assertEquals(false,display.isNativeValid());
+ Assert.assertEquals(false,screen.isNativeValid());
+ screen.addReference();
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);
+ final MonitorDevice monitor = screen.getMainMonitor(rect);
+ Assert.assertEquals(mmOrig, monitor.getCurrentMode());
- cleanupGL();
+ screen.removeReference();
+ Assert.assertEquals(false,display.isNativeValid());
+ Assert.assertEquals(false,screen.isNativeValid());
}
-
+
public static void main(String args[]) throws IOException {
String tstname = TestScreenMode01dNEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
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 aee9c28c2..f261a24a5 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
@@ -59,10 +59,6 @@ import javax.media.nativewindow.util.Dimension;
* <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>
*/
public class TestScreenMode02aNEWT extends UITestCase {
static GLProfile glp;
@@ -200,6 +196,7 @@ public class TestScreenMode02aNEWT extends UITestCase {
}
if(changeMode) {
+ // manual restore!
monitor.setCurrentMode(mmOrig);
Assert.assertFalse(monitor.isModeChangedByUs());
Assert.assertEquals(mmOrig, monitor.getCurrentMode());
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
index bd7ac55db..f0dbb1ffc 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java
@@ -204,17 +204,16 @@ public class TestScreenMode02bNEWT extends UITestCase {
window.setFullscreen(false);
}
+ // manual restore!
monitor.setCurrentMode(mmOrig);
Assert.assertFalse(monitor.isModeChangedByUs());
- Assert.assertEquals(mmOrig, monitor.getCurrentMode());
+ Assert.assertEquals(mmOrig, monitor.queryCurrentMode());
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());