From d2ec9f34cf2b3a54c80e2e23671d8fa8a5397d5d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Oct 2010 04:01:56 +0200 Subject: Tests: Accomodate previous changes plus using AWT EDT for setVisible() as well. --- .../jogamp/test/junit/jogl/awt/TestAWT01GLn.java | 19 ++- .../junit/jogl/awt/TestAWT02WindowClosing.java | 11 +- ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 2 +- .../demos/gl2/gears/TestGearsNewtAWTWrapper.java | 6 +- .../junit/jogl/offscreen/TestOffscreen01NEWT.java | 2 +- .../junit/newt/TestDisplayLifecycle01NEWT.java | 4 +- .../test/junit/newt/TestGLWindows01NEWT.java | 6 +- .../junit/newt/TestGLWindows02NEWTAnimated.java | 12 +- .../junit/newt/parenting/TestParenting01NEWT.java | 156 +++++---------------- .../junit/newt/parenting/TestParenting03AWT.java | 6 +- .../junit/newt/parenting/TestParenting03bAWT.java | 6 +- 11 files changed, 81 insertions(+), 149 deletions(-) (limited to 'src') diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java index 006010eeb..f3c228a5d 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java @@ -66,14 +66,17 @@ public class TestAWT01GLn extends UITestCase { public void release() { Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas); - frame.setVisible(false); try { - frame.remove(glCanvas); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glCanvas); + frame.dispose(); + }}); } catch (Throwable t) { t.printStackTrace(); Assume.assumeNoException(t); } - frame.dispose(); frame=null; glCanvas=null; } @@ -88,8 +91,16 @@ public class TestAWT01GLn extends UITestCase { glCanvas.display(); // one in process display + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(true); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } Animator animator = new Animator(glCanvas); - frame.setVisible(true); animator.start(); Thread.sleep(500); // 500 ms diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java index 9e8cb916a..6132f8232 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT02WindowClosing.java @@ -56,7 +56,16 @@ public class TestAWT02WindowClosing extends UITestCase { frame.setSize(500, 500); ClosingWindowAdapter closingWindowAdapter = new ClosingWindowAdapter(frame); frame.addWindowListener(closingWindowAdapter); - frame.setVisible(true); + final Frame _frame = frame; + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _frame.setVisible(true); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } Thread.sleep(durationPerTest); if(!closingWindowAdapter.closingCalled) { diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java index fd1a15e52..3e54e1c8e 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java @@ -148,13 +148,13 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { frame.setSize(512, 512); frame.setLocation(0, 0); frame.pack(); - frame.setVisible(true); // AWT/Swing: From here on (post setVisible(true) // you need to use AWT/Swing's invokeAndWait() javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { + frame.setVisible(true); colorPanel.setBackground(Color.white); colorPanel.repaint(); }}); diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java index 27c353942..be1e5a58b 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java @@ -63,9 +63,9 @@ public class TestGearsNewtAWTWrapper extends UITestCase { } protected void runTestGL(GLCapabilities caps) throws InterruptedException { - Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display - Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0 - Window nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps); + Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null, false); // local display + Screen nScreen = NewtFactory.createScreen(nDisplay, 0); // screen 0 + Window nWindow = NewtFactory.createWindow(nScreen, caps); GLWindow glWindow = GLWindow.create(nWindow); Assert.assertNotNull(glWindow); diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java index 1d699a1aa..ea77b2876 100644 --- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java @@ -251,7 +251,7 @@ public class TestOffscreen01NEWT extends UITestCase { for(i=0; i= reparentAction) { - Assert.assertNotSame(screen1,glWindow2.getScreen()); - Assert.assertNotSame(display1,glWindow2.getScreen().getDisplay()); - Assert.assertEquals(1,screen1.getReferenceCount()); - Assert.assertEquals(1,display2.getReferenceCount()); - Assert.assertEquals(true,display2.isNativeValid()); - Assert.assertEquals(true,display2.getEDTUtil().isRunning()); - Assert.assertEquals(1,screen2.getReferenceCount()); - Assert.assertEquals(true,screen2.isNativeValid()); - Assert.assertEquals(2,Display.getActiveDisplayNumber()); - } else { - Assert.assertSame(screen1,glWindow2.getScreen()); - Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); - Assert.assertEquals(2,screen1.getReferenceCount()); - Assert.assertEquals(0,display2.getReferenceCount()); - Assert.assertEquals(false,display2.isNativeValid()); - Assert.assertEquals(false,display2.getEDTUtil().isRunning()); - Assert.assertEquals(0,screen2.getReferenceCount()); - Assert.assertEquals(false,screen2.isNativeValid()); - Assert.assertEquals(1,Display.getActiveDisplayNumber()); - } + Assert.assertSame(screen1,glWindow2.getScreen()); + Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); + Assert.assertEquals(2,screen1.getReferenceCount()); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); break; @@ -478,7 +439,7 @@ public class TestParenting01NEWT extends UITestCase { reparentAction = glWindow2.reparentWindow(null, reparentRecreate); Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction); - for(wait=0; wait<10 && glWindow2.getTotalFrames()<1; wait++) { Thread.sleep(100); } + for(wait=0; wait= reparentAction) { - Assert.assertNotSame(screen1,glWindow2.getScreen()); - Assert.assertNotSame(display1,glWindow2.getScreen().getDisplay()); - Assert.assertEquals(1,screen1.getReferenceCount()); - Assert.assertEquals(1,display2.getReferenceCount()); - Assert.assertEquals(true,display2.isNativeValid()); - Assert.assertEquals(true,display2.getEDTUtil().isRunning()); - Assert.assertEquals(1,screen2.getReferenceCount()); - Assert.assertEquals(true,screen2.isNativeValid()); - Assert.assertEquals(2,Display.getActiveDisplayNumber()); - } else { - Assert.assertSame(screen1,glWindow2.getScreen()); - Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); - Assert.assertEquals(2,screen1.getReferenceCount()); - Assert.assertEquals(0,display2.getReferenceCount()); - Assert.assertEquals(false,display2.isNativeValid()); - Assert.assertEquals(false,display2.getEDTUtil().isRunning()); - Assert.assertEquals(0,screen2.getReferenceCount()); - Assert.assertEquals(false,screen2.isNativeValid()); - Assert.assertEquals(1,Display.getActiveDisplayNumber()); - } + Assert.assertSame(screen1,glWindow2.getScreen()); + Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); + Assert.assertEquals(2,screen1.getReferenceCount()); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); break; } @@ -531,26 +474,9 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true,display1.isNativeValid()); Assert.assertNotNull(display1.getEDTUtil()); Assert.assertEquals(true,display1.getEDTUtil().isRunning()); - Assert.assertNotNull(display2.getEDTUtil()); - if(!reparentRecreate) { - Assert.assertEquals(1,screen1.getReferenceCount()); - Assert.assertEquals(true,screen1.isNativeValid()); - Assert.assertEquals(1,display2.getReferenceCount()); - Assert.assertEquals(true,display2.isNativeValid()); - Assert.assertEquals(true,display2.getEDTUtil().isRunning()); - Assert.assertEquals(1,screen2.getReferenceCount()); - Assert.assertEquals(true,screen2.isNativeValid()); - Assert.assertEquals(2,Display.getActiveDisplayNumber()); - } else { - Assert.assertEquals(2,screen1.getReferenceCount()); - Assert.assertEquals(true,screen1.isNativeValid()); - Assert.assertEquals(0,display2.getReferenceCount()); - Assert.assertEquals(false,display2.isNativeValid()); - Assert.assertEquals(false,display2.getEDTUtil().isRunning()); - Assert.assertEquals(0,screen2.getReferenceCount()); - Assert.assertEquals(false,screen2.isNativeValid()); - Assert.assertEquals(1,Display.getActiveDisplayNumber()); - } + Assert.assertEquals(2,screen1.getReferenceCount()); + Assert.assertEquals(true,screen1.isNativeValid()); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); // destroy glWindow2 glWindow2.destroy(true); @@ -564,13 +490,6 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(1,screen1.getReferenceCount()); Assert.assertEquals(true,screen1.isNativeValid()); - Assert.assertEquals(0,display2.getReferenceCount()); - Assert.assertEquals(false,display2.isNativeValid()); - Assert.assertNotNull(display2.getEDTUtil()); - Assert.assertEquals(false,display2.getEDTUtil().isRunning()); - Assert.assertEquals(0,screen2.getReferenceCount()); - Assert.assertEquals(false,screen2.isNativeValid()); - Assert.assertEquals(1,Display.getActiveDisplayNumber()); // destroy glWindow1 @@ -585,13 +504,6 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(0,screen1.getReferenceCount()); Assert.assertEquals(false,screen1.isNativeValid()); - Assert.assertEquals(0,display2.getReferenceCount()); - Assert.assertEquals(false,display2.isNativeValid()); - Assert.assertNotNull(display2.getEDTUtil()); - Assert.assertEquals(false,display2.getEDTUtil().isRunning()); - Assert.assertEquals(0,screen2.getReferenceCount()); - Assert.assertEquals(false,screen2.isNativeValid()); - Assert.assertEquals(0,Display.getActiveDisplayNumber()); } @@ -659,7 +571,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(0, glWindow2.getTotalFrames()); glWindow1.setVisible(true); int wait; - for(wait=0; wait<10 && ( glWindow2.getTotalFrames()<1 || glWindow1.getTotalFrames()<1 ); wait++) { + for(wait=0; wait