diff options
author | Sven Gothel <[email protected]> | 2020-01-05 22:57:14 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-01-05 22:57:14 +0100 |
commit | 9512a4bbda02002d06fcbb34504c3bea9c7abdc8 (patch) | |
tree | 39cef3462a311f00aec1ada14891a7aa0ba7aaf9 /src | |
parent | 741e62820299bc384741d692e2665d22d97c1970 (diff) |
Bug 1421, Bug 1358, Bug 969, Bug 672: Generalization of test case TestGLCanvasSWTNewtCanvasSWTPosInTabs (1/2)
Testing the TabFolder and a SashForm in the 2nd tab
covering both SWT layout use cases on both out SWT support classes SWT GLCanvas and NewtCanvasSWT.
Merging TestBug1421NewtCanvasSWTPosInTabs + TestBug672NewtCanvasSWTSashFormComposite
into TestGLCanvasSWTNewtCanvasSWTPosInTabs.
TestBug672NewtCanvasSWTSashFormComposite exposes that SWT GLCanvas
still requires work for proper High-DPI scaling on OSX!
Diffstat (limited to 'src')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java | 175 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug1421NewtCanvasSWTPosInTabs.java) | 12 |
2 files changed, 118 insertions, 69 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java index fd6a3691c..baad0da2a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java @@ -40,6 +40,7 @@ import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.swt.NewtCanvasSWT; 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.UITestCase; @@ -52,9 +53,11 @@ import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.Point; import com.jogamp.nativewindow.util.PointImmutable; import com.jogamp.nativewindow.util.DimensionImmutable; +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 org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -171,60 +174,77 @@ public class TestBug672NewtCanvasSWTSashFormComposite extends UITestCase { } } } - final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE); + final WaitAction waitAction = new WaitAction(AWTRobotUtil.TIME_SLICE); final WaitAction generalWaitAction = new WaitAction(10); - protected void runTestGL(final GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { + protected void runTestGL(final boolean useNewtCanvasSWT, final GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { final com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, screenIdx); - final GLWindow glWindow = GLWindow.create(screen, caps); - Assert.assertNotNull(glWindow); + final GLWindow glWindow; + final GLCanvas glCanvas; + final GLAutoDrawable glad; + final NewtCanvasSWT newtCanvasSWT; + if( useNewtCanvasSWT ) { + glWindow = GLWindow.create(screen, caps); + glad = glWindow; + glCanvas = null; + Assert.assertNotNull(glWindow); + newtCanvasSWT = NewtCanvasSWT.create( innerComposite, 0, glWindow ); + Assert.assertNotNull( newtCanvasSWT ); + } else { + glCanvas = GLCanvas.create( innerComposite, 0, caps, null); + glad = glCanvas; + glWindow = null; + Assert.assertNotNull(glCanvas); + newtCanvasSWT = null; + } + Assert.assertNotNull(glad); final GearsES2 demo = new GearsES2(1); - glWindow.addGLEventListener(demo); + glad.addGLEventListener(demo); final Animator animator = new Animator(); animator.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD); final QuitAdapter quitAdapter = new QuitAdapter(); - //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); - //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - - glWindow.addWindowListener(new WindowAdapter() { - public void windowResized(final WindowEvent e) { - System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); - } - public void windowMoved(final WindowEvent e) { - System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); - } - }); - - glWindow.addKeyListener(new KeyAdapter() { - public void keyReleased(final KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; + if( useNewtCanvasSWT ) { + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(final WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); } - 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); - } } ); + public void windowMoved(final WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); } - } - }); + }); + + glWindow.addKeyListener(new KeyAdapter() { + public void keyReleased(final KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } + 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); + } } ); + } + } + }); + } - animator.add(glWindow); + animator.add(glad); animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); animator.setUpdateFPSFrames(60, null); - final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( innerComposite, 0, glWindow ); - Assert.assertNotNull( canvas1 ); display.syncExec( new Runnable() { public void run() { @@ -236,14 +256,21 @@ public class TestBug672NewtCanvasSWTSashFormComposite extends UITestCase { shell.open(); } }); - Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(glWindow, true, awtRobotWaitAction)); - Assert.assertNotNull( canvas1.getNativeWindow() ); - - 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)); - System.err.println("NewtCanvasSWT LOS.0: "+canvas1.getNativeWindow().getLocationOnScreen(null)); + if( useNewtCanvasSWT ) { + 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 { + 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(glad, true, waitAction)); if( null != rwsize ) { for(int i=0; i<50; i++) { // 500 ms dispatched delay @@ -254,20 +281,32 @@ public class TestBug672NewtCanvasSWTSashFormComposite extends UITestCase { shell.setSize( rwsize.getWidth(), rwsize.getHeight() ); } }); - 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: "+canvas1.getNativeWindow().getLocationOnScreen(null)); + if( useNewtCanvasSWT ) { + 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 { + 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)); + } } - final PointImmutable pSashRightClient = new Point(wsize.getWidth(), 0); - final PointImmutable pNatWinLOS = canvas1.getNativeWindow().getLocationOnScreen(null); - final PointImmutable pGLWinLOS = glWindow.getLocationOnScreen(null); - - System.err.println("GLWindow LOS: "+pGLWinLOS); - System.err.println("NewtCanvasSWT LOS: "+pNatWinLOS); - - Assert.assertTrue( "NewtCanvasAWT LOS "+pNatWinLOS+" not >= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 ); - Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 ); + { + final PointImmutable pSashRightClient = new Point(wsize.getWidth(), 0); + final PointImmutable pGLWinLOS; + if( useNewtCanvasSWT ) { + final PointImmutable pNatWinLOS = newtCanvasSWT.getNativeWindow().getLocationOnScreen(null); + pGLWinLOS = glWindow.getLocationOnScreen(null); + System.err.println("GLWindow LOS: "+pGLWinLOS); + System.err.println("NewtCanvasSWT LOS: "+pNatWinLOS); + Assert.assertTrue( "NewtCanvasAWT LOS "+pNatWinLOS+" not >= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 ); + } else { + pGLWinLOS = SWTAccessor.getLocationOnScreen(new Point(), glCanvas); + System.err.println("GLCanvas LOS: "+pGLWinLOS); + } + Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 ); + } while( !quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration ) { generalWaitAction.run(); @@ -276,18 +315,28 @@ public class TestBug672NewtCanvasSWTSashFormComposite extends UITestCase { animator.stop(); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); - Assert.assertEquals(null, glWindow.getExclusiveContextThread()); - canvas1.dispose(); - glWindow.destroy(); - Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow, false, null)); + if( useNewtCanvasSWT ) { + newtCanvasSWT.dispose(); + glWindow.destroy(); + Assert.assertEquals(true, NewtTestUtil.waitForRealized(glWindow, false, null)); + } else { + glCanvas.dispose(); + } + } + + @Test + public void test01_SashFormNewtCanvasSWT() throws InterruptedException, InvocationTargetException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities( glp ); + runTestGL(true /* NewtCanvasSWT */, caps); } @Test - public void test01() throws InterruptedException, InvocationTargetException { + public void test02_SashFormGLCanvas() throws InterruptedException, InvocationTargetException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities( glp ); - runTestGL(caps); + runTestGL(false /* NewtCanvasSWT */, caps); } public static void main(final String args[]) throws IOException { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug1421NewtCanvasSWTPosInTabs.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java index f71e078f3..69e1b7fda 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug1421NewtCanvasSWTPosInTabs.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java @@ -71,7 +71,7 @@ import com.jogamp.opengl.util.FPSAnimator; * This issue does not occur on GNU/Linux GTK nor on Windows.
* </p>
*/
-public class TestBug1421NewtCanvasSWTPosInTabs {
+public class TestGLCanvasSWTNewtCanvasSWTPosInTabs {
static int duration = 250;
Display display = null;
@@ -135,7 +135,7 @@ public class TestBug1421NewtCanvasSWTPosInTabs { }
}
}
- final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE);
+ final WaitAction waitAction = new WaitAction(AWTRobotUtil.TIME_SLICE);
final WaitAction generalWaitAction = new WaitAction(10);
protected void runTestInLayout() throws InterruptedException {
@@ -149,9 +149,9 @@ public class TestBug1421NewtCanvasSWTPosInTabs { tabFolder.setBorderVisible(true);
tabFolder.setLayoutData(new FillLayout());
final CTabItem tabItem1 = new CTabItem(tabFolder, SWT.NONE, 0);
- tabItem1.setText("GLTab");
+ tabItem1.setText("GLTab1");
final CTabItem tabItem2 = new CTabItem(tabFolder, SWT.NONE, 1);
- tabItem2.setText("Tab");
+ tabItem2.setText("GLTab2");
// Get the default OpenGL profile, reflecting the best for your running platform
final GLProfile glp = GLProfile.getDefault();
@@ -195,7 +195,7 @@ public class TestBug1421NewtCanvasSWTPosInTabs { shell.open();
}
});
- Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(window, true, awtRobotWaitAction));
+ Assert.assertTrue("GLWindow didn't become visible natively!", NewtTestUtil.waitForRealized(window, true, waitAction));
final long lStartTime = System.currentTimeMillis();
final long lEndTime = lStartTime + duration;
@@ -235,6 +235,6 @@ public class TestBug1421NewtCanvasSWTPosInTabs { }
}
System.out.println("durationPerTest: "+duration);
- org.junit.runner.JUnitCore.main(TestBug1421NewtCanvasSWTPosInTabs.class.getName());
+ org.junit.runner.JUnitCore.main(TestGLCanvasSWTNewtCanvasSWTPosInTabs.class.getName());
}
}
|