diff options
Diffstat (limited to 'src/test/com/jogamp')
11 files changed, 388 insertions, 354 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index fc08301cb..5cbcb7380 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -33,6 +33,7 @@ import java.net.URISyntaxException; import java.net.URLConnection; import java.util.Arrays; +import javax.media.nativewindow.util.Rectangle; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -46,7 +47,6 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; - import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; @@ -120,7 +120,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { { final int padding = mPlayerHUD ? 32 : 0; final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowMain.getDelegatedWindow()).getAndroidView(); - glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding); + glWindowMain.setSurfaceSize(scrn.getWidth()-padding, scrn.getHeight()-padding); glWindowMain.setUndecorated(true); // setContentView(getWindow(), glWindowMain); viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowMain.getSurfaceWidth(), glWindowMain.getSurfaceHeight(), Gravity.BOTTOM|Gravity.RIGHT)); @@ -172,15 +172,13 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { public boolean run(GLAutoDrawable drawable) { final GLMediaPlayer mPlayerSub; final MovieSimple demoHUD; - int x2 = scrn.getX(); - int y2 = scrn.getY(); - int w2 = scrn.getWidth()/3; - int h2 = scrn.getHeight()/3; + final Rectangle windowBounds = scrn.getViewportInWindowUnits(glWindowHUD); if(null != mPlayerShared) { if(0 < mPlayerShared.getWidth() && mPlayerShared.getWidth()<scrn.getWidth()/2 && 0 < mPlayerShared.getHeight() && mPlayerShared.getHeight()<scrn.getHeight()/2) { - w2 = mPlayerShared.getWidth(); - h2 = mPlayerShared.getHeight(); + final int[] wh = glWindowHUD.convertToWindowUnits(new int[]{mPlayerShared.getWidth(), mPlayerShared.getHeight()}); + windowBounds.setWidth( wh[0] ); + windowBounds.setHeight( wh[1] ); } glWindowHUD.setSharedContext(glWindowMain.getContext()); demoHUD = new MovieSimple(mPlayerShared); @@ -209,10 +207,10 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { }); demoHUD.initStream(streamLoc1, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); - glWindowHUD.setPosition(x2, y2); - glWindowHUD.setSize(w2, h2); + glWindowHUD.setPosition(windowBounds.getX(), windowBounds.getY()); + glWindowHUD.setSize(windowBounds.getWidth(), windowBounds.getHeight()); System.err.println("HUD: "+mPlayerHUD); - System.err.println("HUD: "+w2+"x"+h2); + System.err.println("HUD: "+windowBounds); glWindowHUD.addMouseListener(toFrontMouseListener); viewGroup.post(new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java index beaf60460..a07d3c97b 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -46,24 +46,24 @@ import android.util.Log; public class NEWTGearsES2TransActivity extends NewtBaseActivity { static String TAG = "NEWTGearsES2TransActivity"; - + @Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate - 0"); super.onCreate(savedInstanceState); - + // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES2)); caps.setBackgroundOpaque(false); - + Log.d(TAG, "req caps: "+caps); Screen screen = NewtFactory.createScreen(NewtFactory.createDisplay(null), 0); screen.addReference(); GLWindow glWindow = GLWindow.create(screen, caps); - glWindow.setSize(2*screen.getWidth()/3, 2*screen.getHeight()/3); + glWindow.setSurfaceSize(2*screen.getWidth()/3, 2*screen.getHeight()/3); glWindow.setUndecorated(true); setContentView(getWindow(), glWindow); - + glWindow.addGLEventListener(new GearsES2(-1)); glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { @Override @@ -75,14 +75,14 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity { }); Animator animator = new Animator(glWindow); // glWindow.setSkipContextReleaseThread(animator.getThread()); - + glWindow.setVisible(true); - + animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); glWindow.resetFPSCounter(); - + screen.removeReference(); Log.d(TAG, "onCreate - X"); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java index f1bc0ab7a..00001d8d2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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.jogl.acore; import javax.media.nativewindow.Capabilities; @@ -55,44 +55,45 @@ import com.jogamp.opengl.util.Animator; */ public abstract class InitConcurrentBaseNEWT extends UITestCase { - static final int demoSize = 128; - + static final int demoWinSize = 128; + static long duration = 300; // ms - + static InsetsImmutable insets = null; - static int scrnHeight, scrnWidth; static int num_x, num_y; - + @BeforeClass public static void initClass() { Window dummyWindow = NewtFactory.createWindow(new Capabilities()); - dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setSize(demoWinSize, demoWinSize); dummyWindow.setVisible(true); Assert.assertEquals(true, dummyWindow.isVisible()); Assert.assertEquals(true, dummyWindow.isNativeValid()); - insets = dummyWindow.getInsets(); - scrnHeight = dummyWindow.getScreen().getHeight(); - scrnWidth = dummyWindow.getScreen().getWidth(); - num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; - num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + insets = dummyWindow.getInsets(); + final int scrnHeight = dummyWindow.getScreen().getHeight(); + final int scrnWidth = dummyWindow.getScreen().getWidth(); + final int[] demoScreenSize = dummyWindow.convertToPixelUnits(new int[] { demoWinSize, demoWinSize }); + final int[] insetsScreenSize = dummyWindow.convertToPixelUnits(new int[] { insets.getTotalWidth(), insets.getTotalHeight() }); + num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2; + num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2; dummyWindow.destroy(); } - + public class JOGLTask implements Runnable { private final int id; private final Object postSync; private final boolean reuse; private boolean done = false; - + public JOGLTask(Object postSync, int id, boolean reuse) { this.postSync = postSync; this.id = id; this.reuse = reuse; } public void run() { - int x = ( id % num_x ) * ( demoSize + insets.getTotalHeight() ); - int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ); - + int x = ( id % num_x ) * ( demoWinSize + insets.getTotalHeight() ); + int y = ( (id / num_x) % num_y ) * ( demoWinSize + insets.getTotalHeight() ); + System.err.println("JOGLTask "+id+": START: "+x+"/"+y+", reuse "+reuse+" - "+Thread.currentThread().getName()); final Display display = NewtFactory.createDisplay(null, reuse); final Screen screen = NewtFactory.createScreen(display, 0); @@ -100,25 +101,25 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setTitle("Task "+id); glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() ); - + glWindow.addGLEventListener(new ValidateLockListener()); glWindow.addGLEventListener(new GearsES2(0)); - + Animator animator = new Animator(glWindow); - - glWindow.setSize(demoSize, demoSize); + + glWindow.setSize(demoWinSize, demoWinSize); glWindow.setVisible(true); animator.setUpdateFPSFrames(60, null); - + System.err.println("JOGLTask "+id+": INITIALIZED: "+", "+display+" - "+Thread.currentThread().getName()); - + animator.start(); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(true, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertEquals(true, glWindow.isRealized()); System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName()); - + while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { try { Thread.sleep(100); @@ -126,10 +127,10 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { e.printStackTrace(); } } - + animator.stop(); glWindow.destroy(); - + System.err.println("JOGLTask "+id+": DONE/SYNC: "+Thread.currentThread().getName()); synchronized (postSync) { done = true; @@ -137,7 +138,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { postSync.notifyAll(); } } - + public boolean done() { return done; } } @@ -161,7 +162,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { sb.append("]"); return sb.toString(); } - + protected static boolean isDead(Thread[] threads) { for(int i=threads.length-1; i>=0; i--) { if(threads[i].isAlive()) { @@ -182,7 +183,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { sb.append("]"); return sb.toString(); } - + protected void runJOGLTasks(int num, boolean reuse) throws InterruptedException { System.err.println("InitConcurrentBaseNEWT "+num+" threads, reuse display: "+reuse); final String currentThreadName = Thread.currentThread().getName(); @@ -194,8 +195,8 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { tasks[i] = new JOGLTask(syncDone, i, reuse); threads[i] = new Thread(tasks[i], currentThreadName+"-jt"+i); } - final long t0 = System.currentTimeMillis(); - + final long t0 = System.currentTimeMillis(); + for(i=0; i<num; i++) { threads[i].start(); } @@ -213,13 +214,13 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { } final long t1 = System.currentTimeMillis(); System.err.println("total: "+(t1-t0)/1000.0+"s"); - + Assert.assertTrue("Tasks are incomplete. Complete: "+doneDump(tasks), done(tasks)); i=0; while(i<30 && !isDead(threads)) { Thread.sleep(100); i++; } - Assert.assertTrue("Threads are still alive after 3s. Alive: "+isAliveDump(threads), isDead(threads)); - } + Assert.assertTrue("Threads are still alive after 3s. Alive: "+isAliveDump(threads), isDead(threads)); + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java index 4980e8562..f1a185c31 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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.jogl.acore.ect; import com.jogamp.newt.NewtFactory; @@ -54,44 +54,45 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase. + * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase. */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public abstract class ExclusiveContextBase00 extends UITestCase { static boolean testExclusiveWithAWT = false; - static final int durationParts = 9; + static final int durationParts = 9; static long duration = 320 * durationParts; // ms ~ 20 frames - + static boolean showFPS = false; static int showFPSRate = 100; - - static final int demoSize = 128; - + + static final int demoWinSize = 128; + static InsetsImmutable insets = null; - static int scrnHeight, scrnWidth; static int num_x, num_y; - + static int swapInterval = 0; - + @BeforeClass public static void initClass00() { Window dummyWindow = NewtFactory.createWindow(new Capabilities()); - dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setSize(demoWinSize, demoWinSize); dummyWindow.setVisible(true); Assert.assertEquals(true, dummyWindow.isVisible()); Assert.assertEquals(true, dummyWindow.isNativeValid()); - insets = dummyWindow.getInsets(); - scrnHeight = dummyWindow.getScreen().getHeight(); - scrnWidth = dummyWindow.getScreen().getWidth(); - num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; - num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + insets = dummyWindow.getInsets(); + final int scrnHeight = dummyWindow.getScreen().getHeight(); + final int scrnWidth = dummyWindow.getScreen().getWidth(); + final int[] demoScreenSize = dummyWindow.convertToPixelUnits(new int[] { demoWinSize, demoWinSize }); + final int[] insetsScreenSize = dummyWindow.convertToPixelUnits(new int[] { insets.getTotalWidth(), insets.getTotalHeight() }); + num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2; + num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2; dummyWindow.destroy(); } @AfterClass public static void releaseClass00() { } - + protected abstract boolean isAWTTestCase(); protected abstract Thread getAWTRenderThread(); protected abstract AnimatorBase createAnimator(); @@ -120,16 +121,16 @@ public abstract class ExclusiveContextBase00 extends UITestCase { } final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; for(int i=0; i<drawableCount; i++) { - final int x = ( i % num_x ) * ( demoSize + insets.getTotalHeight() ) + insets.getLeftWidth(); - final int y = ( (i / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ) + insets.getTopHeight(); - - drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoSize, demoSize, caps); + final int x = ( i % num_x ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getLeftWidth(); + final int y = ( (i / num_x) % num_y ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getTopHeight(); + + drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoWinSize, demoWinSize, caps); Assert.assertNotNull(drawables[i]); final GearsES2 demo = new GearsES2(swapInterval); demo.setVerbose(false); drawables[i].addGLEventListener(demo); } - + if( preAdd ) { for(int i=0; i<drawableCount; i++) { animator.add(drawables[i]); @@ -144,10 +145,10 @@ public abstract class ExclusiveContextBase00 extends UITestCase { } Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); - + // Animator Start Assert.assertTrue(animator.start()); - + Assert.assertTrue(animator.isStarted()); if( preAdd ) { Assert.assertTrue(animator.isAnimating()); @@ -166,7 +167,7 @@ public abstract class ExclusiveContextBase00 extends UITestCase { Assert.assertTrue(animator.isAnimating()); } Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); - + // After start, ExclusiveContextThread is set { final Thread ect = animator.getExclusiveContextThread(); @@ -178,14 +179,14 @@ public abstract class ExclusiveContextBase00 extends UITestCase { } } else { Assert.assertEquals(null, ect); - } + } for(int i=0; i<drawableCount; i++) { Assert.assertEquals(ect, drawables[i].getExclusiveContextThread()); } setGLAutoDrawableVisible(drawables); } animator.setUpdateFPSFrames(showFPSRate, showFPS ? System.err : null); - + // Normal run .. Thread.sleep(duration/durationParts); // 1 @@ -197,19 +198,19 @@ public abstract class ExclusiveContextBase00 extends UITestCase { Assert.assertEquals(awtRenderThread, ect); } else { Assert.assertEquals(animator.getThread(), ect); - } + } for(int i=0; i<drawableCount; i++) { final Thread t = drawables[i].setExclusiveContextThread(null); Assert.assertEquals(ect, t); } - + Thread.sleep(duration/durationParts); // 2 - + for(int i=0; i<drawableCount; i++) { // poll until clearing drawable ECT is established { boolean ok = null == drawables[i].getExclusiveContextThread(); - int c = 0; + int c = 0; while(!ok && c<5*50) { // 5*50*20 = 5s TO Thread.sleep(20); ok = null == drawables[i].getExclusiveContextThread(); @@ -223,10 +224,10 @@ public abstract class ExclusiveContextBase00 extends UITestCase { final Thread t = drawables[i].setExclusiveContextThread(ect); Assert.assertEquals(null, t); } - + Thread.sleep(duration/durationParts); // 3 } - + // Disable/Enable exclusive mode via Animator for all GLAutoDrawable if(exclusive) { final Thread ect = animator.getExclusiveContextThread(); @@ -234,31 +235,31 @@ public abstract class ExclusiveContextBase00 extends UITestCase { Assert.assertEquals(awtRenderThread, ect); } else { Assert.assertEquals(animator.getThread(), ect); - } - + } + Assert.assertEquals(true, animator.setExclusiveContext(false)); Assert.assertFalse(animator.isExclusiveContextEnabled()); for(int i=0; i<drawableCount; i++) { Assert.assertEquals(null, drawables[i].getExclusiveContextThread()); } - + Thread.sleep(duration/durationParts); // 4 - + Assert.assertEquals(null, animator.setExclusiveContext(ect)); Assert.assertTrue(animator.isExclusiveContextEnabled()); Assert.assertEquals(ect, animator.getExclusiveContextThread()); for(int i=0; i<drawableCount; i++) { Assert.assertEquals(ect, drawables[i].getExclusiveContextThread()); } - + Thread.sleep(duration/durationParts); // 5 - } - + } + Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); Assert.assertFalse(animator.isPaused()); - + // Animator Pause Assert.assertTrue(animator.pause()); Assert.assertTrue(animator.isStarted()); @@ -277,9 +278,9 @@ public abstract class ExclusiveContextBase00 extends UITestCase { } for(int i=0; i<drawableCount; i++) { Assert.assertEquals(null, drawables[i].getExclusiveContextThread()); - } + } Thread.sleep(duration/durationParts); // 6 - + // Animator Resume Assert.assertTrue(animator.resume()); Assert.assertTrue(animator.isStarted()); @@ -295,32 +296,32 @@ public abstract class ExclusiveContextBase00 extends UITestCase { } for(int i=0; i<drawableCount; i++) { Assert.assertEquals(ect, drawables[i].getExclusiveContextThread()); - } + } } else { Assert.assertEquals(null, animator.getExclusiveContextThread()); for(int i=0; i<drawableCount; i++) { Assert.assertEquals(null, drawables[i].getExclusiveContextThread()); - } + } } Thread.sleep(duration/durationParts); // 7 - + // Animator Stop #1 - Assert.assertTrue(animator.stop()); + Assert.assertTrue(animator.stop()); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); - Assert.assertFalse(animator.isPaused()); + Assert.assertFalse(animator.isPaused()); Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); Assert.assertEquals(null, animator.getExclusiveContextThread()); for(int i=0; i<drawableCount; i++) { Assert.assertEquals(null, drawables[i].getExclusiveContextThread()); } Thread.sleep(duration/durationParts); // 8 - + // Animator Re-Start - Assert.assertTrue(animator.start()); + Assert.assertTrue(animator.start()); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); - Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); + Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); // After start, ExclusiveContextThread is set { final Thread ect = animator.getExclusiveContextThread(); @@ -332,13 +333,13 @@ public abstract class ExclusiveContextBase00 extends UITestCase { } } else { Assert.assertEquals(null, ect); - } + } for(int i=0; i<drawableCount; i++) { Assert.assertEquals(ect, drawables[i].getExclusiveContextThread()); } } Thread.sleep(duration/durationParts); // 9 - + // Remove all drawables .. while running! for(int i=0; i<drawableCount; i++) { final GLAutoDrawable drawable = drawables[i]; @@ -348,22 +349,22 @@ public abstract class ExclusiveContextBase00 extends UITestCase { Assert.assertTrue(animator.isStarted()); Assert.assertFalse(animator.isAnimating()); // no drawables in list! } // !shortenTest - + // Animator Stop #2 - Assert.assertTrue(animator.stop()); + Assert.assertTrue(animator.stop()); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); - Assert.assertFalse(animator.isPaused()); + Assert.assertFalse(animator.isPaused()); Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); Assert.assertEquals(null, animator.getExclusiveContextThread()); - + // Destroy GLWindows for(int i=0; i<drawableCount; i++) { destroyGLAutoDrawableVisible(drawables[i]); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(drawables[i], false)); - } - } - + } + } + @Test public void test01NormalPre_1Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); @@ -384,40 +385,40 @@ public abstract class ExclusiveContextBase00 extends UITestCase { final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 1 /* numWin */, true /* exclusive */, true /* preAdd */, false /* short */); } - + @Test public void test04ExclPost_1Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 1 /* numWin */, true /* exclusive */, false /* preAdd */, true /* short */); } - + @Test public void test05NormalPre_4Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 4 /* numWin */, false /* exclusive */, true /* preAdd */, false /* short */); } - + @Test public void test06NormalPost_4Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 4 /* numWin */, false /* exclusive */, false /* preAdd */, true /* short */); } - + @Test public void test07ExclPre_4Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 4 /* numWin */, true /* exclusive */, true /* preAdd */, false /* short */); } - + @Test public void test08ExclPost_4Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 4 /* numWin */, true /* exclusive */, false /* preAdd */, true /* short */); } - + } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java index 516622796..b6d4c4e6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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.jogl.acore.ect; import com.jogamp.newt.NewtFactory; @@ -54,43 +54,44 @@ import org.junit.Test; import org.junit.runners.MethodSorters; /** - * ExclusiveContextThread base implementation to test performance impact of the ExclusiveContext feature with AnimatorBase. + * ExclusiveContextThread base implementation to test performance impact of the ExclusiveContext feature with AnimatorBase. */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public abstract class ExclusiveContextBase10 extends UITestCase { static boolean testExclusiveWithAWT = false; static long duration = 1400; - + static boolean showFPS = true; static int showFPSRate = 60; - - static final int demoSize = 128; - + + static final int demoWinSize = 128; + static InsetsImmutable insets = null; - static int scrnHeight, scrnWidth; static int num_x, num_y; - + static int swapInterval = 0; - + @BeforeClass public static void initClass00() { Window dummyWindow = NewtFactory.createWindow(new Capabilities()); - dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setSize(demoWinSize, demoWinSize); dummyWindow.setVisible(true); Assert.assertEquals(true, dummyWindow.isVisible()); Assert.assertEquals(true, dummyWindow.isNativeValid()); - insets = dummyWindow.getInsets(); - scrnHeight = dummyWindow.getScreen().getHeight(); - scrnWidth = dummyWindow.getScreen().getWidth(); - num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; - num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + insets = dummyWindow.getInsets(); + final int scrnHeight = dummyWindow.getScreen().getHeight(); + final int scrnWidth = dummyWindow.getScreen().getWidth(); + final int[] demoScreenSize = dummyWindow.convertToPixelUnits(new int[] { demoWinSize, demoWinSize }); + final int[] insetsScreenSize = dummyWindow.convertToPixelUnits(new int[] { insets.getTotalWidth(), insets.getTotalHeight() }); + num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2; + num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2; dummyWindow.destroy(); } @AfterClass public static void releaseClass00() { } - + protected abstract boolean isAWTTestCase(); protected abstract Thread getAWTRenderThread(); protected abstract AnimatorBase createAnimator(); @@ -119,16 +120,16 @@ public abstract class ExclusiveContextBase10 extends UITestCase { } final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; for(int i=0; i<drawableCount; i++) { - final int x = ( i % num_x ) * ( demoSize + insets.getTotalHeight() ) + insets.getLeftWidth(); - final int y = ( (i / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ) + insets.getTopHeight(); - - drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoSize, demoSize, caps); + final int x = ( i % num_x ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getLeftWidth(); + final int y = ( (i / num_x) % num_y ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getTopHeight(); + + drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoWinSize, demoWinSize, caps); Assert.assertNotNull(drawables[i]); final GearsES2 demo = new GearsES2(swapInterval); demo.setVerbose(false); drawables[i].addGLEventListener(demo); } - + for(int i=0; i<drawableCount; i++) { animator.add(drawables[i]); } @@ -141,14 +142,14 @@ public abstract class ExclusiveContextBase10 extends UITestCase { } Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); - + // Animator Start Assert.assertTrue(animator.start()); - + Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); - + // After start, ExclusiveContextThread is set { final Thread ect = animator.getExclusiveContextThread(); @@ -160,32 +161,32 @@ public abstract class ExclusiveContextBase10 extends UITestCase { } } else { Assert.assertEquals(null, ect); - } + } for(int i=0; i<drawableCount; i++) { Assert.assertEquals(ect, drawables[i].getExclusiveContextThread()); } setGLAutoDrawableVisible(drawables); } animator.setUpdateFPSFrames(showFPSRate, showFPS ? System.err : null); - + // Normal run .. Thread.sleep(duration); - + // Animator Stop #2 - Assert.assertTrue(animator.stop()); + Assert.assertTrue(animator.stop()); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); - Assert.assertFalse(animator.isPaused()); + Assert.assertFalse(animator.isPaused()); Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled()); Assert.assertEquals(null, animator.getExclusiveContextThread()); - + // Destroy GLWindows for(int i=0; i<drawableCount; i++) { destroyGLAutoDrawableVisible(drawables[i]); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(drawables[i], false)); - } - } - + } + } + @Test public void test01Normal_1Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); @@ -199,18 +200,18 @@ public abstract class ExclusiveContextBase10 extends UITestCase { final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 1 /* numWin */, true /* exclusive */); } - + @Test public void test05Normal_4Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 4 /* numWin */, false /* exclusive */); } - + @Test public void test07Excl_4Win() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); runTestGL(caps, 4 /* numWin */, true /* exclusive */); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java index 2f5fb2606..22154ab58 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java @@ -3,14 +3,14 @@ * * 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 @@ -20,27 +20,27 @@ * 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.jogl.newt; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; - import com.jogamp.opengl.test.junit.util.*; import java.lang.reflect.InvocationTargetException; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.util.Rectangle; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLCapabilities; import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.Animator; import com.jogamp.newt.Screen; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.awt.NewtCanvasAWT; @@ -57,6 +57,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; + import javax.media.opengl.GLEventListener; import javax.swing.JButton; import javax.swing.JFrame; @@ -158,7 +159,7 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { colorPanel.setBackground(Color.white); colorPanel.repaint(); }}); - + robot = new Robot(); robot.setAutoWaitForIdle(true); @@ -167,12 +168,12 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { Thread.sleep(AWTRobotUtil.TIME_SLICE); } Assert.assertEquals(true, frame.isVisible()); - + System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Before NativeWindow init"); - + NativeWindowFactory.initSingleton(); - - AWTRobotUtil.clearAWTFocus(robot); + + AWTRobotUtil.clearAWTFocus(robot); AWTRobotUtil.toFrontAndRequestFocus(robot, frame); AWTRobotUtil.requestFocus(robot, button); @@ -198,7 +199,7 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.release(): End"); } - protected void runTestGL(final Canvas canvas, GLAutoDrawable drawable) + protected void runTestGL(final Canvas canvas, GLAutoDrawable drawable) throws AWTException, InterruptedException, InvocationTargetException { Dimension size = new Dimension(400,400); @@ -268,9 +269,10 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { win0.setSize(100,100); win0.setVisible(true); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(win0, true)); - + Screen screen = win0.getScreen(); - win0.setPosition(screen.getWidth()-150, 0); + final Rectangle screenBoundsInWinU = screen.getViewportInWindowUnits(win0); + win0.setPosition(screenBoundsInWinU.getX()-150, 0); win0.addGLEventListener(new GearsES2()); Animator anim = new Animator(win0); anim.start(); @@ -282,14 +284,14 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { win0.destroy(); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(win0, false)); - Assert.assertEquals(false, win0.isNativeValid()); + Assert.assertEquals(false, win0.isNativeValid()); Assert.assertEquals(true, anim.isAnimating()); // due to newtCanvasAWT/win1 newtCanvasAWT.destroy(); // destroys both newtCanvasAWT/win1 Assert.assertEquals(false, win1.isNativeValid()); Assert.assertEquals(false, win0.isNativeValid()); Assert.assertEquals(true, anim.isAnimating()); - + Assert.assertEquals(true, anim.stop()); Assert.assertEquals(false, anim.isAnimating()); @@ -321,10 +323,10 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { GLCanvas glCanvas = new GLCanvas(caps); anim.add(glCanvas); runTestGL(glCanvas, glCanvas); - + anim.remove(glCanvas); Assert.assertEquals(false, anim.isAnimating()); - + /** win0.destroy(); Assert.assertEquals(true, anim.isAnimating()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java index 87cb6f05b..8c679d209 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -34,11 +34,13 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import javax.media.nativewindow.util.Rectangle; import javax.media.opengl.*; import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; + import java.io.IOException; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; @@ -68,7 +70,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { // // Create native windowing resources .. X11/Win/OSX - // + // GLWindow glWindow = GLWindow.create(caps); glWindow.setUpdateFPSFrames(1, null); @@ -147,7 +149,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { window.destroy(); Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - + Assert.assertEquals(screen,window.getScreen()); Assert.assertEquals(0,Display.getActiveDisplayNumber()); Assert.assertEquals(0,display.getReferenceCount()); @@ -195,7 +197,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { window.destroy(); Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - + Assert.assertEquals(screen,window.getScreen()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); @@ -239,7 +241,8 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { GLWindow window2 = createWindow(caps, width, height); Assert.assertSame(screen, window2.getScreen()); Assert.assertSame(display, window2.getScreen().getDisplay()); - window2.setPosition(screen.getWidth()-width, 0); + final Rectangle screenBoundsInWinU = screen.getViewportInWindowUnits(window2); + window2.setPosition(screenBoundsInWinU.getWidth()-width, 0); Assert.assertEquals(0,Display.getActiveDisplayNumber()); Assert.assertEquals(0,display.getReferenceCount()); @@ -298,7 +301,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { // destruction ... window1.destroy(); Assert.assertTrue(AWTRobotUtil.waitForRealized(window1, false)); - + Assert.assertNotNull(window1.getScreen()); Assert.assertEquals(false,window1.isNativeValid()); Assert.assertEquals(false,window1.isVisible()); @@ -316,7 +319,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { window2.destroy(); Assert.assertTrue(AWTRobotUtil.waitForRealized(window2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - + Assert.assertNotNull(window2.getScreen()); Assert.assertEquals(false,window2.isNativeValid()); Assert.assertEquals(false,window2.isVisible()); @@ -331,12 +334,12 @@ public class TestDisplayLifecycle02NEWT extends UITestCase { Assert.assertEquals(0,screen.getReferenceCount()); Assert.assertEquals(false,screen.isNativeValid()); - // invalidate (again) .. + // invalidate (again) .. window1.destroy(); Assert.assertEquals(false,window1.isNativeValid()); Assert.assertEquals(false,window1.isVisible()); - // invalidate (again) .. + // invalidate (again) .. window2.destroy(); Assert.assertEquals(false,window2.isNativeValid()); Assert.assertEquals(false,window2.isVisible()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java index 86cb53319..6bad27384 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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; @@ -35,12 +35,14 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import javax.media.nativewindow.util.Rectangle; import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; + import java.io.IOException; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -67,7 +69,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { // // Create native windowing resources .. X11/Win/OSX - // + // GLWindow glWindow; if(null!=screen) { Window window = NewtFactory.createWindow(screen, caps); @@ -76,7 +78,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { } else { glWindow = GLWindow.create(caps); } - glWindow.setUpdateFPSFrames(1, null); + glWindow.setUpdateFPSFrames(1, null); Assert.assertNotNull(glWindow); glWindow.setUndecorated(onscreen && undecorated); @@ -96,9 +98,9 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { // System.out.println("Created: "+glWindow); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) - // + // GLCapabilitiesImmutable caps2 = glWindow.getChosenGLCapabilities(); Assert.assertNotNull(caps2); Assert.assertTrue(caps2.getGreenBits()>=5); @@ -121,18 +123,18 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertNotNull(caps); GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */, true /* vsync */); Animator animator = new Animator(window); - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(1, null); Assert.assertTrue(animator.start()); while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { Thread.sleep(100); } - destroyWindow(window); // destroy - but still in animator + destroyWindow(window); // destroy - but still in animator Assert.assertEquals(false, window.isNativeValid()); - Assert.assertEquals(false, window.isVisible()); + Assert.assertEquals(false, window.isVisible()); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); Assert.assertEquals(true, animator.isStarted()); - + animator.remove(window); Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); @@ -147,7 +149,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertNotNull(caps); GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */, true /* vsync */); Animator animator = new Animator(); - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(1, null); Assert.assertTrue(animator.start()); Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); // zero drawables @@ -185,10 +187,11 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { GLWindow window2 = createWindow(screen, caps, width-10, height-10, true /* onscreen */, false /* undecorated */, true /* vsync */); Assert.assertNotNull(window2); - window2.setPosition(screen.getWidth()-width, 0); + final Rectangle screenBoundsInWinU = screen.getViewportInWindowUnits(window2); + window2.setPosition(screenBoundsInWinU.getWidth()-width, 0); Animator animator = new Animator(); - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(1, null); Assert.assertEquals(false, animator.isStarted()); Assert.assertEquals(false, animator.isAnimating()); // zero drawables Assert.assertEquals(false, animator.isPaused()); // zero drawables, but not started @@ -251,10 +254,11 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertNotNull(screen2); GLWindow window2 = createWindow(screen2, caps, width-10, height-10, true /* onscreen */, false /* undecorated */, true /* vsync */); Assert.assertNotNull(window2); - window2.setPosition(screen2.getWidth()-width, 0); + final Rectangle screen2BoundsInWinU = screen2.getViewportInWindowUnits(window2); + window2.setPosition(screen2BoundsInWinU.getWidth()-width, 0); Animator animator = new Animator(); - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(1, null); Assert.assertEquals(false, animator.isStarted()); Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); @@ -287,23 +291,23 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest+durationPerTest/10) { Thread.sleep(100); } - - Assert.assertEquals(true, animator.isStarted()); + + Assert.assertEquals(true, animator.isStarted()); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); - + Assert.assertEquals(true, animator.pause()); - - Assert.assertEquals(true, animator.isStarted()); + + Assert.assertEquals(true, animator.isStarted()); Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(true, animator.isPaused()); Assert.assertEquals(true, animator.resume()); - + Assert.assertEquals(true, animator.isStarted()); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(false, animator.isPaused()); - + destroyWindow(window2); animator.remove(window2); Assert.assertEquals(true, animator.isStarted()); 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 871012a28..ac5e7e53c 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 @@ -3,14 +3,14 @@ * * 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 @@ -20,15 +20,16 @@ * 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; @@ -54,7 +55,9 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import java.util.List; + import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; /** @@ -64,7 +67,7 @@ import javax.media.nativewindow.util.RectangleImmutable; public class TestScreenMode01bNEWT extends UITestCase { static GLProfile glp; static int width, height; - + static long waitTimeShort = 2000; static long duration = 6000; @@ -80,14 +83,15 @@ public class TestScreenMode01bNEWT extends UITestCase { 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) throws InterruptedException { + + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int screenXPos, int screenYPos, int width, int height) throws InterruptedException { Assert.assertNotNull(caps); GLWindow window = GLWindow.create(screen, caps); // Window window = NewtFactory.createWindow(screen, caps); + final int[] winPos = window.convertToWindowUnits(new int[] { screenXPos, screenYPos }); window.setTitle(name); - window.setPosition(x, y); + window.setPosition(winPos[0], winPos[1]); window.setSize(width, height); window.addGLEventListener(new GearsES2()); Assert.assertNotNull(window); @@ -100,10 +104,10 @@ public class TestScreenMode01bNEWT extends UITestCase { static void destroyWindow(Window window) throws InterruptedException { if(null!=window) { window.destroy(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); } } - + @Test public void testScreenModeChangeSingleQ1() throws InterruptedException { final Display display = NewtFactory.createDisplay(null); // local display @@ -119,7 +123,7 @@ public class TestScreenMode01bNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); } } - + @Test public void testScreenModeChangeSingleQ2() throws InterruptedException { final Display display = NewtFactory.createDisplay(null); // local display @@ -139,24 +143,26 @@ public class TestScreenMode01bNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); } } - - void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException { + + void testScreenModeChangeImpl(final Screen screen, int screenXPos, int screenYPos) throws InterruptedException { Thread.sleep(waitTimeShort); final GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); final Display display = screen.getDisplay(); System.err.println("Test.0: Window screen: "+screen); - - System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); - - GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); - Assert.assertNotNull(window0); - System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport()); + + System.err.println("Test.0: Window bounds (pre): screenPos "+screenXPos+"/"+screenYPos+" [pixels], windowSize "+width+"x"+height+" [wu] within "+screen.getViewport()+" [pixels]"); + + GLWindow window0 = createWindow(screen, caps, "win0", screenXPos, screenYPos, width, height); + Assert.assertNotNull(window0); + Rectangle window0ScreenRect = window0.getSurfaceBounds(); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]"); + System.err.println("Test.0: Window screenRect: "+window0ScreenRect+" [pixels]"); final Animator anim = new Animator(window0); anim.start(); - + List<MonitorMode> allMonitorModes = screen.getMonitorModes(); Assert.assertTrue(allMonitorModes.size()>0); if(allMonitorModes.size()==1) { @@ -168,7 +174,7 @@ public class TestScreenMode01bNEWT extends UITestCase { MonitorDevice monitor = window0.getMainMonitor(); System.err.println("Test.0: Window monitor: "+monitor); - + List<MonitorMode> monitorModes = monitor.getSupportedModes(); Assert.assertTrue(monitorModes.size()>0); if(monitorModes.size()==1) { @@ -178,7 +184,7 @@ public class TestScreenMode01bNEWT extends UITestCase { return; } Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); - + MonitorMode mmCurrent = monitor.getCurrentMode(); Assert.assertNotNull(mmCurrent); MonitorMode mmOrig = monitor.getOriginalMode(); @@ -199,7 +205,7 @@ public class TestScreenMode01bNEWT extends UITestCase { 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); @@ -218,10 +224,14 @@ public class TestScreenMode01bNEWT extends UITestCase { Assert.assertTrue(smOk); } - System.err.println("Test.1: Window screen: "+screen); - System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport()); - System.err.println("Test.1: Window monitor: "+window0.getMainMonitor()); - + window0ScreenRect = window0.getSurfaceBounds(); + System.err.println("Test.1: Screen : "+screen); + System.err.println("Test.1: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]"); + System.err.println("Test.1: Window screenRect: "+window0ScreenRect+" [pixels]"); + System.err.println("Test.1: Screen viewport : "+screen.getViewport()+" [pixels]"); + System.err.println("Test.1: Window monitor : "+monitor.getViewport()+" [pixels]"); + System.err.println("Test.1: Window main-mon : "+window0.getMainMonitor()); + Thread.sleep(duration); Assert.assertEquals(true,display.isNativeValid()); @@ -238,12 +248,15 @@ public class TestScreenMode01bNEWT extends UITestCase { Assert.assertFalse(monitor.isModeChangedByUs()); Assert.assertEquals(mmOrig, mmCurrent); Assert.assertTrue(smOk); - } - - System.err.println("Test.2: Window screen: "+screen); - System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport()); - System.err.println("Test.2: Window monitor: "+window0.getMainMonitor()); - + } + + System.err.println("Test.2: Screen : "+screen); + System.err.println("Test.2: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]"); + System.err.println("Test.2: Window screenRect: "+window0ScreenRect+" [pixels]"); + System.err.println("Test.2: Screen viewport : "+screen.getViewport()+" [pixels]"); + System.err.println("Test.2: Window monitor : "+monitor.getViewport()+" [pixels]"); + System.err.println("Test.2: Window main-mon : "+window0.getMainMonitor()); + Thread.sleep(duration); anim.stop(); destroyWindow(window0); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java index b4257e070..b48d582ed 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java @@ -3,14 +3,14 @@ * * 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 @@ -20,15 +20,16 @@ * 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; @@ -54,6 +55,7 @@ import com.jogamp.opengl.util.Animator; import java.util.ArrayList; import java.util.List; + import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; @@ -64,7 +66,7 @@ import javax.media.nativewindow.util.RectangleImmutable; public class TestScreenMode01cNEWT extends UITestCase { static GLProfile glp; static int width, height; - + static long waitTimeShort = 2000; static long duration = 4000; @@ -80,14 +82,15 @@ public class TestScreenMode01cNEWT extends UITestCase { 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) throws InterruptedException { + + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int screenXPos, int screenYPos, int width, int height) throws InterruptedException { Assert.assertNotNull(caps); GLWindow window = GLWindow.create(screen, caps); // Window window = NewtFactory.createWindow(screen, caps); + final int[] winPos = window.convertToWindowUnits(new int[] { screenXPos, screenYPos }); window.setTitle(name); - window.setPosition(x, y); + window.setPosition(winPos[0], winPos[1]); window.setSize(width, height); window.addGLEventListener(new GearsES2()); Assert.assertNotNull(window); @@ -100,10 +103,10 @@ public class TestScreenMode01cNEWT extends UITestCase { static void destroyWindow(Window window) throws InterruptedException { if(null!=window) { window.destroy(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); } } - + @Test public void testScreenFullscreenSingleQ1() throws InterruptedException { final Display display = NewtFactory.createDisplay(null); // local display @@ -116,17 +119,17 @@ public class TestScreenMode01cNEWT extends UITestCase { testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null); } finally { screen.removeReference(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); } } - + @Test public void testScreenFullscreenSingleQ2() throws InterruptedException { final Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 Assert.assertNotNull(screen); - screen.addReference(); // trigger creation + screen.addReference(); // trigger creation try { if( 2 > screen.getMonitorDevices().size() ) { System.err.println("Test Disabled (1): Monitor count < 2: "+screen); @@ -136,23 +139,23 @@ public class TestScreenMode01cNEWT extends UITestCase { testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null); } finally { screen.removeReference(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); } } - + @Test public void testScreenFullscreenSpanQ1Q2() throws InterruptedException { final Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 Assert.assertNotNull(screen); - screen.addReference(); // trigger creation + screen.addReference(); // trigger creation try { final int crtCount = screen.getMonitorDevices().size(); if( 2 >= crtCount ) { System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen); - return; - } + return; + } final ArrayList<MonitorDevice> monitors = new ArrayList<MonitorDevice>(); monitors.add(screen.getMonitorDevices().get(0)); // Q1 monitors.add(screen.getMonitorDevices().get(1)); // Q2 @@ -160,17 +163,17 @@ public class TestScreenMode01cNEWT extends UITestCase { testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors); } finally { screen.removeReference(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); } } - + @Test public void testScreenFullscreenSpanALL() throws InterruptedException { final Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 Assert.assertNotNull(screen); - screen.addReference(); // trigger creation + screen.addReference(); // trigger creation try { if( 2 > screen.getMonitorDevices().size() ) { System.err.println("Test Disabled (3): Monitor count < 2: "+screen); @@ -180,28 +183,32 @@ public class TestScreenMode01cNEWT extends UITestCase { testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null); } finally { screen.removeReference(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); } } - - void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List<MonitorDevice> monitors) throws InterruptedException { + + void testScreenFullscreenImpl(final Screen screen, final int screenXPos, final int screenYPos, + final boolean spanAcrossMonitors, final List<MonitorDevice> monitors) throws InterruptedException { Thread.sleep(waitTimeShort); final GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); final Display display = screen.getDisplay(); - + System.err.println("Test.0: Window screen: "+screen); - - System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); - - GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); - Assert.assertNotNull(window0); - System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport()); + + System.err.println("Test.0: Window bounds (pre): screenPos "+screenXPos+"/"+screenYPos+" [pixels], windowSize "+width+"x"+height+" [wu] within "+screen.getViewport()+" [pixels]"); + + GLWindow window0 = createWindow(screen, caps, "win0", screenXPos, screenYPos, width, height); + Assert.assertNotNull(window0); + Rectangle window0ScreenRect = window0.getSurfaceBounds(); + System.err.println("Test.0: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]"); + System.err.println("Test.0: Window screenRect: "+window0ScreenRect+" [pixels]"); + System.err.println("Test.0: Screen viewport : "+screen.getViewport()+" [pixels]"); final Animator anim = new Animator(window0); anim.start(); - + List<MonitorMode> allMonitorModes = screen.getMonitorModes(); Assert.assertTrue(allMonitorModes.size()>0); @@ -214,29 +221,33 @@ public class TestScreenMode01cNEWT extends UITestCase { } monitor = window0.getMainMonitor(); - System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport()); - System.err.println("Test.1: Window monitor: "+monitor.getViewport()); - Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getSurfaceWidth(), window0.getSurfaceHeight()); + window0ScreenRect = window0.getSurfaceBounds(); + System.err.println("Test.1: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]"); + System.err.println("Test.1: Window screenRect: "+window0ScreenRect+" [pixels]"); + System.err.println("Test.1: Screen viewport : "+screen.getViewport()+" [pixels]"); + System.err.println("Test.1: Window monitor : "+monitor.getViewport()+" [pixels]"); if( !spanAcrossMonitors ) { - Assert.assertEquals(monitor.getViewport(), window0Rect); + Assert.assertEquals(monitor.getViewport(), window0ScreenRect); } else { List<MonitorDevice> monitorsUsed = monitors; if( null == monitorsUsed ) { monitorsUsed = window0.getScreen().getMonitorDevices(); } Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed); - Assert.assertEquals(monitorsUsedViewport, window0Rect); + Assert.assertEquals(monitorsUsedViewport, window0ScreenRect); } - + Thread.sleep(duration); window0.setFullscreen(false); - - window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getSurfaceWidth(), window0.getSurfaceHeight()); + + window0ScreenRect = window0.getSurfaceBounds(); monitor = window0.getMainMonitor(); - System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport()); - System.err.println("Test.2: Window monitor: "+monitor.getViewport()); - + System.err.println("Test.2: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]"); + System.err.println("Test.2: Window screenRect: "+window0ScreenRect+" [pixels]"); + System.err.println("Test.2: Screen viewport : "+screen.getViewport()+" [pixels]"); + System.err.println("Test.2: Window monitor : "+monitor.getViewport()+" [pixels]"); + Thread.sleep(duration); anim.stop(); destroyWindow(window0); 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 4b16a006f..d9ea39365 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 @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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; @@ -66,13 +66,13 @@ import javax.media.nativewindow.util.RectangleImmutable; * i.e. the original MonitorMode should get reinstated! * </p> * <p> - * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.</p> + * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.</p> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestScreenMode01dNEWT extends UITestCase { static GLProfile glp; static int width, height; - + static int waitTimeShort = 2000; // 2 sec static int waitTimeLong = 8000; // 8 sec @@ -88,13 +88,13 @@ public class TestScreenMode01dNEWT extends UITestCase { public static void releaseClass() throws InterruptedException { Thread.sleep(waitTimeShort); } - + /** * Following configurations results in a SIGSEGV: * <pre> * Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03] * </pre> - * + * * Situation: * <pre> * 1 - Create Screen, GLWindow (w/ context) @@ -102,19 +102,19 @@ public class TestScreenMode01dNEWT extends UITestCase { * 3 - Destroy GLWindow (w/ context), Screen * 4 - Create Screen, GLWindow (w/ context) (*) * </pre> - * + * * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call * on the the created GL context. - * + * * Remedy: * <pre> * A) Releasing all resources before step 4 .. works. * B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()). * </pre> - * + * * Hence there must be some correlations with the screen randr mode * and some of the glcontext/gldrawables. - * + * * <pre> * Remedy A) is demonstrated here * Remedy B) is shown in {@link TestScreenMode01bNEWT} @@ -127,7 +127,7 @@ public class TestScreenMode01dNEWT extends UITestCase { 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); @@ -143,10 +143,10 @@ public class TestScreenMode01dNEWT extends UITestCase { static void destroyWindow(Window window) throws InterruptedException { if(null!=window) { window.destroy(); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); } } - + @Test public void test01FullscreenChange01() throws InterruptedException { Thread.sleep(waitTimeShort); @@ -160,40 +160,40 @@ public class TestScreenMode01dNEWT extends UITestCase { 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.getSurfaceWidth()); Assert.assertEquals(height, window.getSurfaceHeight()); - + window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); + Assert.assertEquals(true, window.isFullscreen()); Assert.assertEquals(monitor.getViewport().getWidth(), window.getSurfaceWidth()); Assert.assertEquals(monitor.getViewport().getHeight(), window.getSurfaceHeight()); - + Thread.sleep(waitTimeShort); window.setFullscreen(false); Assert.assertEquals(false, window.isFullscreen()); Assert.assertEquals(width, window.getSurfaceWidth()); Assert.assertEquals(height, window.getSurfaceHeight()); - + Thread.sleep(waitTimeShort); animator.stop(); Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(false, animator.isStarted()); - + destroyWindow(window); - + 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()); - + cleanupGL(); } @@ -210,9 +210,9 @@ public class TestScreenMode01dNEWT extends UITestCase { GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); Assert.assertNotNull(window); - final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getSurfaceWidth(), window.getSurfaceHeight()); - final MonitorDevice monitor = screen.getMainMonitor(winRect); - + final RectangleImmutable screenRect = window.getSurfaceBounds(); + final MonitorDevice monitor = screen.getMainMonitor( screenRect ); + List<MonitorMode> monitorModes = monitor.getSupportedModes(); Assert.assertTrue(monitorModes.size()>0); if(monitorModes.size()==1) { @@ -245,14 +245,14 @@ public class TestScreenMode01dNEWT extends UITestCase { 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); // set mode { - MonitorMode sm = (MonitorMode) monitorModes.get(0); + MonitorMode sm = monitorModes.get(0); System.err.println("[0] set current: "+sm); final boolean smOk = monitor.setCurrentMode(sm); mmCurrent = monitor.getCurrentMode(); @@ -263,7 +263,7 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); Assert.assertTrue(smOk); } - + Thread.sleep(waitTimeLong); Assert.assertEquals(true,display.isNativeValid()); @@ -271,10 +271,10 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - animator.stop(); + animator.stop(); Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(false, animator.isStarted()); - + destroyWindow(window); Assert.assertEquals(false,window.isVisible()); @@ -284,7 +284,7 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - validateScreenModeReset(mmOrig, winRect); + validateScreenModeReset(mmOrig, screenRect); cleanupGL(); } @@ -308,8 +308,8 @@ public class TestScreenMode01dNEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); - final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getSurfaceWidth(), window.getSurfaceHeight()); - final MonitorDevice monitor = screen.getMainMonitor(winRect); + final RectangleImmutable screenRect = window.getSurfaceBounds(); + final MonitorDevice monitor = screen.getMainMonitor(screenRect); MonitorMode mmCurrent = monitor.queryCurrentMode(); Assert.assertNotNull(mmCurrent); MonitorMode mmOrig = monitor.getOriginalMode(); @@ -317,7 +317,7 @@ public class TestScreenMode01dNEWT extends UITestCase { System.err.println("[0] orig : "+mmOrig); System.err.println("[0] current: "+mmCurrent); Assert.assertEquals(mmCurrent, mmOrig); - + List<MonitorMode> monitorModes = monitor.getSupportedModes(); if(monitorModes.size()==1) { // no support .. @@ -331,9 +331,9 @@ public class TestScreenMode01dNEWT extends UITestCase { monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); + MonitorMode monitorMode = monitorModes.get(0); Assert.assertNotNull(monitorMode); - + if(preFS) { System.err.println("[0] set FS pre 0: "+window.isFullscreen()); window.setFullscreen(true); @@ -342,7 +342,7 @@ public class TestScreenMode01dNEWT extends UITestCase { System.err.println("[0] set FS pre X: "+window.isFullscreen()); } Thread.sleep(waitTimeShort); - + // set mode { System.err.println("[0] set current: "+monitorMode); @@ -355,7 +355,7 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); Assert.assertTrue(smOk); } - + if(!preFS) { System.err.println("[0] set FS post 0: "+window.isFullscreen()); window.setFullscreen(true); @@ -364,7 +364,7 @@ public class TestScreenMode01dNEWT extends UITestCase { } Thread.sleep(waitTimeLong); - + if(!preFS) { System.err.println("[0] set !FS post 0: "+window.isFullscreen()); window.setFullscreen(false); @@ -372,7 +372,7 @@ public class TestScreenMode01dNEWT extends UITestCase { 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()); @@ -381,7 +381,7 @@ public class TestScreenMode01dNEWT extends UITestCase { animator.stop(); Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(false, animator.isStarted()); - + destroyWindow(window); Assert.assertEquals(false,window.isVisible()); @@ -391,7 +391,7 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - validateScreenModeReset(mmOrig, winRect); + validateScreenModeReset(mmOrig, screenRect); cleanupGL(); } @@ -405,15 +405,15 @@ public class TestScreenMode01dNEWT extends UITestCase { screen.addReference(); Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - + final MonitorDevice monitor = screen.getMainMonitor(rect); Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - + 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); |