aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-01-06 04:51:19 +0100
committerSven Gothel <[email protected]>2020-01-06 04:51:19 +0100
commit05b3978d47e304b2e0223bbdf34d393a2e4c7c26 (patch)
tree719178fda4dd8361268322ea71e578756e6fb10c
parent69db39c035455fc0154006304e7340d825415e99 (diff)
Bug 1421, Bug 1358, Bug 969, Bug 672: Generalization of test case TestGLCanvasSWTNewtCanvasSWTPosInTabs (2/2)
Complete merging unit tests.
-rw-r--r--make/scripts/tests.sh7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java499
2 files changed, 392 insertions, 114 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 6039109fd..ddfef3047 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"
+ D_ARGS="-Dnativewindow.debug.SWT -Dnewt.debug.Window -Djogl.debug.GLCanvas"
#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"
@@ -185,7 +185,6 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL"
#D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window"
- #D_ARGS="-Dnativewindow.debug.SWT -Djogl.debug.GLCanvas"
#D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas"
#D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource"
#D_ARGS="-Dnativewindow.debug.JAWT"
@@ -794,13 +793,13 @@ function testawtswt() {
#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.TestNewtCanvasSWTGLn $*
-testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug1421NewtCanvasSWTPosInTabs $*
#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.TestGLCanvasSWTNewtCanvasSWTPosInTabs $*
#testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite $*
+#testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm $*
#testswt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $*
#
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 69e1b7fda..597fe1b0b 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
@@ -28,17 +28,28 @@
package com.jogamp.opengl.test.junit.jogl.swt;
+import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
+import com.jogamp.opengl.GLCapabilitiesImmutable;
import com.jogamp.opengl.GLProfile;
+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.RedSquareES2;
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.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import java.io.IOException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -47,69 +58,94 @@ import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.nativewindow.util.Dimension;
+import com.jogamp.nativewindow.util.DimensionImmutable;
+import com.jogamp.nativewindow.util.Point;
+import com.jogamp.nativewindow.util.PointImmutable;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.swt.NewtCanvasSWT;
-import com.jogamp.opengl.util.FPSAnimator;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.AnimatorBase;
/**
- * Test for Bug 1421: Child Newt Window position within an SWT (tab) layout
- * using NewtCanvasSWT on MacOS.
+ * Test for Bug 1421, Bug 1358, Bug 969 and Bug 672.
+ * <p>
+ * High-DPI scaling impact on MacOS and
+ * SWT child window positioning on MacOS.
+ * </p>
+ * <p>
+ * Testing the TabFolder and a SashForm in the 2nd tab
+ * covering both SWT layout use cases on
+ * both our SWT support classes SWT GLCanvas and NewtCanvasSWT.
+ * </p>
* <p>
* Bug 1421 {@link #test01_tabFolderParent()} shows that the
* inner child NEWT GLWindow is position wrongly.
* It's position is shifted down abo0ut the height of the
* parent TabFolder and right about the width of the same.
* </p>
- * This positioning issue occurs on MacOS
- * with and without High-DPI Retina,
- * therefor it is a general issue on MacOS.
- * This issue does not occur on GNU/Linux GTK nor on Windows.
- * </p>
*/
-public class TestGLCanvasSWTNewtCanvasSWTPosInTabs {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGLCanvasSWTNewtCanvasSWTPosInTabs extends UITestCase {
static int duration = 250;
+
Display display = null;
Shell shell = null;
+ Composite composite = null;
+ CTabFolder tabFolder = null;
+ CTabItem tabItem1 = null;
+ CTabItem tabItem2 = null;
+ SashForm sash = null;
+ Composite sashRightComposite = null;
- private static final int FPS = 60; // animator's target frames per second
+ static PointImmutable wpos = null;
+ static DimensionImmutable wsize = new Dimension(640, 480), rwsize = null;
@BeforeClass
public static void startup() {
GLProfile.initSingleton();
}
- @Before
- public void init() {
- SWTAccessor.invoke(true, new Runnable() {
- public void run() {
- display = new Display();
- Assert.assertNotNull( display );
- }});
- display.syncExec(new Runnable() {
- public void run() {
- shell = new Shell( display );
- Assert.assertNotNull( shell );
- }});
- }
-
@After
public void release() {
- Assert.assertNotNull( display );
- Assert.assertNotNull( shell );
try {
- display.syncExec(new Runnable() {
- public void run() {
- shell.dispose();
- }});
+ if( null != display ) {
+ display.syncExec(new Runnable() {
+ public void run() {
+ if( null != sashRightComposite ) {
+ sashRightComposite.dispose();
+ }
+ if( null != sash ) {
+ sash.dispose();
+ }
+ if( null != tabFolder ) {
+ tabFolder.dispose();
+ }
+ if( null != composite ) {
+ composite.dispose();
+ }
+ if( null != shell ) {
+ shell.dispose();
+ }
+ }});
+ }
SWTAccessor.invoke(true, new Runnable() {
public void run() {
- display.dispose();
+ if( null != display ) {
+ display.dispose();
+ }
}});
}
catch( final Throwable throwable ) {
@@ -118,6 +154,12 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs {
}
display = null;
shell = null;
+ composite = null;
+ tabFolder = null;
+ tabItem1 = null;
+ tabItem2 = null;
+ sash = null;
+ sashRightComposite = null;
}
class WaitAction implements Runnable {
@@ -138,103 +180,340 @@ public class TestGLCanvasSWTNewtCanvasSWTPosInTabs {
final WaitAction waitAction = new WaitAction(AWTRobotUtil.TIME_SLICE);
final WaitAction generalWaitAction = new WaitAction(10);
- protected void runTestInLayout() throws InterruptedException {
- shell.setText("OneTriangle SWT");
- shell.setLayout(new FillLayout());
- shell.setSize(640, 480);
-
- final Composite composite = new Composite(shell, SWT.NONE);
- composite.setLayout(new FillLayout());
- final CTabFolder tabFolder = new CTabFolder(composite, SWT.TOP);
- tabFolder.setBorderVisible(true);
- tabFolder.setLayoutData(new FillLayout());
- final CTabItem tabItem1 = new CTabItem(tabFolder, SWT.NONE, 0);
- tabItem1.setText("GLTab1");
- final CTabItem tabItem2 = new CTabItem(tabFolder, SWT.NONE, 1);
- tabItem2.setText("GLTab2");
-
- // Get the default OpenGL profile, reflecting the best for your running platform
- final GLProfile glp = GLProfile.getDefault();
- // Specifies a set of OpenGL capabilities, based on your profile.
- final GLCapabilities caps = new GLCapabilities(glp);
- // Create the OpenGL rendering canvas
- final GLWindow window = GLWindow.create(caps);
-
- // Create a animator that drives canvas' display() at the specified FPS.
- final FPSAnimator animator = new FPSAnimator(window, FPS, true);
-
- window.addWindowListener(new WindowAdapter() {
- @Override
- public void windowDestroyNotify(final WindowEvent arg0) {
- // Use a dedicate thread to run the stop() to ensure that the
- // animator stops before program exits.
- new Thread() {
- @Override
- public void run() {
- if (animator.isStarted())
- animator.stop(); // stop the animator loop
- System.exit(0);
- }
- }.start();
- }
- });
-
- window.addGLEventListener(new GearsES2());
- // window.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
- // window.setTitle(TITLE);
- // window.setVisible(true);
-
- final NewtCanvasSWT canvas = new NewtCanvasSWT(tabFolder, SWT.NO_BACKGROUND, window);
- // canvas.setSize(tabFolder.getClientArea().width,
- // tabFolder.getClientArea().height);
- tabItem1.setControl(canvas);
- canvas.setFocus();
- animator.start(); // start the animator loop
- display.syncExec( new Runnable() {
- public void run() {
- shell.open();
- }
- });
- Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(window, true, waitAction));
-
- final long lStartTime = System.currentTimeMillis();
- final long lEndTime = lStartTime + duration;
- try {
- while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) {
+ protected void runTestInLayout(final boolean focusOnTab1, final boolean useNewtCanvasSWT, final GLCapabilitiesImmutable caps)
+ throws InterruptedException
+ {
+ display = new Display();
+ Assert.assertNotNull( display );
+
+ shell = new Shell( display );
+ shell.setText( getSimpleTestName(".") );
+ shell.setLayout(new FillLayout());
+ shell.setSize( wsize.getWidth(), wsize.getHeight() );
+
+ 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");
+ sash = new SashForm(tabFolder, SWT.NONE);
+ Assert.assertNotNull( sash );
+ final org.eclipse.swt.widgets.Label c = new org.eclipse.swt.widgets.Label(sash, SWT.NONE);
+ c.setText("Left cell");
+ sashRightComposite = new Composite(sash, SWT.NONE);
+ Assert.assertNotNull( sashRightComposite );
+ sashRightComposite.setLayout( new FillLayout() );
+ tabItem2.setControl(sash);
+
+ final GLWindow glWindow1;
+ final NewtCanvasSWT newtCanvasSWT1;
+ final GLCanvas glCanvas1;
+ final Canvas canvas1;
+ final GLAutoDrawable glad1;
+ if( useNewtCanvasSWT ) {
+ glCanvas1 = null;
+ glWindow1 = GLWindow.create(caps);
+ glad1 = glWindow1;
+ Assert.assertNotNull(glWindow1);
+ newtCanvasSWT1 = NewtCanvasSWT.create( tabFolder, 0, glWindow1 );
+ Assert.assertNotNull( newtCanvasSWT1 );
+ canvas1 = newtCanvasSWT1;
+ } else {
+ glWindow1 = null;
+ newtCanvasSWT1 = null;
+ glCanvas1 = GLCanvas.create( tabFolder, 0, caps, null);
+ glad1 = glCanvas1;
+ Assert.assertNotNull(glCanvas1);
+ canvas1 = glCanvas1;
+ }
+ Assert.assertNotNull(canvas1);
+ Assert.assertNotNull(glad1);
+ tabItem1.setControl(canvas1);
+ final GearsES2 demo1 = new GearsES2(1);
+ glad1.addGLEventListener(demo1);
+
+ final Animator animator1 = new Animator();
+ animator1.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD);
+ animator1.add(glad1);
+
+ final GLWindow glWindow2;
+ final GLCanvas glCanvas2;
+ final NewtCanvasSWT newtCanvasSWT2;
+ final Canvas canvas2;
+ final GLAutoDrawable glad2;
+ if( useNewtCanvasSWT ) {
+ glWindow2 = GLWindow.create(caps);
+ glad2 = glWindow2;
+ glCanvas2 = null;
+ Assert.assertNotNull(glWindow2);
+ newtCanvasSWT2 = NewtCanvasSWT.create( sashRightComposite, 0, glWindow2 );
+ Assert.assertNotNull( newtCanvasSWT2 );
+ canvas2 = newtCanvasSWT2;
+ } else {
+ glCanvas2 = GLCanvas.create( sashRightComposite, 0, caps, null);
+ glad2 = glCanvas2;
+ glWindow2 = null;
+ Assert.assertNotNull(glCanvas2);
+ newtCanvasSWT2 = null;
+ canvas2 = glCanvas2;
+ }
+ Assert.assertNotNull(canvas2);
+ Assert.assertNotNull(glad2);
+ final RedSquareES2 demo2 = new RedSquareES2(1);
+ glad2.addGLEventListener(demo2);
+
+ final Animator animator2 = new Animator();
+ animator2.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD);
+ animator2.add(glad2);
+
+ if( focusOnTab1 ) {
+ canvas1.setFocus();
+ tabFolder.setSelection(0);
+ } else {
+ canvas2.setFocus();
+ tabFolder.setSelection(1);
+ }
+
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ if( useNewtCanvasSWT ) {
+ glWindow1.addKeyListener(quitAdapter);
+ glWindow1.addWindowListener(quitAdapter);
+ glWindow2.addKeyListener(quitAdapter);
+ glWindow2.addWindowListener(quitAdapter);
+
+ final WindowListener wl = new WindowAdapter() {
+ public void windowResized(final WindowEvent e) {
+ final GLWindow glWindow = ( e.getSource() instanceof GLWindow ) ? (GLWindow)e.getSource() : null;
+ if( null != glWindow ) {
+ System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
+ }
+ }
+ public void windowMoved(final WindowEvent e) {
+ final GLWindow glWindow = ( e.getSource() instanceof GLWindow ) ? (GLWindow)e.getSource() : null;
+ if( null != glWindow ) {
+ System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight());
+ }
+ }
+ };
+ glWindow1.addWindowListener(wl);
+ glWindow2.addWindowListener(wl);
+
+ final KeyListener kl = new KeyAdapter() {
+ public void keyReleased(final KeyEvent e) {
+ if( !e.isPrintableKey() || e.isAutoRepeat() ) {
+ return;
+ }
+ final GLWindow glWindow = ( e.getSource() instanceof GLWindow ) ? (GLWindow)e.getSource() : null;
+ if( null != glWindow ) {
+ if(e.getKeyChar()=='f') {
+ glWindow.invokeOnNewThread(null, false, new Runnable() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+ glWindow.setFullscreen(!glWindow.isFullscreen());
+ System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+ glWindow.setExclusiveContextThread(t);
+ } } );
+ }
+ }
+ }
+ };
+ glWindow1.addKeyListener(kl);
+ glWindow2.addKeyListener(kl);
+ }
+
+ animator1.start();
+ Assert.assertTrue(animator1.isStarted());
+ Assert.assertTrue(animator1.isAnimating());
+ animator1.setUpdateFPSFrames(60, null);
+
+ animator2.start();
+ Assert.assertTrue(animator2.isStarted());
+ Assert.assertTrue(animator2.isAnimating());
+ animator2.setUpdateFPSFrames(60, null);
+
+ shell.open(); // from here on, manipulation of SWT elements might be thread sensitive
+
+ if( useNewtCanvasSWT ) {
+ final GLWindow glWindow = focusOnTab1 ? glWindow1 : glWindow2;
+ final NewtCanvasSWT newtCanvasSWT = focusOnTab1 ? newtCanvasSWT1 : newtCanvasSWT2;
+ Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(glWindow, true, waitAction));
+ Assert.assertNotNull( newtCanvasSWT.getNativeWindow() );
+ System.err.println("NewtCanvasSWT LOS.0: "+newtCanvasSWT.getNativeWindow().getLocationOnScreen(null));
+ System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
+ System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("window pos/siz.0: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
+ System.err.println("GLWindow LOS.0: "+glWindow.getLocationOnScreen(null));
+ } else {
+ final GLCanvas glCanvas = focusOnTab1 ? glCanvas1: glCanvas2;
+ System.err.println("GL chosen: "+glCanvas.getChosenGLCapabilities());
+ System.err.println("GLCanvas pixel-units pos/siz.0: pos "+SWTAccessor.getLocationInPixels(glCanvas)+", size "+SWTAccessor.getSizeInPixels(glCanvas));
+ System.err.println("GLCanvas window-units pos/siz.0: pos "+glCanvas.getLocation()+", size "+glCanvas.getSize());
+ System.err.println("GLCanvas LOS.0: "+SWTAccessor.getLocationOnScreen(new Point(), glCanvas));
+ }
+ Assert.assertEquals(true, GLTestUtil.waitForRealized( focusOnTab1 ? glad1 : glad2, true, waitAction));
+
+ if( null != rwsize ) {
+ for(int i=0; i<50; i++) { // 500 ms dispatched delay
generalWaitAction.run();
}
- } catch( final Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
+ display.syncExec( new Runnable() {
+ public void run() {
+ shell.setSize( rwsize.getWidth(), rwsize.getHeight() );
+ }
+ });
+ if( useNewtCanvasSWT ) {
+ final GLWindow glWindow = focusOnTab1 ? glWindow1 : glWindow2;
+ final NewtCanvasSWT newtCanvasSWT = focusOnTab1 ? newtCanvasSWT1 : newtCanvasSWT2;
+ System.err.println("window resize pos/siz.1: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
+ System.err.println("GLWindow LOS.1: "+glWindow.getLocationOnScreen(null));
+ System.err.println("NewtCanvasSWT LOS.1: "+newtCanvasSWT.getNativeWindow().getLocationOnScreen(null));
+ } else {
+ final GLCanvas glCanvas = focusOnTab1 ? glCanvas1: glCanvas2;
+ System.err.println("GLCanvas pixel-units pos/siz.1: pos "+SWTAccessor.getLocationInPixels(glCanvas)+", size "+SWTAccessor.getSizeInPixels(glCanvas));
+ System.err.println("GLCanvas window-units pos/siz.1: pos "+glCanvas.getLocation()+", size "+glCanvas.getSize());
+ System.err.println("GLCanvas LOS.1: "+SWTAccessor.getLocationOnScreen(new Point(), glCanvas));
+ }
}
- if(null != animator) {
- animator.stop();
+
+ if( !focusOnTab1 ) {
+ final PointImmutable pSashRightClient = new Point(wsize.getWidth(), 0);
+ final PointImmutable pGLWinLOS;
+ if( useNewtCanvasSWT ) {
+ final PointImmutable pNatWinLOS = newtCanvasSWT2.getNativeWindow().getLocationOnScreen(null);
+ pGLWinLOS = 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 {
+ pGLWinLOS = SWTAccessor.getLocationOnScreen(new Point(), glCanvas2);
+ System.err.println("GLCanvas LOS: "+pGLWinLOS);
+ }
+ Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 );
}
+ while( animator1.isAnimating() || animator2.isAnimating() ) {
+ final boolean keepGoing = !quitAdapter.shouldQuit() &&
+ ( animator1.isAnimating() || animator2.isAnimating() ) &&
+ ( animator1.getTotalFPSDuration()<duration || animator2.getTotalFPSDuration()<duration );
+ if( !keepGoing ) {
+ new Thread() {
+ @Override
+ public void run() {
+ animator1.stop();
+ animator2.stop();
+ }
+ }.start();
+ }
+ generalWaitAction.run();
+ }
+
+ Assert.assertFalse(animator1.isAnimating());
+ Assert.assertFalse(animator1.isStarted());
+ Assert.assertFalse(animator2.isAnimating());
+ Assert.assertFalse(animator2.isStarted());
+
try {
- display.syncExec(new Runnable() {
- public void run() {
- canvas.dispose();
- tabFolder.dispose();
- composite.dispose();
- }});
+ if( useNewtCanvasSWT ) {
+ newtCanvasSWT1.dispose();
+ glWindow1.destroy();
+ Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow1, false, null));
+ newtCanvasSWT2.dispose();
+ glWindow2.destroy();
+ Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow2, false, null));
+ } else {
+ glCanvas1.dispose();
+ glCanvas2.dispose();
+ }
}
catch( final Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
}
+
@Test
- public void test01_tabFolderParent() throws InterruptedException {
- runTestInLayout();
+ public void test01_GLCanvasTabPlainGL() throws InterruptedException {
+ if( 0 != manualTest && 1 != manualTest ) {
+ return;
+ }
+ runTestInLayout(true /* focusOnTab1 */, false /* useNewtCanvasSWT */, new GLCapabilities(GLProfile.getGL2ES2()));
}
- public static void main(final String args[]) {
+ @Test
+ public void test02_GLCanvasTabSashGL() throws InterruptedException {
+ if( 0 != manualTest && 2 != manualTest ) {
+ return;
+ }
+ runTestInLayout(false /* focusOnTab1 */, false /* useNewtCanvasSWT */, new GLCapabilities(GLProfile.getGL2ES2()));
+ }
+ @Test
+ public void test11_NewtCanvasSWTTabPlainGL() throws InterruptedException {
+ if( 0 != manualTest && 11 != manualTest ) {
+ return;
+ }
+ runTestInLayout(true /* focusOnTab1 */, true /* useNewtCanvasSWT */, new GLCapabilities(GLProfile.getGL2ES2()));
+ }
+ @Test
+ public void test12_NewtCanvasSWTTabSashGL() throws InterruptedException {
+ if( 0 != manualTest && 12 != manualTest ) {
+ return;
+ }
+ runTestInLayout(false /* focusOnTab1 */, true /* useNewtCanvasSWT */, new GLCapabilities(GLProfile.getGL2ES2()));
+ }
+
+ static int manualTest = 0;
+
+ public static void main(final String args[]) throws IOException {
+ int x=0, y=0, w=640, h=480, rw=-1, rh=-1;
+ boolean usePos = false;
+
for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- duration = MiscUtils.atoi(args[++i], duration);
+ if(args[i].equals("-test")) {
+ i++;
+ manualTest = MiscUtils.atoi(args[i], manualTest);
+ } else if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atoi(args[i], duration);
+ } else if(args[i].equals("-width")) {
+ i++;
+ w = MiscUtils.atoi(args[i], w);
+ } else if(args[i].equals("-height")) {
+ i++;
+ h = MiscUtils.atoi(args[i], h);
+ } else if(args[i].equals("-x")) {
+ i++;
+ x = MiscUtils.atoi(args[i], x);
+ usePos = true;
+ } else if(args[i].equals("-y")) {
+ i++;
+ y = MiscUtils.atoi(args[i], y);
+ usePos = true;
+ } else if(args[i].equals("-rwidth")) {
+ i++;
+ rw = MiscUtils.atoi(args[i], rw);
+ } else if(args[i].equals("-rheight")) {
+ i++;
+ rh = MiscUtils.atoi(args[i], rh);
}
}
+ wsize = new Dimension(w, h);
+ if( 0 < rw && 0 < rh ) {
+ rwsize = new Dimension(rw, rh);
+ }
+
+ if(usePos) {
+ wpos = new Point(x, y);
+ }
+ System.out.println("manualTest: "+manualTest);
System.out.println("durationPerTest: "+duration);
+ System.err.println("position "+wpos);
+ System.err.println("size "+wsize);
+ System.err.println("resize "+rwsize);
+
org.junit.runner.JUnitCore.main(TestGLCanvasSWTNewtCanvasSWTPosInTabs.class.getName());
}
}