aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-13 17:04:17 +0200
committerSven Gothel <[email protected]>2011-10-13 17:04:17 +0200
commitd186f6e945fd157b219231fb3861b3b0ce10ee75 (patch)
treeb3851f97222cf224251956cb8ad06508c7a9d090 /src/test/com
parent3fd89ccc138eddb915372cff4843f69f764048a7 (diff)
OSX/SWT: Adding OSXUtil: RunOnMainThread(), IsMainThread() / Utilizing those for SWT access/calls
Adding OSXUtil: RunOnMainThread(), IsMainThread() - Issuing a native call where the user Runnable is to be performed on the main thread - Enable query if we are on the main thread. Utilizing those for SWT access/calls - Using the above to call all SWT functions on the main thread if required (incomplete) TODO/Issues: - JOGL OSX CGL Context fails, ie expecting NS, but having CGL
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
index 1ee374895..3e153214b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
@@ -38,6 +38,7 @@ import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
@@ -83,14 +84,26 @@ public class TestSWT02GLn extends UITestCase {
@Before
public void init() {
- display = new Display();
- Assert.assertNotNull( display );
- shell = new Shell( display );
+ final Display[] r = new Display[1];
+ final Shell[] s = new Shell[1];
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ r[0] = new Display();
+ s[0] = new Shell();
+ }
+ });
+ display = r[0];
+ shell = s[0];
+ Assert.assertNotNull( display );
Assert.assertNotNull( shell );
- shell.setLayout( new FillLayout() );
- composite = new Composite( shell, SWT.NONE );
- composite.setLayout( new FillLayout() );
- Assert.assertNotNull( composite );
+
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ shell.setLayout( new FillLayout() );
+ composite = new Composite( shell, SWT.NONE );
+ Assert.assertNotNull( composite );
+ composite.setLayout( new FillLayout() );
+ }});
}
@After
@@ -99,9 +112,12 @@ public class TestSWT02GLn extends UITestCase {
Assert.assertNotNull( shell );
Assert.assertNotNull( composite );
try {
- composite.dispose();
- shell.dispose();
- display.dispose();
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ composite.dispose();
+ shell.dispose();
+ display.dispose();
+ }});
}
catch( Throwable throwable ) {
throwable.printStackTrace();
@@ -111,14 +127,25 @@ public class TestSWT02GLn extends UITestCase {
shell = null;
composite = null;
}
-
+
+ class CanvasCStr implements Runnable {
+ Canvas canvas;
+
+ public void run() {
+ canvas = new Canvas( composite, SWT.NO_BACKGROUND);
+ }
+ }
+
protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
GLCapabilities caps = new GLCapabilities(glprofile);
GLDrawableFactory factory = GLDrawableFactory.getFactory(glprofile);
// need SWT.NO_BACKGROUND to prevent SWT from clearing the window
// at the wrong times (we use glClear for this instead)
- final Canvas canvas = new Canvas( composite, SWT.NO_BACKGROUND);
+ CanvasCStr canvasCstr = new CanvasCStr();
+
+ SWTAccessor.invoke(true, canvasCstr);
+ final Canvas canvas = canvasCstr.canvas;
Assert.assertNotNull( canvas );
SWTAccessor.setRealized(canvas, true);