diff options
author | Sven Gothel <[email protected]> | 2010-10-27 16:39:20 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-10-27 16:39:20 +0200 |
commit | e6225fce71daa90a2a2b631550ba048c2a84ff25 (patch) | |
tree | 863985817e72b5b9fc855de3be4f2154fa86dedf /src/junit/com/jogamp/test | |
parent | e6131c6b2cbf8d1e5a05f0343612f5083b55aaa9 (diff) |
WindowImpl/GLWindow LifecycleHook:
- 'destroyAction' -> 'destroyActionPreLock' 'destroyActionInLock',
to be able to stop animation before locking.
GLDrawableHelper.invokeGL() dispose case (initAction == null):
- pause animator if animating before makeCurrent (locking)
GLCanvas/GLJPanel dispose: recreate case
- resume animator if was animating
Diffstat (limited to 'src/junit/com/jogamp/test')
3 files changed, 65 insertions, 56 deletions
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 62fc02251..e77f4f8b0 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java @@ -28,7 +28,6 @@ package com.jogamp.test.junit.jogl.awt; -import com.jogamp.test.junit.util.UITestCase; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import com.jogamp.test.junit.util.*; @@ -43,19 +42,15 @@ import com.jogamp.newt.Screen; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.awt.NewtCanvasAWT; -import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt.AWTException; -import java.awt.LayoutManager; import java.awt.Robot; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.InputEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; @@ -68,7 +63,6 @@ import javax.swing.BorderFactory; import javax.swing.border.Border; import org.junit.Assert; -import org.junit.Assume; import org.junit.BeforeClass; import org.junit.AfterClass; import org.junit.Test; @@ -238,12 +232,10 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { } robot.mouseRelease(InputEvent.BUTTON1_MASK); - for(int i=0; !windowClosing && i<durationPerTest/10; i++) { - Thread.sleep(10); + for(int i=0; !windowClosing && i<durationPerTest/100; i++) { + Thread.sleep(100); } - animator.stop(); - Assert.assertNotNull(canvas); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -251,11 +243,13 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { frame.pack(); } }); + Assert.assertEquals(false, animator.isAnimating()); } @Test - public void test01GLCanvas() throws AWTException, InterruptedException, InvocationTargetException { - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test01GLCanvas(): Start"); + public void test01NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test01NewtCanvasAWT(): Start"); + GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); @@ -268,45 +262,40 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { Animator anim0 = new Animator(win0); anim0.start(); - GLCanvas glCanvas = new GLCanvas(caps); + NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(GLWindow.create(caps)); - runTestGL(glCanvas, glCanvas); + runTestGL(newtCanvasAWT, (GLAutoDrawable)newtCanvasAWT.getNEWTChild()); - anim0.stop(); win0.destroy(true); - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test01GLCanvas(): End"); + Assert.assertEquals(false, anim0.isAnimating()); + + newtCanvasAWT.destroy(true); + + System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test01NewtCanvasAWT(): End"); } @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test02NewtCanvasAWT(): Start"); - + public void test02GLCanvas() throws AWTException, InterruptedException, InvocationTargetException { + System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test02GLCanvas(): Start"); GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); - GLWindow winDummy = GLWindow.create(caps); - winDummy.addGLEventListener(new Gears()); - GLWindow win0 = GLWindow.create(caps); win0.setSize(100,100); win0.setVisible(true); Screen screen = win0.getScreen(); win0.setPosition(screen.getWidth()-150, screen.getHeight()-150); win0.addGLEventListener(new Gears()); - Animator anim0 = new Animator(win0); + Animator anim0 = new Animator(win0); anim0.start(); - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(GLWindow.create(caps)); + GLCanvas glCanvas = new GLCanvas(caps); - runTestGL(newtCanvasAWT, (GLAutoDrawable)newtCanvasAWT.getNEWTChild()); - newtCanvasAWT.destroy(true); + runTestGL(glCanvas, glCanvas); - anim0.stop(); win0.destroy(true); - - winDummy.destroy(true); - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test02NewtCanvasAWT(): End"); + Assert.assertEquals(false, anim0.isAnimating()); + System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test02GLCanvas(): End"); } static int atoi(String a) { diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java index 73d962dfa..f136b2a3c 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java @@ -253,16 +253,14 @@ public class TestGLWindows01NEWT extends UITestCase { Assert.assertNotNull(display); display.setDestroyWhenUnused(true); - Screen screen1 = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen1); - GLWindow window1 = createWindow(screen1, caps, width, height, + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + GLWindow window1 = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */, false /*addGLEventListenerAfterVisible*/); Assert.assertNotNull(window1); - Screen screen2 = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen2); - GLWindow window2 = createWindow(screen2, caps, width, height, + GLWindow window2 = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */, false /*addGLEventListenerAfterVisible*/); Assert.assertNotNull(window2); @@ -274,11 +272,8 @@ public class TestGLWindows01NEWT extends UITestCase { Assert.assertNotNull(display.getEDTUtil()); Assert.assertEquals(true,display.getEDTUtil().isRunning()); - Assert.assertEquals(1,screen1.getReferenceCount()); - Assert.assertEquals(true,screen1.isNativeValid()); - - Assert.assertEquals(1,screen2.getReferenceCount()); - Assert.assertEquals(true,screen2.isNativeValid()); + Assert.assertEquals(2,screen.getReferenceCount()); + Assert.assertEquals(true,screen.isNativeValid()); int state; for(state=0; state*100<durationPerTest; state++) { @@ -297,11 +292,8 @@ public class TestGLWindows01NEWT extends UITestCase { Assert.assertNotNull(display.getEDTUtil()); Assert.assertEquals(false,display.getEDTUtil().isRunning()); - Assert.assertEquals(0,screen1.getReferenceCount()); - Assert.assertEquals(false,screen1.isNativeValid()); - - Assert.assertEquals(0,screen2.getReferenceCount()); - Assert.assertEquals(false,screen2.isNativeValid()); + Assert.assertEquals(0,screen.getReferenceCount()); + Assert.assertEquals(false,screen.isNativeValid()); } @Test diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java index 7a8bc1db0..12cc7875a 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -130,8 +130,8 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { while(animator.isAnimating() && animator.getDuration()<durationPerTest) { Thread.sleep(100); } - animator.stop(); destroyWindow(window, true); + Assert.assertEquals(false, animator.isAnimating()); } @Test @@ -144,13 +144,43 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { while(animator.isAnimating() && animator.getDuration()<durationPerTest) { Thread.sleep(100); } - animator.stop(); destroyWindow(window, false); destroyWindow(window, true); + Assert.assertEquals(false, animator.isAnimating()); } @Test - public void testWindowDecor03TwoWin() throws InterruptedException { + public void testWindowDecor03TwoWinOneDisplay() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + GLWindow window1 = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Assert.assertNotNull(window1); + + GLWindow window2 = createWindow(screen, caps, width-10, height-10, true /* onscreen */, false /* undecorated */); + Assert.assertNotNull(window2); + + Animator animator1 = new Animator(window1); + animator1.start(); + Animator animator2 = new Animator(window2); + animator2.start(); + while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { + Thread.sleep(100); + } + + destroyWindow(window2, true); + Assert.assertEquals(false, animator2.isAnimating()); + + destroyWindow(window1, true); + Assert.assertEquals(false, animator1.isAnimating()); + } + @Test + public void testWindowDecor03TwoWinTwoDisplays() throws InterruptedException { GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); @@ -178,13 +208,11 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Thread.sleep(100); } - animator2.stop(); - Assert.assertEquals(false, animator2.isAnimating()); - destroyWindow(window2, false); - - animator1.stop(); - Assert.assertEquals(false, animator1.isAnimating()); destroyWindow(window1, true); + Assert.assertEquals(false, animator1.isAnimating()); + + destroyWindow(window2, false); + Assert.assertEquals(false, animator2.isAnimating()); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow) { |