diff options
author | Sven Gothel <[email protected]> | 2023-01-16 20:34:56 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-01-16 20:34:56 +0100 |
commit | 5fe510b9be98b8490b6ffb4e0ca0a76115f429ab (patch) | |
tree | 298f676277480285b151847564c4c4b88a1f18df | |
parent | 8eb84e8234bc85f2cf096a1e24523660441d0b73 (diff) |
SWTTestUtil: Add WaitAction2, using the EDTUtil to dispatch the display.readAndDispatch() wait action (experimental)
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 2 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/util/SWTTestUtil.java | 47 |
2 files changed, 43 insertions, 6 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java index ab4f2419f..51aa4c138 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java @@ -192,6 +192,8 @@ public class TestNewtCanvasSWTGLn extends UITestCase { } } ); } + // final SWTTestUtil.WaitAction2 awtRobotWaitAction = new SWTTestUtil.WaitAction2(glWindow1.getScreen().getDisplay().getEDTUtil(), display, true, TestUtil.TIME_SLICE); + // final SWTTestUtil.WaitAction2 generalWaitAction = new SWTTestUtil.WaitAction2(glWindow1.getScreen().getDisplay().getEDTUtil(), display, true, 10); final SWTTestUtil.WaitAction awtRobotWaitAction = new SWTTestUtil.WaitAction(display, true, TestUtil.TIME_SLICE); final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(display, true, 10); diff --git a/src/test/com/jogamp/opengl/test/junit/util/SWTTestUtil.java b/src/test/com/jogamp/opengl/test/junit/util/SWTTestUtil.java index 8b359df3b..5e80bacaa 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/SWTTestUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/SWTTestUtil.java @@ -31,17 +31,22 @@ package com.jogamp.opengl.test.junit.util; import org.eclipse.swt.widgets.Display; +import com.jogamp.newt.util.EDTUtil; + public class SWTTestUtil { public static class WaitAction implements Runnable { final Display display; final boolean blocking; final long sleepMS; + public WaitAction(final Display display, final boolean blocking, final long sleepMS) { this.display = display; this.blocking = blocking; this.sleepMS = sleepMS; } + final Runnable waitAction0 = new Runnable() { + @Override public void run() { if( !display.readAndDispatch() ) { try { @@ -49,15 +54,45 @@ public class SWTTestUtil { } catch (final InterruptedException e) { } } } }; + + @Override + public void run() { + if( blocking ) { + display.syncExec( waitAction0 ); + } else { + display.asyncExec( waitAction0 ); + } + }; + } + + public static class WaitAction2 implements Runnable { + final EDTUtil edt; + final Display display; + final boolean blocking; + final long sleepMS; + + public WaitAction2(final EDTUtil edt, final Display display, final boolean blocking, final long sleepMS) { + this.edt = edt; + this.display = display; + this.blocking = blocking; + this.sleepMS = sleepMS; + } + + final Runnable waitAction0 = new Runnable() { + @Override public void run() { - if( blocking ) { - display.syncExec( waitAction0 ); - } else { - display.asyncExec( waitAction0 ); + if( !display.readAndDispatch() ) { + try { + Thread.sleep(sleepMS); + } catch (final InterruptedException e) { } } - }; - } + } }; + @Override + public void run() { + edt.invoke(blocking, waitAction0); + }; + } } |