diff options
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java | 132 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java | 30 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java | 76 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java | 31 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java | 1 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java | 90 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java) | 141 |
7 files changed, 327 insertions, 174 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java index 2da3188e2..e1a9cd51c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java @@ -38,6 +38,7 @@ import java.awt.Container; import java.awt.Frame; import javax.media.opengl.*; +import javax.swing.SwingUtilities; import com.jogamp.opengl.util.Animator; import com.jogamp.newt.opengl.*; @@ -80,7 +81,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); - Frame frame1 = new Frame("AWT Parent Frame"); + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); frame1.add(new Button("South"), BorderLayout.SOUTH); @@ -99,7 +100,11 @@ public class TestParenting01aAWT extends UITestCase { frame1.setSize(width, height); // visible test - frame1.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); @@ -139,20 +144,29 @@ public class TestParenting01aAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); - Frame frame = new Frame("AWT Parent Frame"); + final Frame frame = new Frame("AWT Parent Frame"); Assert.assertNotNull(frame); frame.setSize(width, height); // visible test - frame.setVisible(true); - - frame.add(newtCanvasAWT); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.add(newtCanvasAWT); + frame.validate(); + } + }); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); @@ -175,16 +189,25 @@ public class TestParenting01aAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - Frame frame = new Frame("AWT Parent Frame"); + final Frame frame = new Frame("AWT Parent Frame"); Assert.assertNotNull(frame); frame.setSize(width, height); // visible test - frame.setVisible(true); - - frame.add(newtCanvasAWT); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.add(newtCanvasAWT); + frame.validate(); + } + }); Animator animator1 = new Animator(glWindow1); animator1.setUpdateFPSFrames(1, null); @@ -208,14 +231,24 @@ public class TestParenting01aAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - Frame frame = new Frame("AWT Parent Frame"); + final Frame frame = new Frame("AWT Parent Frame"); frame.setSize(width, height); frame.setLocation(640, 480); - frame.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.add(newtCanvasAWT); + frame.validate(); + } + }); - frame.add(newtCanvasAWT); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); @@ -254,9 +287,9 @@ public class TestParenting01aAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - Frame frame = new Frame("AWT Parent Frame"); + final Frame frame = new Frame("AWT Parent Frame"); frame.setLayout(new BorderLayout()); frame.add(new Button("North"), BorderLayout.NORTH); frame.add(new Button("South"), BorderLayout.SOUTH); @@ -264,9 +297,20 @@ public class TestParenting01aAWT extends UITestCase { frame.add(new Button("West"), BorderLayout.WEST); frame.setSize(width, height); frame.setLocation(640, 480); - frame.setVisible(true); - - frame.add(newtCanvasAWT, BorderLayout.CENTER); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.add(newtCanvasAWT, BorderLayout.CENTER); + frame.validate(); + } + }); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); @@ -306,9 +350,9 @@ public class TestParenting01aAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - Frame frame1 = new Frame("AWT Parent Frame"); + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); frame1.add(new Button("South"), BorderLayout.SOUTH); @@ -316,9 +360,13 @@ public class TestParenting01aAWT extends UITestCase { frame1.add(new Button("West"), BorderLayout.WEST); frame1.setSize(width, height); frame1.setLocation(0, 0); - frame1.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); - Frame frame2 = new Frame("AWT Parent Frame"); + final Frame frame2 = new Frame("AWT Parent Frame"); frame2.setLayout(new BorderLayout()); frame2.add(new Button("North"), BorderLayout.NORTH); frame2.add(new Button("South"), BorderLayout.SOUTH); @@ -326,9 +374,19 @@ public class TestParenting01aAWT extends UITestCase { frame2.add(new Button("West"), BorderLayout.WEST); frame2.setSize(width, height); frame2.setLocation(640, 480); - frame2.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame2.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.validate(); + } + }); - frame1.add(newtCanvasAWT, BorderLayout.CENTER); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); @@ -340,12 +398,24 @@ public class TestParenting01aAWT extends UITestCase { Thread.sleep(durationPerTest); switch(state) { case 0: - frame1.remove(newtCanvasAWT); - frame2.add(newtCanvasAWT, BorderLayout.CENTER); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.remove(newtCanvasAWT); + frame2.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.validate(); + frame2.validate(); + } + }); break; case 1: - frame2.remove(newtCanvasAWT); - frame1.add(newtCanvasAWT, BorderLayout.CENTER); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame2.remove(newtCanvasAWT); + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame2.validate(); + frame1.validate(); + } + }); break; } state++; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java index fb93ad92f..0a0486558 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java @@ -46,6 +46,7 @@ import com.jogamp.newt.opengl.*; import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import com.jogamp.opengl.test.junit.util.*; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -64,16 +65,16 @@ public class TestParenting01bAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException { + public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException, InvocationTargetException { testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(25); } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException { + public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException, InvocationTargetException { testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(0); } - public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException { + public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); @@ -81,7 +82,7 @@ public class TestParenting01bAWT extends UITestCase { glWindow1.addGLEventListener(demo1); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); @@ -90,7 +91,11 @@ public class TestParenting01bAWT extends UITestCase { frame1.add(new Button("West"), BorderLayout.WEST); frame1.setSize(width, height); frame1.setLocation(0, 0); - frame1.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); final Frame frame2 = new Frame("AWT Parent Frame"); frame2.setLayout(new BorderLayout()); @@ -100,9 +105,18 @@ public class TestParenting01bAWT extends UITestCase { frame2.add(new Button("West"), BorderLayout.WEST); frame2.setSize(width, height); frame2.setLocation(640, 480); - frame2.setVisible(true); - - frame1.add(newtCanvasAWT, BorderLayout.CENTER); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame2.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.validate(); + } + }); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); GLAnimatorControl animator1; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java index 4477c3f8e..fa88415e4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java @@ -38,6 +38,7 @@ import java.awt.Container; import java.awt.Frame; import javax.media.opengl.*; +import javax.swing.SwingUtilities; import com.jogamp.newt.*; import com.jogamp.newt.opengl.*; @@ -74,13 +75,13 @@ public class TestParenting01cAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); - Frame frame1 = new Frame("AWT Parent Frame"); + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); frame1.add(new Button("South"), BorderLayout.SOUTH); @@ -99,20 +100,36 @@ public class TestParenting01cAWT extends UITestCase { frame1.setSize(width, height); // visible test - frame1.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); for(i=0; i*100<durationPerTest; i++) { Thread.sleep(100); } - frame1.setVisible(false); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(false); + } + }); Assert.assertEquals(true, glWindow1.isNativeValid()); - frame1.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); Assert.assertEquals(true, glWindow1.isNativeValid()); - frame1.remove(newtCanvasAWT); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.remove(newtCanvasAWT); + } + }); // Assert.assertNull(glWindow1.getParent()); Assert.assertEquals(true, glWindow1.isNativeValid()); @@ -131,9 +148,9 @@ public class TestParenting01cAWT extends UITestCase { setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - Frame frame1 = new Frame("AWT Parent Frame"); + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); frame1.add(new Button("South"), BorderLayout.SOUTH); @@ -141,9 +158,13 @@ public class TestParenting01cAWT extends UITestCase { frame1.add(new Button("West"), BorderLayout.WEST); frame1.setSize(width, height); frame1.setLocation(0, 0); - frame1.setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); - Frame frame2 = new Frame("AWT Parent Frame"); + final Frame frame2 = new Frame("AWT Parent Frame"); frame2.setLayout(new BorderLayout()); frame2.add(new Button("North"), BorderLayout.NORTH); frame2.add(new Button("South"), BorderLayout.SOUTH); @@ -151,9 +172,18 @@ public class TestParenting01cAWT extends UITestCase { frame2.add(new Button("West"), BorderLayout.WEST); frame2.setSize(width, height); frame2.setLocation(640, 480); - frame2.setVisible(true); - - frame1.add(newtCanvasAWT, BorderLayout.CENTER); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame2.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.validate(); + } + }); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); int state; @@ -161,12 +191,24 @@ public class TestParenting01cAWT extends UITestCase { Thread.sleep(durationPerTest); switch(state) { case 0: - frame1.remove(newtCanvasAWT); - frame2.add(newtCanvasAWT, BorderLayout.CENTER); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame1.remove(newtCanvasAWT); + frame2.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.validate(); + frame2.validate(); + } + }); break; case 1: - frame2.remove(newtCanvasAWT); - frame1.add(newtCanvasAWT, BorderLayout.CENTER); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame2.remove(newtCanvasAWT); + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.validate(); + frame2.validate(); + } + }); break; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 478e00007..5a324c647 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -129,7 +129,13 @@ public class TestParenting01cSwingAWT extends UITestCase { jFrame1.setContentPane(jPanel1); jFrame1.setSize(width, height); System.out.println("Demos: 1 - Visible"); - jFrame1.setVisible(true); // from here on, we need to run modifications on EDT + SwingUtilities.invokeLater(new Runnable() { + public void run() { + jFrame1.setVisible(true); + } + }); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); // visible test Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); @@ -143,25 +149,24 @@ public class TestParenting01cSwingAWT extends UITestCase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.out.println("Demos: 3 - !Visible"); + System.out.println("Demos: 3 - !Visible"); jFrame1.setVisible(false); } }); - Assert.assertEquals(true, glWindow1.isNativeValid()); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, false)); SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.out.println("Demos: 4 - Visible"); + System.out.println("Demos: 4 - Visible"); jFrame1.setVisible(true); } }); - Assert.assertEquals(true, glWindow1.isNativeValid()); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.out.println("Demos: 5 - X Container"); + System.out.println("Demos: 5 - X Container"); jPanel1.remove(container1); jFrame1.validate(); } }); - // Assert.assertNull(glWindow1.getParent()); Assert.assertEquals(true, glWindow1.isNativeValid()); SwingUtilities.invokeAndWait(new Runnable() { @@ -236,7 +241,11 @@ public class TestParenting01cSwingAWT extends UITestCase { jFrame1.setContentPane(jPanel1); jFrame1.setLocation(0, 0); jFrame1.setSize(width, height); - jFrame1.setVisible(true); // from here on, we need to run modifications on EDT + SwingUtilities.invokeLater(new Runnable() { + public void run() { + jFrame1.setVisible(true); + } + }); final JPanel jPanel2 = new JPanel(); jPanel2.setLayout(new BorderLayout()); @@ -251,7 +260,11 @@ public class TestParenting01cSwingAWT extends UITestCase { jFrame2.setContentPane(jPanel2); jFrame2.setLocation(640, 480); jFrame2.setSize(width, height); - jFrame2.setVisible(true); // from here on, we need to run modifications on EDT + SwingUtilities.invokeLater(new Runnable() { + public void run() { + jFrame2.setVisible(true); + } + }); // visible test Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java index 3ce1f5079..bd3e3f7ed 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java @@ -221,6 +221,7 @@ public class TestParenting02AWT extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.remove(newtCanvasAWT); + frame.validate(); }}); } frame.dispose(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 2ce622312..56ae21e2a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -44,7 +44,6 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import com.jogamp.newt.*; -import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; import com.jogamp.newt.awt.NewtCanvasAWT; @@ -55,78 +54,91 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; public class TestParenting03AWT extends UITestCase { static Dimension size; - static long durationPerTest = 400; - static long waitAdd2nd = 200; + static long durationPerTest = 800; + static long waitAdd2nd = 500; static GLCapabilities glCaps; @BeforeClass public static void initClass() { size = new Dimension(400,200); glCaps = new GLCapabilities(null); - glCaps.setAlphaBits(8); - glCaps.setBackgroundOpaque(false); } @Test - public void testWindowParenting1AWTOneNewtChild01() throws InterruptedException, InvocationTargetException { - testWindowParenting1AWTOneNewtChild(); + public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException { + testWindowParenting1AWTTwoNewtChilds(); } - public void testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException { + public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException { + final Frame frame1 = new Frame("AWT Parent Frame"); GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUpdateFPSFrames(1, null); - glWindow1.setUndecorated(true); - NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); + final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); newtCanvasAWT1.setPreferredSize(size); GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - final NewtCanvasAWT f_newtCanvasAWT1 = newtCanvasAWT1; - final GLWindow f_glWindow1 = glWindow1; - glWindow1.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='d') { - f_glWindow1.setUndecorated(!f_glWindow1.isUndecorated()); - } else if(e.getKeyChar()=='f') { - f_glWindow1.setFullscreen(!f_glWindow1.isFullscreen()); - } else if(e.getKeyChar()=='r') { - if(f_glWindow1.getParent()==null) { - System.err.println("XXX glWin1 to home"); - f_glWindow1.reparentWindow(f_newtCanvasAWT1.getNativeWindow()); - } else { - System.err.println("XXX glWin1 to TOP"); - f_glWindow1.reparentWindow(null); - } - } - } - }); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); GLAnimatorControl animator1 = new Animator(glWindow1); animator1.start(); - Container cont1 = new Container(); + GLWindow glWindow2 = GLWindow.create(glCaps); + glWindow2.setUpdateFPSFrames(1, null); + NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); + newtCanvasAWT2.setPreferredSize(size); + + GLEventListener demo2 = new GearsES2(1); + setDemoFields(demo2, glWindow2, false); + glWindow2.addGLEventListener(demo2); + glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2)); + GLAnimatorControl animator2 = new Animator(glWindow2); + animator2.start(); + + final Container cont1 = new Container(); cont1.setLayout(new BorderLayout()); cont1.add(newtCanvasAWT1, BorderLayout.CENTER); + System.err.println("******* Cont1 setVisible"); cont1.setVisible(true); - Frame frame1 = new Frame("AWT Parent Frame"); + final Container cont2 = new Container(); + cont2.setLayout(new BorderLayout()); + cont2.add(newtCanvasAWT2, BorderLayout.CENTER); + System.err.println("******* Cont2 setVisible"); + cont2.setVisible(true); + frame1.setLayout(new BorderLayout()); + frame1.add(new Label("NORTH"), BorderLayout.NORTH); + frame1.add(new Label("CENTER"), BorderLayout.CENTER); + frame1.add(new Label("SOUTH"), BorderLayout.SOUTH); frame1.add(cont1, BorderLayout.EAST); - frame1.add(new Label("center"), BorderLayout.CENTER); frame1.setLocation(0, 0); - frame1.setSize((int)size.getWidth(), (int)size.getHeight()); - final Frame f_frame1 = frame1; + frame1.setSize((int)size.getWidth()*3, (int)size.getHeight()*2); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - f_frame1.pack(); - f_frame1.setVisible(true); + System.err.println("******* Frame setVisible"); + frame1.setVisible(true); }}); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); + Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent()); + Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); + Assert.assertEquals(true, animator2.isAnimating()); + Assert.assertEquals(false, animator2.isPaused()); + Assert.assertNotNull(animator2.getThread()); + + Thread.sleep(waitAdd2nd); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.add(cont2, BorderLayout.WEST); + frame1.validate(); + }}); + Thread.sleep(durationPerTest); animator1.stop(); @@ -134,8 +146,14 @@ public class TestParenting03AWT extends UITestCase { Assert.assertEquals(false, animator1.isPaused()); Assert.assertEquals(null, animator1.getThread()); + animator2.stop(); + Assert.assertEquals(false, animator2.isAnimating()); + Assert.assertEquals(false, animator2.isPaused()); + Assert.assertEquals(null, animator2.getThread()); + frame1.dispose(); glWindow1.destroy(); + glWindow2.destroy(); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java index 46a63dc14..be812e6aa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java @@ -28,120 +28,121 @@ package com.jogamp.opengl.test.junit.newt.parenting; -import java.lang.reflect.*; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.Label; +import java.awt.Transparency; +import java.awt.image.ColorModel; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; -import javax.media.opengl.*; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; -import com.jogamp.opengl.util.Animator; -import com.jogamp.newt.*; -import com.jogamp.newt.opengl.*; -import com.jogamp.newt.awt.NewtCanvasAWT; - -import java.io.IOException; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; -import com.jogamp.opengl.test.junit.util.*; +import com.jogamp.newt.Window; +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; 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.UITestCase; +import com.jogamp.opengl.util.Animator; -public class TestParenting03bAWT extends UITestCase { +public class TestTranslucentParentingAWT extends UITestCase { static Dimension size; - static long durationPerTest = 800; - static long waitAdd2nd = 500; + static long durationPerTest = 400; + static long waitAdd2nd = 200; static GLCapabilities glCaps; @BeforeClass public static void initClass() { size = new Dimension(400,200); glCaps = new GLCapabilities(null); + glCaps.setAlphaBits(8); + glCaps.setBackgroundOpaque(false); } @Test - public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException { - testWindowParenting1AWTTwoNewtChilds(); + public void testWindowParenting1AWTOneNewtChild01() throws InterruptedException, InvocationTargetException { + testWindowParenting1AWTOneNewtChild(); } - public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException { - Frame frame1 = new Frame("AWT Parent Frame"); - GLWindow glWindow1 = GLWindow.create(glCaps); + static Frame getTranslucentFrame() { + GraphicsConfiguration gc=null; + GraphicsDevice[] devices= GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + for (int i = 0; i < devices.length ; i++) + { + GraphicsConfiguration[] configs = devices[i].getConfigurations(); + for (int j = 0; j < configs.length ; j++) { + GraphicsConfiguration config = configs[j]; + ColorModel tcm = config.getColorModel(Transparency.TRANSLUCENT); + boolean capable1 = ( null != tcm ) ? tcm.getTransparency() == Transparency.TRANSLUCENT : false; + boolean capable2 = false; + try { + capable2 = com.sun.awt.AWTUtilities.isTranslucencyCapable(config); + } catch (Exception e) {} + System.err.println(i+":"+j+" "+config+", "+tcm+", capable "+capable1+"/"+capable2); + if(capable1&&capable2) { + gc=configs[j]; + System.err.println("Chosen "+i+":"+j+" "+config+", "+tcm+", capable "+capable1+"/"+capable2); + break; + } + } + } + final Frame frame = new Frame(gc); + if(null!=gc) { + frame.setUndecorated(true); + frame.setBackground(new Color(0, 0, 0, 0)); + } + frame.setTitle("AWT Parent Frame (opaque: "+(null==gc)+")"); + return frame; + } + + public void testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException { + final Frame frame1 = getTranslucentFrame(); + final GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUpdateFPSFrames(1, null); - NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); + glWindow1.setUndecorated(true); + final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(frame1.getGraphicsConfiguration(), glWindow1); newtCanvasAWT1.setPreferredSize(size); GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); GLAnimatorControl animator1 = new Animator(glWindow1); animator1.start(); - GLWindow glWindow2 = GLWindow.create(glCaps); - glWindow2.setUpdateFPSFrames(1, null); - NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); - newtCanvasAWT2.setPreferredSize(size); - - GLEventListener demo2 = new GearsES2(1); - setDemoFields(demo2, glWindow2, false); - glWindow2.addGLEventListener(demo2); - glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2)); - GLAnimatorControl animator2 = new Animator(glWindow2); - animator2.start(); - Container cont1 = new Container(); cont1.setLayout(new BorderLayout()); cont1.add(newtCanvasAWT1, BorderLayout.CENTER); - System.err.println("******* Cont1 setVisible"); cont1.setVisible(true); - Container cont2 = new Container(); - cont2.setLayout(new BorderLayout()); - cont2.add(newtCanvasAWT2, BorderLayout.CENTER); - System.err.println("******* Cont2 setVisible"); - cont2.setVisible(true); - final Container f_cont2 = cont2; - frame1.setLayout(new BorderLayout()); - frame1.add(new Label("NORTH"), BorderLayout.NORTH); - frame1.add(new Label("CENTER"), BorderLayout.CENTER); - frame1.add(new Label("SOUTH"), BorderLayout.SOUTH); frame1.add(cont1, BorderLayout.EAST); + frame1.add(new Label("center"), BorderLayout.CENTER); frame1.setLocation(0, 0); - frame1.setSize((int)size.getWidth()*2, (int)size.getHeight()*2); - final Frame f_frame1 = frame1; + frame1.setSize((int)size.getWidth(), (int)size.getHeight()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - f_frame1.pack(); - System.err.println("******* Frame setVisible"); - f_frame1.setVisible(true); + frame1.pack(); + frame1.setVisible(true); }}); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent()); - Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); - Assert.assertEquals(true, animator2.isAnimating()); - Assert.assertEquals(false, animator2.isPaused()); - Assert.assertNotNull(animator2.getThread()); - - Thread.sleep(waitAdd2nd); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f_frame1.add(f_cont2, BorderLayout.WEST); - f_frame1.pack(); - }}); - Thread.sleep(durationPerTest); animator1.stop(); @@ -149,14 +150,8 @@ public class TestParenting03bAWT extends UITestCase { Assert.assertEquals(false, animator1.isPaused()); Assert.assertEquals(null, animator1.getThread()); - animator2.stop(); - Assert.assertEquals(false, animator2.isAnimating()); - Assert.assertEquals(false, animator2.isPaused()); - Assert.assertEquals(null, animator2.getThread()); - frame1.dispose(); glWindow1.destroy(); - glWindow2.destroy(); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { @@ -188,7 +183,7 @@ public class TestParenting03bAWT extends UITestCase { waitAdd2nd = atoi(args[++i]); } } - String tstname = TestParenting03bAWT.class.getName(); + String tstname = TestTranslucentParentingAWT.class.getName(); /* org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { tstname, |