diff options
5 files changed, 82 insertions, 39 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7088f98d9..e1211d051 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -758,15 +758,15 @@ function testawtswt() { # SWT (testswt) # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor01 $* -testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02NewtGLWindow $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02NewtGLWindow $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* -#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite $* -#testswt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* +testswt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* # # awtswt (testawtswt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java index 248551118..4e2457181 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java @@ -39,6 +39,7 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.util.GLTestUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.NewtTestUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -200,17 +201,27 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { shell2.open(); // shall wait until f1 is ready shell3.open(); // shall wait until f1 is ready } } ); + final long t0 = System.currentTimeMillis(); animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion - Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) - - Assert.assertTrue(GLTestUtil.waitForContextCreated(c1, true)); + final Runnable waitAction = new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + try { + Thread.sleep(10); + } catch (final InterruptedException e) { } + } + } }; + Assert.assertEquals(true, GLTestUtil.waitForRealized(c1, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c1, true, waitAction)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); - Assert.assertTrue(GLTestUtil.waitForContextCreated(c2, true)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(c2, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c2, true, waitAction)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); - Assert.assertTrue(GLTestUtil.waitForContextCreated(c3, true)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(c3, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c3, true, waitAction)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -236,11 +247,10 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); - try { - Thread.sleep(duration); - } catch(final Exception e) { - e.printStackTrace(); + while(animator.isAnimating() && System.currentTimeMillis()-t0<duration) { + waitAction.run(); } + // Stopped animator allows native windowing system 'repaint' event // to trigger GLAD 'display' animator.stop(); @@ -266,10 +276,16 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } } ); a1.start(); - - Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) - - Assert.assertTrue(GLTestUtil.waitForContextCreated(c1, true)); + final Runnable waitAction = new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + try { + Thread.sleep(10); + } catch (final InterruptedException e) { } + } + } }; + Assert.assertEquals(true, GLTestUtil.waitForRealized(c1, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c1, true, waitAction)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); final Animator a2 = new Animator(); @@ -284,8 +300,6 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } } ); a2.start(); - Thread.sleep(200); // wait a while .. - final Animator a3 = new Animator(); final GearsES2 g3 = new GearsES2(0); g3.setSharedGears(g1); @@ -298,12 +312,16 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } } ); a3.start(); - Assert.assertTrue(GLTestUtil.waitForContextCreated(c2, true)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(c2, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c2, true, waitAction)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); - Assert.assertTrue(GLTestUtil.waitForContextCreated(c3, true)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(c3, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c3, true, waitAction)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + final long t0 = System.currentTimeMillis(); + final GLContext ctx1 = c1.getContext(); final GLContext ctx2 = c2.getContext(); final GLContext ctx3 = c3.getContext(); @@ -327,10 +345,8 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); - try { - Thread.sleep(duration); - } catch(final Exception e) { - e.printStackTrace(); + while(System.currentTimeMillis()-t0<duration) { + waitAction.run(); } // Stopped animator allows native windowing system 'repaint' event // to trigger GLAD 'display' diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java index ee72e1e6f..7eb57c436 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java @@ -41,7 +41,9 @@ import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.swt.NewtCanvasSWT; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.GLTestUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.NewtTestUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; @@ -217,16 +219,24 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + final Runnable waitAction = new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + try { + Thread.sleep(10); + } catch (final InterruptedException e) { } + } + } }; + Assert.assertEquals(true, NewtTestUtil.waitForVisible(glWindow, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(glWindow, true, waitAction)); + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets()); if( null != rwsize ) { for(int i=0; i<50; i++) { // 500 ms dispatched delay - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + waitAction.run(); } display.syncExec( new Runnable() { public void run() { @@ -237,10 +247,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { } while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + waitAction.run(); } Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); @@ -251,7 +258,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { canvas1.dispose(); glWindow.destroy(); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false, null)); } @Test diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java index c05444b02..f76081754 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java @@ -33,7 +33,9 @@ import java.lang.reflect.InvocationTargetException; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.opengl.swt.GLCanvas; +import com.jogamp.opengl.test.junit.util.GLTestUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.NewtTestUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.AnimatorBase; @@ -171,11 +173,18 @@ public class TestGearsES2SWT extends UITestCase { animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + final Runnable waitAction = new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + try { + Thread.sleep(10); + } catch (final InterruptedException e) { } + } + } }; + Assert.assertEquals(true, GLTestUtil.waitForRealized(canvas, true, waitAction)); + while(animator.isAnimating() && !canvas.isRealized() && animator.getTotalFPSDuration()<duration) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + waitAction.run(); } System.err.println("NW chosen: "+canvas.getDelegatedDrawable().getChosenGLCapabilities()); System.err.println("GL chosen: "+canvas.getChosenGLCapabilities()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java index da33392e3..89df0b1fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java @@ -40,7 +40,9 @@ import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.swt.NewtCanvasSWT; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.GLTestUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.NewtTestUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; @@ -228,7 +230,16 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { shell.open(); } }); - Assert.assertTrue("GLWindow didn't become visible natively!", AWTRobotUtil.waitForRealized(glWindow, true, awtRobotWaitAction)); + final Runnable waitAction = new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + try { + Thread.sleep(10); + } catch (final InterruptedException e) { } + } + } }; + Assert.assertEquals(true, NewtTestUtil.waitForVisible(glWindow, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(glWindow, true, waitAction)); Assert.assertNotNull( canvas1.getNativeWindow() ); System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); @@ -272,7 +283,7 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { canvas1.dispose(); glWindow.destroy(); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false, null)); + Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow, false, waitAction)); } @Test |