summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java272
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java38
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor01.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java119
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java40
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java38
15 files changed, 361 insertions, 348 deletions
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 332d799b2..ba1486010 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
@@ -40,6 +40,7 @@ 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.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -102,7 +103,7 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -145,7 +146,7 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
composite1.dispose();
shell1.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -206,14 +207,7 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
final long t0 = System.currentTimeMillis();
animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
- final Runnable waitAction = new Runnable() {
- public void run() {
- if( !display.readAndDispatch() ) {
- try {
- Thread.sleep(200);
- } catch (final InterruptedException e) { }
- }
- } };
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 200);
Assert.assertEquals(true, GLTestUtil.waitForRealized(c1, true, waitAction));
Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c1, true, waitAction));
Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
@@ -281,14 +275,7 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
} } );
a1.start();
- final Runnable waitAction = new Runnable() {
- public void run() {
- if( !display.readAndDispatch() ) {
- try {
- Thread.sleep(200);
- } catch (final InterruptedException e) { }
- }
- } };
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 200);
Assert.assertEquals(true, GLTestUtil.waitForRealized(c1, true, waitAction));
Assert.assertEquals(true, GLTestUtil.waitForContextCreated(c1, true, waitAction));
Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
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 0cc06160a..67d180fb8 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
@@ -31,6 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import com.jogamp.nativewindow.NativeWindowFactory;
import com.jogamp.nativewindow.swt.SWTAccessor;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.event.KeyAdapter;
@@ -45,8 +46,12 @@ 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.test.junit.util.SWTTestUtil;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.AnimatorBase;
+
+import jogamp.newt.DisplayImpl;
+
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.nativewindow.util.Dimension;
@@ -109,7 +114,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -137,7 +142,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
composite.dispose();
shell.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -152,7 +157,29 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
composite = null;
}
+ private String isOSXMainThread() {
+ if( NativeWindowFactory.getNativeWindowType(true) == NativeWindowFactory.TYPE_MACOSX ) {
+ return ", isOSX-Main-Thread: " + jogamp.nativewindow.macosx.OSXUtil.IsMainThread();
+ } else {
+ return "";
+ }
+ }
protected void runTestGL(final GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException {
+ System.err.println("CCC00: Run Thread: "+Thread.currentThread()+isOSXMainThread());
+ display.syncExec( new Runnable() {
+ public void run() {
+ System.err.println("CCC01: SWT Thread: "+Thread.currentThread()+isOSXMainThread());
+ }
+ });
+ {
+ final DisplayImpl d = (DisplayImpl)NewtFactory.createDisplay(null);
+ d.runOnEDTIfAvail(true, new Runnable() {
+ public void run() {
+ System.err.println("CCC02: NEWT EDT Thread: "+Thread.currentThread()+isOSXMainThread());
+ }
+ });
+ }
+
System.err.println("requested: vsync "+swapInterval+", "+caps);
final com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, screenIdx);
final GLWindow glWindow = GLWindow.create(screen, caps);
@@ -223,14 +250,7 @@ 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) { }
- }
- } };
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 10);
Assert.assertEquals(true, NewtTestUtil.waitForVisible(glWindow, true, waitAction));
Assert.assertEquals(true, GLTestUtil.waitForRealized(glWindow, true, waitAction));
@@ -260,7 +280,11 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase {
Assert.assertFalse(animator.isStarted());
Assert.assertEquals(null, glWindow.getExclusiveContextThread());
- canvas1.dispose();
+ display.syncExec( new Runnable() {
+ public void run() {
+ canvas1.dispose();
+ }
+ });
glWindow.destroy();
Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow, false, null));
}
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 f76081754..9ca6577b0 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
@@ -36,6 +36,7 @@ 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.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.AnimatorBase;
@@ -100,7 +101,7 @@ public class TestGearsES2SWT extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -127,7 +128,7 @@ public class TestGearsES2SWT extends UITestCase {
composite.dispose();
shell.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -173,14 +174,8 @@ 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) { }
- }
- } };
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 16);
+
Assert.assertEquals(true, GLTestUtil.waitForRealized(canvas, true, waitAction));
while(animator.isAnimating() && !canvas.isRealized() && animator.getTotalFPSDuration()<duration) {
@@ -188,14 +183,14 @@ public class TestGearsES2SWT extends UITestCase {
}
System.err.println("NW chosen: "+canvas.getDelegatedDrawable().getChosenGLCapabilities());
System.err.println("GL chosen: "+canvas.getChosenGLCapabilities());
- System.err.println("window pos/siz: "+canvas.getLocation()+" "+canvas.getSurfaceWidth()+"x"+canvas.getSurfaceHeight());
+ display.syncExec(new Runnable() {
+ public void run() {
+ System.err.println("window pos/siz: "+canvas.getLocation()+" "+canvas.getSurfaceWidth()+"x"+canvas.getSurfaceHeight());
+ } } );
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() {
@@ -206,10 +201,7 @@ public class TestGearsES2SWT extends UITestCase {
}
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
+ waitAction.run();
}
Assert.assertEquals(exclusiveContext ? animator.getThread() : null, canvas.getExclusiveContextThread());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java
index 86e0f9d9b..78bc99dd1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java
@@ -40,6 +40,8 @@ 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.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
+import com.jogamp.opengl.test.junit.util.TestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import java.io.IOException;
@@ -111,7 +113,9 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
CTabFolder tabFolder = null;
CTabItem tabItem1 = null;
CTabItem tabItem2 = null;
+ Composite tab1Comp = null;
SashForm sash = null;
+ Composite sashRight = null;
static PointImmutable wpos = null;
static DimensionImmutable wsize = new Dimension(640, 480), rwsize = null;
@@ -130,6 +134,9 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
if( null != sash ) {
sash.dispose();
}
+ if( null != tab1Comp ) {
+ tab1Comp.dispose();
+ }
if( null != tabFolder ) {
tabFolder.dispose();
}
@@ -141,7 +148,7 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
}
}});
}
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
if( null != display ) {
display.dispose();
@@ -158,59 +165,53 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
tabFolder = null;
tabItem1 = null;
tabItem2 = null;
+ tab1Comp = null;
sash = null;
+ sashRight = null;
}
- class WaitAction implements Runnable {
- private final long sleepMS;
-
- WaitAction(final long sleepMS) {
- this.sleepMS = sleepMS;
- }
- public void run() {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- try {
- Thread.sleep(sleepMS);
- } catch (final InterruptedException e) { }
- }
- }
- }
- final WaitAction waitAction = new WaitAction(AWTRobotUtil.TIME_SLICE);
- final WaitAction generalWaitAction = new WaitAction(10);
-
protected void runTestInLayout(final boolean focusOnTab1, final boolean useNewtCanvasSWT, final boolean addComposite, final GLCapabilitiesImmutable caps)
throws InterruptedException
{
- display = new Display();
- Assert.assertNotNull( display );
- SWTAccessor.printInfo(System.err, display);
-
- shell = new Shell( display );
- shell.setText( getSimpleTestName(".") );
- shell.setLayout(new FillLayout());
- shell.setSize( wsize.getWidth(), wsize.getHeight() );
- if( null != wpos ) {
- shell.setLocation(wpos.getX(), wpos.getY());
- }
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
+ public void run() {
+ display = new Display();
+ Assert.assertNotNull( display );
+ SWTAccessor.printInfo(System.err, display);
+ }});
+
+ display.syncExec(new Runnable() {
+ public void run() {
+ shell = new Shell( display );
+ Assert.assertNotNull( shell );
+ shell.setText( getSimpleTestName(".") );
+ shell.setLayout( new FillLayout() );
+ shell.setSize( wsize.getWidth(), wsize.getHeight() );
+ if( null != wpos ) {
+ shell.setLocation(wpos.getX(), wpos.getY());
+ }
+ composite = new Composite( shell, SWT.NONE );
+ composite.setLayout( new FillLayout() );
+ Assert.assertNotNull( composite );
+
+ tabFolder = new CTabFolder(composite, SWT.TOP);
+ tabFolder.setBorderVisible(true);
+ tabFolder.setLayoutData(new FillLayout());
+ tabItem1 = new CTabItem(tabFolder, SWT.NONE, 0);
+ tabItem1.setText("PlainGL");
+ tabItem2 = new CTabItem(tabFolder, SWT.NONE, 1);
+ tabItem2.setText("SashGL");
+ if( addComposite ) {
+ tab1Comp = new Composite(tabFolder, SWT.NONE);
+ tab1Comp.setLayout(new FillLayout());
+ tabItem1.setControl(tab1Comp);
+ } else {
+ tab1Comp = null;
+ }
+ }});
- composite = new Composite(shell, SWT.NONE);
- composite.setLayout(new FillLayout());
- tabFolder = new CTabFolder(composite, SWT.TOP);
- tabFolder.setBorderVisible(true);
- tabFolder.setLayoutData(new FillLayout());
- tabItem1 = new CTabItem(tabFolder, SWT.NONE, 0);
- tabItem1.setText("PlainGL");
- tabItem2 = new CTabItem(tabFolder, SWT.NONE, 1);
- tabItem2.setText("SashGL");
- final Composite tab1Comp;
- if( addComposite ) {
- tab1Comp = new Composite(tabFolder, SWT.NONE);
- tab1Comp.setLayout(new FillLayout());
- tabItem1.setControl(tab1Comp);
- } else {
- tab1Comp = null;
- }
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, TestUtil.TIME_SLICE);
+ final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(display, true, 10);
final GLWindow glWindow1;
final NewtCanvasSWT newtCanvasSWT1;
@@ -237,29 +238,32 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
Assert.assertNotNull(glad1);
final GearsES2 demo1 = new GearsES2(1);
glad1.addGLEventListener(demo1);
- if( !addComposite ) {
- tabItem1.setControl(canvas1);
- }
- sash = new SashForm(tabFolder, SWT.NONE);
- Assert.assertNotNull( sash );
- final Text text = new Text (sash, SWT.MULTI | SWT.BORDER);
- text.setText("Left Sash Cell");
- text.append(Text.DELIMITER);
- if( useNewtCanvasSWT ) {
- text.append("SWT running with JogAmp, JOGL and NEWT using NewtCanvasSWT");
- } else {
- text.append("SWT running with JogAmp and JOGL using JOGL's GLCanvas");
- }
- text.append(Text.DELIMITER);
- final Composite sashRight;
- if( addComposite ) {
- sashRight = new Composite(sash, SWT.NONE);
- sashRight.setLayout(new FillLayout());
- } else {
- sashRight = null;
- }
- tabItem2.setControl(sash);
+ display.syncExec(new Runnable() {
+ public void run() {
+ if( !addComposite ) {
+ tabItem1.setControl(canvas1);
+ }
+
+ sash = new SashForm(tabFolder, SWT.NONE);
+ Assert.assertNotNull( sash );
+ final Text text = new Text (sash, SWT.MULTI | SWT.BORDER);
+ text.setText("Left Sash Cell");
+ text.append(Text.DELIMITER);
+ if( useNewtCanvasSWT ) {
+ text.append("SWT running with JogAmp, JOGL and NEWT using NewtCanvasSWT");
+ } else {
+ text.append("SWT running with JogAmp and JOGL using JOGL's GLCanvas");
+ }
+ text.append(Text.DELIMITER);
+ if( addComposite ) {
+ sashRight = new Composite(sash, SWT.NONE);
+ sashRight.setLayout(new FillLayout());
+ } else {
+ sashRight = null;
+ }
+ tabItem2.setControl(sash);
+ } } );
final Animator animator = new Animator();
animator.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD);
@@ -302,41 +306,44 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
// we need to forward these events of interest!
// Index 0 -> newtCanvasSWT1 ( glWindow1 )
// Index 1 -> newtCanvasSWT2 ( glWindow2 )
- {
- final Listener swtListener = new Listener() {
- @Override
- public void handleEvent(final Event event) {
- newtCanvasSWT1.notifyListeners(event.type, event);
- } };
- final Control itemControl = tabFolder.getItem(0).getControl();
- if( itemControl != newtCanvasSWT1 ) {
- itemControl.addListener(SWT.Show, swtListener);
- itemControl.addListener(SWT.Hide, swtListener);
- }
- }
- {
- final Listener swtListener = new Listener() {
- @Override
- public void handleEvent(final Event event) {
- newtCanvasSWT2.notifyListeners(event.type, event);
- } };
- final Control itemControl = tabFolder.getItem(1).getControl();
- if( itemControl != newtCanvasSWT2 ) {
- itemControl.addListener(SWT.Show, swtListener);
- itemControl.addListener(SWT.Hide, swtListener);
- }
- }
+ display.syncExec(new Runnable() {
+ public void run() {
+ final Listener swtListener0 = new Listener() {
+ @Override
+ public void handleEvent(final Event event) {
+ newtCanvasSWT1.notifyListeners(event.type, event);
+ } };
+ final Control itemControl0 = tabFolder.getItem(0).getControl();
+ if( itemControl0 != newtCanvasSWT1 ) {
+ itemControl0.addListener(SWT.Show, swtListener0);
+ itemControl0.addListener(SWT.Hide, swtListener0);
+ }
+
+ final Listener swtListener1 = new Listener() {
+ @Override
+ public void handleEvent(final Event event) {
+ newtCanvasSWT2.notifyListeners(event.type, event);
+ } };
+ final Control itemControl1 = tabFolder.getItem(1).getControl();
+ if( itemControl1 != newtCanvasSWT2 ) {
+ itemControl1.addListener(SWT.Show, swtListener1);
+ itemControl1.addListener(SWT.Hide, swtListener1);
+ }
+ } } );
}
animator.add(glad2);
- if( focusOnTab1 ) {
- canvas1.setFocus();
- tabFolder.setSelection(0);
- } else {
- canvas2.setFocus();
- tabFolder.setSelection(1);
- }
+ display.syncExec(new Runnable() {
+ public void run() {
+ if( focusOnTab1 ) {
+ canvas1.setFocus();
+ tabFolder.setSelection(0);
+ } else {
+ canvas2.setFocus();
+ tabFolder.setSelection(1);
+ }
+ } } );
final QuitAdapter quitAdapter = new QuitAdapter();
if( useNewtCanvasSWT ) {
@@ -405,15 +412,19 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
Assert.assertTrue(animator.isAnimating());
animator.setUpdateFPSFrames(60, null);
- shell.open(); // from here on, manipulation of SWT elements might be thread sensitive
+ display.syncExec(new Runnable() {
+ public void run() {
+ shell.open();
+ } } );
Assert.assertEquals(true, GLTestUtil.waitForRealized( focusOnTab1 ? glad1 : glad2, true, waitAction));
- {
- final Canvas canvas = focusOnTab1 ? canvas1 : canvas2;
- System.err.println("Canvas pixel-units pos/siz.0: pos "+SWTAccessor.getLocationInPixels(canvas)+", size "+SWTAccessor.getSizeInPixels(canvas));
- System.err.println("Canvas window-units pos/siz.0: pos "+canvas.getLocation()+", size "+canvas.getSize());
- System.err.println("Canvas LOS.0: "+canvas.toDisplay(0, 0));
- }
+ display.syncExec(new Runnable() {
+ public void run() {
+ final Canvas canvas = focusOnTab1 ? canvas1 : canvas2;
+ System.err.println("Canvas pixel-units pos/siz.0: pos "+SWTAccessor.getLocationInPixels(canvas)+", size "+SWTAccessor.getSizeInPixels(canvas));
+ System.err.println("Canvas window-units pos/siz.0: pos "+canvas.getLocation()+", size "+canvas.getSize());
+ System.err.println("Canvas LOS.0: "+canvas.toDisplay(0, 0));
+ } } );
if( useNewtCanvasSWT ) {
final GLWindow glWindow = focusOnTab1 ? glWindow1 : glWindow2;
final NewtCanvasSWT newtCanvasSWT = focusOnTab1 ? newtCanvasSWT1 : newtCanvasSWT2;
@@ -434,15 +445,12 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
}
display.syncExec( new Runnable() {
public void run() {
- shell.setSize( rwsize.getWidth(), rwsize.getHeight() );
- }
- });
- {
- final Canvas canvas = focusOnTab1 ? canvas1 : canvas2;
- System.err.println("Canvas pixel-units pos/siz.1: pos "+SWTAccessor.getLocationInPixels(canvas)+", size "+SWTAccessor.getSizeInPixels(canvas));
- System.err.println("Canvas window-units pos/siz.1: pos "+canvas.getLocation()+", size "+canvas.getSize());
- System.err.println("Canvas LOS.1: "+canvas.toDisplay(0, 0));
- }
+ shell.setSize( rwsize.getWidth(), rwsize.getHeight() );
+ final Canvas canvas = focusOnTab1 ? canvas1 : canvas2;
+ System.err.println("Canvas pixel-units pos/siz.1: pos "+SWTAccessor.getLocationInPixels(canvas)+", size "+SWTAccessor.getSizeInPixels(canvas));
+ System.err.println("Canvas window-units pos/siz.1: pos "+canvas.getLocation()+", size "+canvas.getSize());
+ System.err.println("Canvas LOS.1: "+canvas.toDisplay(0, 0));
+ } } );
if( useNewtCanvasSWT ) {
final GLWindow glWindow = focusOnTab1 ? glWindow1 : glWindow2;
final NewtCanvasSWT newtCanvasSWT = focusOnTab1 ? newtCanvasSWT1 : newtCanvasSWT2;
@@ -454,19 +462,22 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
if( !focusOnTab1 ) {
final PointImmutable pSashRightClient = new Point(wsize.getWidth(), 0);
- final PointImmutable pGLWinLOS;
+ final PointImmutable[] pGLWinLOS = { null };
if( useNewtCanvasSWT ) {
final PointImmutable pNatWinLOS = newtCanvasSWT2.getNativeWindow().getLocationOnScreen(null);
- pGLWinLOS = glWindow2.getLocationOnScreen(null);
+ pGLWinLOS[0] = glWindow2.getLocationOnScreen(null);
System.err.println("GLWindow2 LOS: "+pGLWinLOS);
System.err.println("NewtCanvasSWT2 LOS: "+pNatWinLOS);
Assert.assertTrue( "NewtCanvasAWT2 LOS "+pNatWinLOS+" not >= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 );
} else {
- final org.eclipse.swt.graphics.Point los = glCanvas2.toDisplay(0, 0);
- pGLWinLOS = new Point(los.x, los.y);
- System.err.println("GLCanvas2 LOS: "+pGLWinLOS);
+ display.syncExec(new Runnable() {
+ public void run() {
+ final org.eclipse.swt.graphics.Point los = glCanvas2.toDisplay(0, 0);
+ pGLWinLOS[0] = new Point(los.x, los.y);
+ System.err.println("GLCanvas2 LOS: "+pGLWinLOS);
+ } } );
}
- Assert.assertTrue( "GLWindow2 LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 );
+ Assert.assertTrue( "GLWindow2 LOS "+pGLWinLOS[0]+" not >= sash-right "+pSashRightClient, pGLWinLOS[0].compareTo(pSashRightClient) >= 0 );
}
while( animator.isAnimating() ) {
@@ -489,15 +500,24 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
try {
if( useNewtCanvasSWT ) {
- newtCanvasSWT1.dispose();
+ display.syncExec( new Runnable() {
+ public void run() {
+ newtCanvasSWT1.dispose();
+ } } );
glWindow1.destroy();
Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow1, false, null));
- newtCanvasSWT2.dispose();
+ display.syncExec( new Runnable() {
+ public void run() {
+ newtCanvasSWT2.dispose();
+ } } );
glWindow2.destroy();
Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow2, false, null));
} else {
- glCanvas1.dispose();
- glCanvas2.dispose();
+ display.syncExec( new Runnable() {
+ public void run() {
+ glCanvas1.dispose();
+ glCanvas2.dispose();
+ } } );
}
}
catch( final Throwable throwable ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
index 329a08a48..85efcdd45 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
@@ -61,6 +61,8 @@ import com.jogamp.newt.swt.NewtCanvasSWT ;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NewtTestUtil;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
+import com.jogamp.opengl.test.junit.util.TestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
////////////////////////////////////////////////////////////////////////////////
@@ -257,7 +259,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
volatile com.jogamp.newt.Display swtNewtDisplay = null;
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -285,7 +287,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
composite.dispose();
shell.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -299,22 +301,6 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
shell = null;
composite = null;
}
- class WaitAction implements Runnable {
- private final long sleepMS;
-
- WaitAction(final long sleepMS) {
- this.sleepMS = sleepMS;
- }
- public void run() {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- try {
- Thread.sleep(sleepMS);
- } catch (final InterruptedException e) { }
- }
- }
- }
- final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE);
}
@Test
@@ -350,7 +336,11 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
dsc.shell.setSize( 400, 450 ) ;
dsc.shell.open() ;
} } );
- Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(glWindow, true, dsc.awtRobotWaitAction));
+
+ final SWTTestUtil.WaitAction awtRobotWaitAction = new SWTTestUtil.WaitAction(dsc.display, true, TestUtil.TIME_SLICE);
+ final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(dsc.display, true, 10);
+
+ Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(glWindow, true, awtRobotWaitAction));
AWTRobotUtil.requestFocus(robot, glWindow, false);
AWTRobotUtil.setMouseToClientLocation(robot, glWindow, 50, 50);
@@ -397,15 +387,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
try {
while( !shallStop && !dsc.display.isDisposed() ) {
- dsc.display.syncExec( new Runnable() {
- public void run() {
- if( !dsc.display.isDisposed() && !dsc.display.readAndDispatch() && !shallStop ) {
- // blocks on linux .. dsc.display.sleep();
- try {
- Thread.sleep(10);
- } catch (final InterruptedException ie) { ie.printStackTrace(); }
- }
- } } );
+ generalWaitAction.run();
}
} catch (final Exception e0) {
e0.printStackTrace();
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 93b1af15a..12c7d6e0b 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
@@ -58,6 +58,8 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NewtTestUtil;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
+import com.jogamp.opengl.test.junit.util.TestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLReadBufferUtil;
@@ -96,7 +98,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -124,7 +126,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
composite.dispose();
shell.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -139,24 +141,6 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
composite = null;
}
- class WaitAction implements Runnable {
- private final long sleepMS;
-
- WaitAction(final long sleepMS) {
- this.sleepMS = sleepMS;
- }
- public void run() {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- try {
- Thread.sleep(sleepMS);
- } catch (final InterruptedException e) { }
- }
- }
- }
- final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE);
- final WaitAction generalWaitAction = new WaitAction(10);
-
protected void runTestAGL( final GLCapabilitiesImmutable caps, final GLEventListener demo,
final boolean postAttach, final boolean useAnimator ) throws InterruptedException {
final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
@@ -192,9 +176,15 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
});
if(postAttach) {
- canvas1.setNEWTChild(glWindow1);
+ display.syncExec( new Runnable() {
+ public void run() {
+ canvas1.setNEWTChild(glWindow1);
+ } } );
}
+ final SWTTestUtil.WaitAction awtRobotWaitAction = new SWTTestUtil.WaitAction(display, true, TestUtil.TIME_SLICE);
+ final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(display, true, 10);
+
Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(glWindow1, true, awtRobotWaitAction));
System.err.println("GLWindow LOS.0: "+glWindow1.getLocationOnScreen(null));
@@ -224,7 +214,10 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
anim.stop();
}
- canvas1.dispose();
+ display.syncExec( new Runnable() {
+ public void run() {
+ canvas1.dispose();
+ } } );
}
@Test
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor01.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor01.java
index 79dc71406..0b8245d7f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor01.java
@@ -83,7 +83,7 @@ public class TestSWTAccessor01 extends UITestCase {
}
protected void init() throws InterruptedException, InvocationTargetException {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -114,7 +114,7 @@ public class TestSWTAccessor01 extends UITestCase {
Assert.assertNotNull( shell );
Assert.assertNotNull( composite );
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
composite.dispose();
shell.close();
@@ -130,7 +130,7 @@ public class TestSWTAccessor01 extends UITestCase {
init();
final Canvas canvas[] = { null };
try {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
canvas[0] = new Canvas (composite, SWT.NONE);
canvas[0].setBackground(new Color(display, 255, 255, 255));
@@ -159,7 +159,7 @@ public class TestSWTAccessor01 extends UITestCase {
final long lEndTime = lStartTime + duration;
try {
while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
if( !display.readAndDispatch() ) {
// blocks on linux .. display.sleep();
@@ -169,7 +169,7 @@ public class TestSWTAccessor01 extends UITestCase {
}
}});
}
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
System.err.println("Window handle.X 0x"+Long.toHexString(SWTAccessor.getWindowHandle(canvas[0])));
}});
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 b40eb3203..689f29260 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
@@ -65,6 +65,7 @@ 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.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import jogamp.newt.swt.SWTEDTUtil;
@@ -92,7 +93,7 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase {
Composite composite = null;
protected void init() throws InterruptedException, InvocationTargetException {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -123,7 +124,7 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase {
Assert.assertNotNull( shell );
Assert.assertNotNull( composite );
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
glwin.destroy();
composite.dispose();
@@ -208,14 +209,7 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase {
canvas[0].redraw();
}});
- final Runnable waitAction = new Runnable() {
- public void run() {
- if( !display.readAndDispatch() ) {
- try {
- Thread.sleep(10);
- } catch (final InterruptedException e) { }
- }
- } };
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 10);
Assert.assertEquals(true, NewtTestUtil.waitForVisible(glwin, true, waitAction));
Assert.assertEquals(true, GLTestUtil.waitForRealized(glwin, true, waitAction));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java
index 732db5c51..bacd6f293 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java
@@ -104,7 +104,7 @@ public class TestSWTAccessor03AWTGLn extends UITestCase {
}
protected void init() throws InterruptedException, InvocationTargetException {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -138,7 +138,7 @@ public class TestSWTAccessor03AWTGLn extends UITestCase {
// javax.swing.SwingUtilities.invokeAndWait( releaseAWT );
releaseAWT.run();
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
composite.dispose();
shell.close();
@@ -182,7 +182,7 @@ public class TestSWTAccessor03AWTGLn extends UITestCase {
}
});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
shell.setText( getClass().getName() );
shell.setSize( 640, 480 );
@@ -193,7 +193,7 @@ public class TestSWTAccessor03AWTGLn extends UITestCase {
final long lEndTime = lStartTime + duration;
try {
while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
if( !display.readAndDispatch() ) {
// blocks on linux .. display.sleep();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java
index b8ba3b97e..9eb1eefdb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java
@@ -60,6 +60,8 @@ import com.jogamp.opengl.swt.GLCanvas;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NewtTestUtil;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
+import com.jogamp.opengl.test.junit.util.TestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
@@ -171,7 +173,7 @@ public class TestSWTBug643AsyncExec extends UITestCase {
Composite composite;
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -198,7 +200,7 @@ public class TestSWTBug643AsyncExec extends UITestCase {
composite.dispose();
shell.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -229,7 +231,11 @@ public class TestSWTBug643AsyncExec extends UITestCase {
final GearsES2 demo = new GearsES2();
final GLCanvas glc = GLCanvas.create(dsc.composite, 0, caps, null);
final SWTNewtEventFactory swtNewtEventFactory = new SWTNewtEventFactory();
- swtNewtEventFactory.attachDispatchListener(glc, glc, demo.gearsMouse, demo.gearsKeys);
+ dsc.display.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ swtNewtEventFactory.attachDispatchListener(glc, glc, demo.gearsMouse, demo.gearsKeys);
+ } } );
glc.addGLEventListener( demo ) ;
glad = glc;
newtDisplay = null;
@@ -296,13 +302,12 @@ public class TestSWTBug643AsyncExec extends UITestCase {
t.start();
}
+ final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(dsc.display, true, 10);
+
try {
final Display d = dsc.display;
while( !shallStop && !d.isDisposed() ) {
- if( !d.readAndDispatch() && !shallStop ) {
- // blocks on linux .. dsc.display.sleep();
- Thread.sleep(10);
- }
+ generalWaitAction.run();
}
} catch (final Exception e0) {
e0.printStackTrace();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java
index 7c91a04af..0a9d5591a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java
@@ -57,6 +57,7 @@ import org.junit.runners.MethodSorters;
import com.jogamp.nativewindow.swt.SWTAccessor;
import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
@@ -77,6 +78,9 @@ public class TestSWTEclipseGLCanvas01GLn extends UITestCase {
Display display = null;
Shell shell = null;
Composite composite = null;
+ GLCanvas glcanvas = null;
+ volatile boolean triangleSet = false;
+
@BeforeClass
public static void startup() {
@@ -85,10 +89,14 @@ public class TestSWTEclipseGLCanvas01GLn extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ triangleSet = false;
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
+ } } );
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
+ public void run() {
shell = new Shell( display );
Assert.assertNotNull( shell );
shell.setLayout( new FillLayout() );
@@ -104,8 +112,11 @@ public class TestSWTEclipseGLCanvas01GLn extends UITestCase {
Assert.assertNotNull( shell );
Assert.assertNotNull( composite );
try {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
+ if( null != glcanvas ) {
+ glcanvas.dispose();
+ }
composite.dispose();
shell.dispose();
display.dispose();
@@ -118,64 +129,82 @@ public class TestSWTEclipseGLCanvas01GLn extends UITestCase {
display = null;
shell = null;
composite = null;
+ glcanvas = null;
}
protected void runTestAGL( final GLProfile glprofile ) throws InterruptedException {
- final GLData gldata = new GLData();
- gldata.doubleBuffer = true;
- // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
- // at the wrong times (we use glClear for this instead)
- final GLCanvas glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
- Assert.assertNotNull( glcanvas );
- glcanvas.setCurrent();
- final GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
- Assert.assertNotNull( glcontext );
-
- // fix the viewport when the user resizes the window
- glcanvas.addListener( SWT.Resize, new Listener() {
- public void handleEvent( final Event event ) {
- final Rectangle rectangle = glcanvas.getClientArea();
- glcanvas.setCurrent();
- glcontext.makeCurrent();
- final GL2ES1 gl = glcontext.getGL().getGL2ES1();
- OneTriangle.setup( gl, rectangle.width, rectangle.height );
- glcontext.release();
- System.err.println("resize");
- }
- });
+ final GLContext glcontext[] = { null };
- // draw the triangle when the OS tells us that any part of the window needs drawing
- glcanvas.addPaintListener( new PaintListener() {
- public void paintControl( final PaintEvent paintevent ) {
- final Rectangle rectangle = glcanvas.getClientArea();
- glcanvas.setCurrent();
- glcontext.makeCurrent();
- final GL2ES1 gl = glcontext.getGL().getGL2ES1();
- OneTriangle.render( gl, rectangle.width, rectangle.height );
- glcanvas.swapBuffers();
- glcontext.release();
- System.err.println("paint");
- }
- });
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
+ public void run() {
+ shell.setText( getClass().getName() );
+ shell.setSize( 640, 480 );
+ shell.open();
+
+ final GLData gldata = new GLData();
+ gldata.doubleBuffer = true;
- shell.setText( getClass().getName() );
- shell.setSize( 640, 480 );
- shell.open();
+ // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
+ // at the wrong times (we use glClear for this instead)
+ glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
+ Assert.assertNotNull( glcanvas );
+
+ glcanvas.setCurrent();
+ glcontext[0] = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
+ Assert.assertNotNull( glcontext[0] );
+
+ // fix the viewport when the user resizes the window
+ glcanvas.addListener( SWT.Resize, new Listener() {
+ public void handleEvent( final Event event ) {
+ final Rectangle rectangle = glcanvas.getClientArea();
+ glcanvas.setCurrent();
+ glcontext[0].makeCurrent();
+ final GL2ES1 gl = glcontext[0].getGL().getGL2ES1();
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
+ triangleSet = true;
+ glcontext[0].release();
+ System.err.println("resize");
+ }
+ });
+
+ // draw the triangle when the OS tells us that any part of the window needs drawing
+ glcanvas.addPaintListener( new PaintListener() {
+ public void paintControl( final PaintEvent paintevent ) {
+ final Rectangle rectangle = glcanvas.getClientArea();
+ glcanvas.setCurrent();
+ glcontext[0].makeCurrent();
+ final GL2ES1 gl = glcontext[0].getGL().getGL2ES1();
+ if( !triangleSet ) {
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
+ triangleSet = true;
+ }
+ OneTriangle.render( gl, rectangle.width, rectangle.height );
+ glcanvas.swapBuffers();
+ glcontext[0].release();
+ System.err.println("paint");
+ }
+ });
+ } } );
+
+ final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(display, true, 16);
final long lStartTime = System.currentTimeMillis();
final long lEndTime = lStartTime + duration;
try {
while( (System.currentTimeMillis() < lEndTime) && !glcanvas.isDisposed() ) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
+ public void run() {
+ if( !triangleSet ) {
+ glcanvas.setSize( 640, 480 );
+ }
+ // glcanvas.redraw();
+ } } );
+ generalWaitAction.run();
}
} catch( final Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
- glcanvas.dispose();
}
@Test
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java
index 4cb273630..68c25fca2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java
@@ -53,6 +53,7 @@ import com.jogamp.nativewindow.swt.SWTAccessor;
import com.jogamp.opengl.swt.GLCanvas;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLReadBufferUtil;
@@ -66,7 +67,7 @@ import com.jogamp.opengl.util.texture.TextureIO;
* independent from the already instantiated SWT visual.
* </p>
* <p>
- * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/
+ * Note that {@link SWTAccessor#invokeOnOSTKThread(boolean, Runnable)} is still used to comply w/
* SWT running on Mac OSX, i.e. to enforce UI action on the main thread.
* </p>
* @author Wade Walker, et al.
@@ -91,7 +92,7 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -118,7 +119,7 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase {
composite.dispose();
shell.dispose();
}});
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display.dispose();
}});
@@ -164,14 +165,12 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase {
anim.start();
}
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 16);
final long lStartTime = System.currentTimeMillis();
final long lEndTime = lStartTime + duration;
try {
while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
+ waitAction.run();
}
} catch( final Throwable throwable ) {
throwable.printStackTrace();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java
index 4d1cbdae2..0d83108d4 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java
@@ -72,7 +72,7 @@ public class TestNewtEventModifiersNewtCanvasSWTAWT extends BaseNewtEventModifie
final boolean[] res = { false };
int i=0;
do {
- SWTAccessor.invoke(_display, true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(_display, true, new Runnable() {
public void run() {
if( !_display.isDisposed() ) {
res[0] = _display.readAndDispatch();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java
index 283caeb59..fed298ebc 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java
@@ -55,6 +55,7 @@ import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.swt.NewtCanvasSWT;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
@@ -80,10 +81,14 @@ public class TestParenting01aSWT extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
+ } } );
+
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
+ public void run() {
shell = new Shell( display );
Assert.assertNotNull( shell );
shell.setLayout( new FillLayout() );
@@ -100,7 +105,7 @@ public class TestParenting01aSWT extends UITestCase {
Assert.assertNotNull( shell );
Assert.assertNotNull( composite1 );
try {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
composite1.dispose();
shell.dispose();
@@ -137,7 +142,7 @@ public class TestParenting01aSWT extends UITestCase {
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertNull(glWindow1.getParent());
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
shell.setText( getSimpleTestName(".") );
shell.setSize( 640, 480 );
@@ -148,28 +153,30 @@ public class TestParenting01aSWT extends UITestCase {
// visible test
Assert.assertEquals(canvas1.getNativeWindow(),glWindow1.getParent());
+ final SWTTestUtil.WaitAction generalWaitAction = new SWTTestUtil.WaitAction(display, true, 16);
+
for(int i=0; i*10<durationPerTest; i++) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
+ generalWaitAction.run();
}
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
canvas1.setVisible(false);
}
});
Assert.assertEquals(true, glWindow1.isNativeValid());
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
canvas1.setVisible(true);
}
});
Assert.assertEquals(true, glWindow1.isNativeValid());
- canvas1.dispose();
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
+ public void run() {
+ canvas1.dispose();
+ } } );
Assert.assertEquals(false, glWindow1.isNativeValid());
}
@@ -201,18 +208,7 @@ public class TestParenting01aSWT extends UITestCase {
durationPerTest = atoi(args[++i]);
}
}
- final String tstname = TestParenting01aSWT.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- tstname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
+ org.junit.runner.JUnitCore.main(TestParenting01aSWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java
index 5e59d55d0..7fc44b04f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java
@@ -55,7 +55,9 @@ import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.swt.NewtCanvasSWT;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT;
import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.SWTTestUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
@@ -84,7 +86,7 @@ public class TestParenting04SWT extends UITestCase {
@Before
public void init() {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
display = new Display();
Assert.assertNotNull( display );
@@ -114,7 +116,7 @@ public class TestParenting04SWT extends UITestCase {
Assert.assertNotNull( composite1 );
Assert.assertNotNull( composite2 );
try {
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnOSTKThread(true, new Runnable() {
public void run() {
composite1.dispose();
composite2.dispose();
@@ -165,7 +167,7 @@ public class TestParenting04SWT extends UITestCase {
final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite1, 0, glWindow1 );
final NewtCanvasSWT canvas2 = NewtCanvasSWT.create( composite2, 0, glWindow2 );
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
shell1.setText( getSimpleTestName(".")+"-Win1" );
shell1.setSize( width, height);
@@ -183,17 +185,15 @@ public class TestParenting04SWT extends UITestCase {
anim1.start();
anim2.start();
+ final SWTTestUtil.WaitAction waitAction = new SWTTestUtil.WaitAction(display, true, 16);
int state;
for(state=0; state<3; state++) {
for(int i=0; i*10<durationPerTest; i++) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
+ waitAction.run();
}
switch(state) {
case 0:
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
// 1 -> 2
if(detachFirst) {
@@ -207,7 +207,7 @@ public class TestParenting04SWT extends UITestCase {
} } );
break;
case 1:
- SWTAccessor.invoke(true, new Runnable() {
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
public void run() {
// 2 -> 1
if(detachFirst) {
@@ -223,8 +223,11 @@ public class TestParenting04SWT extends UITestCase {
}
}
- canvas1.dispose();
- canvas2.dispose();
+ SWTAccessor.invokeOnSWTThread(display, true, new Runnable() {
+ public void run() {
+ canvas1.dispose();
+ canvas2.dispose();
+ } } );
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertEquals(false, glWindow2.isNativeValid());
}
@@ -256,18 +259,7 @@ public class TestParenting04SWT extends UITestCase {
durationPerTest = atoi(args[++i]);
}
}
- final String tstname = TestParenting04SWT.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- tstname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
+ org.junit.runner.JUnitCore.main(TestParenting04SWT.class.getName());
}
}