diff options
author | Sven Gothel <[email protected]> | 2020-01-13 13:51:13 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-01-13 13:51:13 +0100 |
commit | a1d9e3d0deaa06a417efac9fcd223db35ec6d255 (patch) | |
tree | 1740af139f306e2ad8c10b61eeb5f298ecc05a1c | |
parent | 17ced028996740af751542ddcd78d2e81d0fbbcf (diff) |
TestSWTAccessor02NewtGLWindow: Setup SWT EDTUtil for NEWT, avoiding deadlocks on OSX and Windows
Essentially same code path as NewtCanvasSWT
-rwxr-xr-x | make/scripts/tests-win.bat | 3 | ||||
-rw-r--r-- | make/scripts/tests.sh | 11 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java | 68 |
3 files changed, 37 insertions, 45 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 42808b44c..2036ead2c 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -160,10 +160,11 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02NewtGLWindow %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestGLCanvasSWTNewtCanvasSWTPosInTabs %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestGLCanvasSWTNewtCanvasSWTPosInTabs %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index abbec8e31..224992c6c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -156,7 +156,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.SWT" - D_ARGS="-Dnativewindow.debug.SWT -Dnewt.debug.Window -Djogl.debug.GLCanvas" + D_ARGS="-Dnativewindow.debug.SWT -Dnewt.debug.Window -Djogl.debug.GLCanvas -Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnativewindow.debug.SWT -Dnativewindow.debug.X11Util -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" @@ -492,6 +492,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $* #testawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtCanvasAWTDemo $* #testawt com.jogamp.opengl.test.junit.jogl.awt.ManualHiDPIBufferedImage01AWT $* +#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* +#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* # # demos (any TK, more user driven tests) @@ -507,13 +509,10 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* -#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawtatomics com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* -#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* -#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* @@ -791,12 +790,12 @@ 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.swt.TestSWTJOGLGLCanvas01GLn $* #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.TestGLCanvasSWTNewtCanvasSWTPosInTabs $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestGLCanvasSWTNewtCanvasSWTPosInTabs $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java index 6694df65a..787858175 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java @@ -31,8 +31,6 @@ package com.jogamp.opengl.test.junit.jogl.swt; import java.lang.reflect.InvocationTargetException; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; @@ -46,7 +44,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.junit.Assert; -import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.junit.FixMethodOrder; @@ -60,13 +57,18 @@ import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.swt.NewtCanvasSWT; +import com.jogamp.newt.util.EDTUtil; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +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 jogamp.newt.swt.SWTEDTUtil; + /** * Tests utilizing {@link SWTAccessor#getWindowHandle(org.eclipse.swt.widgets.Control)} * for NEWT native window reparenting also using GL rendering {@link GLWindow#reparentWindow(NativeWindow, int, int, int)}. @@ -89,17 +91,6 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase { Shell shell = null; Composite composite = null; - @BeforeClass - public static void startup() { - if( Platform.getOSType() == Platform.OSType.MACOS ) { - // NSLocking issues on OSX and AWT, able to freeze whole test suite! - // Since this test is merely a technical nature to validate the accessor w/ SWT - // we can drop it w/o bothering. - JunitTracer.setTestSupported(false); - return; - } - } - protected void init() throws InterruptedException, InvocationTargetException { System.err.println("SWT Platform: "+SWT.getPlatform()+", Version "+SWT.getVersion()); System.err.println("GTK_VERSION: "+SWTAccessor.GTK_VERSION()); @@ -155,10 +146,17 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase { glwin.addGLEventListener(demo); glwin.setSize(600, 600); + // set SWT EDT and start it + { + final com.jogamp.newt.Display newtDisplay = glwin.getScreen().getDisplay(); + final EDTUtil edtUtil = new SWTEDTUtil(newtDisplay, display); + edtUtil.start(); + newtDisplay.setEDTUtil( edtUtil ); + } final Canvas canvas[] = { null }; try { - SWTAccessor.invoke(true, new Runnable() { - public void run() { + display.syncExec( new Runnable() { + public void run() { canvas[0] = new Canvas (composite, SWT.NO_BACKGROUND); // Bug 1362 fix or workaround: Seems SWT/GTK3 at least performs lazy initialization // Minimal action required: setBackground of the parent canvas before reparenting! @@ -202,38 +200,32 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase { canvas[0].addListener (SWT.Paint, listener); canvas[0].addListener (SWT.Dispose, listener); - final NativeWindow parentWindow = NativeWindowFactory.createWrappedWindow(aScreen, 0 /* surfaceHandle*/, parentWinHandle, upstreamSizePosHook); - glwin.reparentWindow(parentWindow, 0, 0, 0); final Rectangle r = canvas[0].getClientArea(); + final NativeWindow parentWindow = NativeWindowFactory.createWrappedWindow(aScreen, 0 /* surfaceHandle*/, parentWinHandle, upstreamSizePosHook); glwin.setSize(r.width, r.height); + glwin.reparentWindow(parentWindow, 0, 0, 0); + glwin.setPosition(r.x, r.y); glwin.setVisible(true); canvas[0].redraw(); }}); + final Runnable waitAction = new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + try { + Thread.sleep(10); + } catch (final InterruptedException e) { } + } + } }; + Assert.assertEquals(true, NewtTestUtil.waitForVisible(glwin, true, waitAction)); + Assert.assertEquals(true, GLTestUtil.waitForRealized(glwin, true, waitAction)); + System.err.println("Window handle.1 0x"+Long.toHexString(SWTAccessor.getWindowHandle(canvas[0]))); final long lStartTime = System.currentTimeMillis(); final long lEndTime = lStartTime + duration; - try { - while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - try { - Thread.sleep(10); - } catch (final InterruptedException e) { } - } - }}); - } - SWTAccessor.invoke(true, new Runnable() { - public void run() { - System.err.println("Window handle.X 0x"+Long.toHexString(SWTAccessor.getWindowHandle(canvas[0]))); - }}); - } - catch( final Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); + while( System.currentTimeMillis() < lEndTime && !composite.isDisposed() ) { + waitAction.run(); } } finally { release(glwin); |