diff options
Diffstat (limited to 'src/junit/com')
9 files changed, 399 insertions, 83 deletions
diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java new file mode 100644 index 000000000..f0ceba606 --- /dev/null +++ b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.test.junit.newt; + +import java.lang.reflect.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Test; + +import javax.media.nativewindow.*; +import javax.media.opengl.*; + +import com.jogamp.newt.*; +import com.jogamp.newt.event.*; +import com.jogamp.newt.opengl.*; +import java.io.IOException; + +import com.jogamp.test.junit.util.MiscUtils; +import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; + +public class TestDisplayLifecycle01NEWT { + static { + GLProfile.initSingleton(); + } + + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + static long durationPerTest = 100; // ms + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + caps = new GLCapabilities(glp); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height) + throws InterruptedException + { + Assert.assertNotNull(caps); + + // + // Create native windowing resources .. X11/Win/OSX + // + GLWindow glWindow; + if(null!=screen) { + Window window = NewtFactory.createWindow(screen, caps, false); + Assert.assertNotNull(window); + glWindow = GLWindow.create(window); + } else { + glWindow = GLWindow.create(caps, false); + } + + GLEventListener demo = new Gears(); + setDemoFields(demo, glWindow); + glWindow.addGLEventListener(demo); + glWindow.addWindowListener(new TraceWindowAdapter()); + glWindow.setSize(width, height); + return glWindow; + } + + private void testDisplayCreate01(Display display, Screen screen, boolean destroyWhenUnused) throws InterruptedException { + // start-state == end-state + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + Assert.assertEquals(0,display.getReferenceCount()); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertNotNull(display.getEDTUtil()); + Assert.assertEquals(false,display.getEDTUtil().isRunning()); + Assert.assertEquals(0,screen.getReferenceCount()); + Assert.assertEquals(false,screen.isNativeValid()); + + // Setup/Verify default DestroyWhenUnused behavior + if(destroyWhenUnused) { + screen.setDestroyWhenUnused(true); + } + Assert.assertEquals(destroyWhenUnused,display.getDestroyWhenUnused()); + Assert.assertEquals(destroyWhenUnused,screen.getDestroyWhenUnused()); + + // Create Window, pending lazy native creation + GLWindow window = createWindow(screen, caps, width, height); + Assert.assertEquals(screen,window.getScreen()); + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + Assert.assertEquals(0,display.getReferenceCount()); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(false,display.getEDTUtil().isRunning()); + Assert.assertEquals(0,screen.getReferenceCount()); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertEquals(false,window.isVisible()); + + // lazy native creation sequence: Display, Screen and Window + window.setVisible(true); + window.display(); + int wait=0; + while(wait<10 && window.getTotalFrames()<1) { Thread.sleep(100); wait++; } + System.out.println("Frames for setVisible(true) 1: "+window.getTotalFrames()); + + Assert.assertEquals(screen,window.getScreen()); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); + Assert.assertEquals(1,display.getReferenceCount()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); + Assert.assertEquals(1,screen.getReferenceCount()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + while(window.getDuration()<1*durationPerTest) { + window.display(); + Thread.sleep(100); + } + System.out.println("duration: "+window.getDuration()); + + // just make the Window invisible + window.setVisible(false); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(false,window.isVisible()); + + // just make the Window visible again + window.setVisible(true); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + while(window.getDuration()<2*durationPerTest) { + window.display(); + Thread.sleep(100); + } + System.out.println("duration: "+window.getDuration()); + + // recoverable destruction, ie Display/Screen untouched + window.destroy(false); + Assert.assertEquals(screen,window.getScreen()); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); + Assert.assertEquals(1,display.getReferenceCount()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertNotNull(display.getEDTUtil()); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); + Assert.assertEquals(1,screen.getReferenceCount()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertEquals(false,window.isVisible()); + + // a display call shall not change a thing + window.display(); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertEquals(false,window.isVisible()); + + // recover Window + window.setVisible(true); + window.display(); + wait=0; + while(wait<10 && window.getTotalFrames()<1) { Thread.sleep(100); wait++; } + System.out.println("Frames for setVisible(true) 2: "+window.getTotalFrames()); + + Assert.assertEquals(screen,window.getScreen()); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); + Assert.assertEquals(1,display.getReferenceCount()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); + Assert.assertEquals(1,screen.getReferenceCount()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + while(window.getDuration()<1*durationPerTest) { + window.display(); + Thread.sleep(100); + } + System.out.println("duration: "+window.getDuration()); + + // unrecoverable destruction, ie Display/Screen will be unreferenced + window.destroy(true); + Assert.assertEquals(null,window.getScreen()); + Display.dumpDisplayList("Post destroy(true)"); + if(!destroyWhenUnused) { + // display/screen untouched when unused, default + Assert.assertEquals(1,Display.getActiveDisplayNumber()); + Assert.assertEquals(1,display.getReferenceCount()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertNotNull(display.getEDTUtil()); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); + Assert.assertEquals(0,screen.getReferenceCount()); + Assert.assertEquals(true,screen.isNativeValid()); + + // manual destruction: Screen + screen.destroy(); + Assert.assertEquals(1,Display.getActiveDisplayNumber()); + Assert.assertEquals(0,display.getReferenceCount()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertNotNull(display.getEDTUtil()); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); + Assert.assertEquals(0,screen.getReferenceCount()); + Assert.assertEquals(false,screen.isNativeValid()); + + // manual destruction: Display + display.destroy(); + } else { + // display/screen destroyed when unused + } + + // end-state == start-state + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + Assert.assertEquals(0,display.getReferenceCount()); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertNotNull(display.getEDTUtil()); + Assert.assertEquals(false,display.getEDTUtil().isRunning()); + Assert.assertEquals(0,screen.getReferenceCount()); + Assert.assertEquals(false,screen.isNativeValid()); + + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertEquals(false,window.isVisible()); + } + + @Test + public void testDisplayCreate01_DestroyWhenUnused_False() throws InterruptedException { + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + + // Create Display/Screen, pending lazy native creation + Display display = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + testDisplayCreate01(display, screen, false); + testDisplayCreate01(display, screen, false); + + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + } + + @Test + public void testDisplayCreate01_DestroyWhenUnused_True() throws InterruptedException { + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + + // Create Display/Screen, pending lazy native creation + Display display = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + testDisplayCreate01(display, screen, true); + testDisplayCreate01(display, screen, true); + + Assert.assertEquals(0,Display.getActiveDisplayNumber()); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getInnerWindow())) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i<args.length; i++) { + if(args[i].equals("-time")) { + durationPerTest = atoi(args[++i]); + } + } + System.out.println("durationPerTest: "+durationPerTest); + String tstname = TestDisplayLifecycle01NEWT.class.getName(); + org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { + tstname, + "filtertrace=true", + "haltOnError=false", + "haltOnFailure=false", + "showoutput=true", + "outputtoformatters=true", + "logfailedtests=true", + "logtestlistenerevents=true", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); + } + +} diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java index 1a6863a31..9586ad936 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java @@ -89,7 +89,7 @@ public class TestGLWindows01NEWT { } Assert.assertNotNull(glWindow); Assert.assertEquals(false,glWindow.isVisible()); - Assert.assertEquals(false,glWindow.isNativeWindowValid()); + Assert.assertEquals(false,glWindow.isNativeValid()); GLEventListener demo = new Gears(); setDemoFields(demo, glWindow); @@ -102,7 +102,7 @@ public class TestGLWindows01NEWT { glWindow.setVisible(true); Assert.assertEquals(true,glWindow.isVisible()); - Assert.assertEquals(true,glWindow.isNativeWindowValid()); + Assert.assertEquals(true,glWindow.isNativeValid()); int wait=0; while(wait<10 && glWindow.getTotalFrames()<1) { Thread.sleep(100); wait++; } System.out.println("Frames for initial setVisible(true): "+glWindow.getTotalFrames()); @@ -133,7 +133,7 @@ public class TestGLWindows01NEWT { static void destroyWindow(GLWindow glWindow, boolean deep) { if(null!=glWindow) { glWindow.destroy(deep); - Assert.assertEquals(false,glWindow.isNativeWindowValid()); + Assert.assertEquals(false,glWindow.isNativeValid()); } } @@ -145,22 +145,22 @@ public class TestGLWindows01NEWT { true /* onscreen */, false /* undecorated */, false /*addGLEventListenerAfterVisible*/); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); window.destroy(false); - Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); window.display(); - Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); window.setVisible(true); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); window.setVisible(false); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); destroyWindow(window, true); @@ -174,22 +174,22 @@ public class TestGLWindows01NEWT { true /* onscreen */, false /* undecorated */, true /*addGLEventListenerAfterVisible*/); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); window.destroy(false); - Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); window.display(); - Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); window.setVisible(true); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); window.setVisible(false); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); destroyWindow(window, true); diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java index 60fadb7d6..62bb5b7f9 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -89,13 +89,13 @@ public class TestGLWindows02NEWTAnimated { setDemoFields(demo, glWindow); glWindow.addGLEventListener(demo); glWindow.addWindowListener(new TraceWindowAdapter()); - Assert.assertEquals(false,glWindow.isNativeWindowValid()); + Assert.assertEquals(false,glWindow.isNativeValid()); glWindow.setSize(width, height); Assert.assertEquals(false,glWindow.isVisible()); glWindow.setVisible(true); Assert.assertEquals(true,glWindow.isVisible()); - Assert.assertEquals(true,glWindow.isNativeWindowValid()); + Assert.assertEquals(true,glWindow.isNativeValid()); // Assert.assertEquals(width,glWindow.getWidth()); // Assert.assertEquals(height,glWindow.getHeight()); // System.out.println("Created: "+glWindow); diff --git a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java index d729b2718..be917ecea 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java @@ -65,11 +65,11 @@ public class TestWindows01NEWT { Window window = NewtFactory.createWindow(screen, caps, onscreen && undecorated); Assert.assertNotNull(window); window.setSize(width, height); - Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); window.setVisible(true); Assert.assertEquals(true,window.isVisible()); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); // Assert.assertEquals(width,window.getWidth()); // Assert.assertEquals(height,window.getHeight()); // System.out.println("Created: "+window); @@ -111,11 +111,11 @@ public class TestWindows01NEWT { Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); window.destroy(); - Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); window.setVisible(true); - Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); Thread.sleep(100); // 100 ms diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java index fc6a30bd6..ad03f010c 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java @@ -83,7 +83,7 @@ public class TestParenting01NEWT { GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); glWindow1.setSize(640, 480); @@ -94,7 +94,7 @@ public class TestParenting01NEWT { GLWindow glWindow2 = GLWindow.create(glWindow1, glCaps); Assert.assertNotNull(glWindow2); Assert.assertEquals(false, glWindow2.isVisible()); - Assert.assertEquals(false, glWindow2.isNativeWindowValid()); + Assert.assertEquals(false, glWindow2.isNativeValid()); Assert.assertEquals(glWindow1,glWindow2.getParentNativeWindow()); glWindow2.setSize(320, 240); GLEventListener demo2 = new Gears(); @@ -104,19 +104,19 @@ public class TestParenting01NEWT { // visible test glWindow1.setVisible(true); Assert.assertEquals(true, glWindow1.isVisible()); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(true, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); glWindow1.setVisible(false); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(false, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); glWindow1.setVisible(true); Assert.assertEquals(true, glWindow1.isVisible()); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(true, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); Animator animator1 = new Animator(glWindow1); animator1.start(); @@ -133,20 +133,20 @@ public class TestParenting01NEWT { glWindow1.destroy(); // false Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertEquals(true, glWindow1.isValid()); Assert.assertEquals(false, glWindow2.isVisible()); - Assert.assertEquals(false, glWindow2.isNativeWindowValid()); - Assert.assertEquals(false, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow2.isNativeValid()); + Assert.assertEquals(true, glWindow2.isValid()); glWindow1.destroy(true); - Assert.assertEquals(true, glWindow1.isDestroyed()); - Assert.assertEquals(true, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow1.isValid()); + Assert.assertEquals(false, glWindow2.isValid()); // test double destroy .. glWindow2.destroy(true); - Assert.assertEquals(true, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow2.isValid()); } @Test @@ -185,14 +185,14 @@ public class TestParenting01NEWT { Assert.assertEquals(true, glWindow2.isVisible()); glWindow2.reparentWindow(glWindow1, null); Assert.assertEquals(true, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertEquals(glWindow1,glWindow2.getParentNativeWindow()); break; case 1: Assert.assertEquals(true, glWindow2.isVisible()); glWindow2.reparentWindow(null, null); Assert.assertEquals(true, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertNull(glWindow2.getParentNativeWindow()); break; } @@ -204,11 +204,11 @@ public class TestParenting01NEWT { Assert.assertEquals(false, animator2.isAnimating()); glWindow1.destroy(true); - Assert.assertEquals(true, glWindow1.isDestroyed()); - Assert.assertEquals(false, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow1.isValid()); + Assert.assertEquals(true , glWindow2.isValid()); glWindow2.destroy(true); - Assert.assertEquals(true, glWindow1.isDestroyed()); - Assert.assertEquals(true, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow1.isValid()); + Assert.assertEquals(false, glWindow2.isValid()); } @Test @@ -246,14 +246,14 @@ public class TestParenting01NEWT { Assert.assertEquals(true, glWindow2.isVisible()); glWindow2.reparentWindow(null, null); Assert.assertEquals(true, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertNull(glWindow2.getParentNativeWindow()); break; case 1: Assert.assertEquals(true, glWindow2.isVisible()); glWindow2.reparentWindow(glWindow1, null); Assert.assertEquals(true, glWindow2.isVisible()); - Assert.assertEquals(true, glWindow2.isNativeWindowValid()); + Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertEquals(glWindow1,glWindow2.getParentNativeWindow()); break; } @@ -265,11 +265,11 @@ public class TestParenting01NEWT { Assert.assertEquals(false, animator2.isAnimating()); glWindow1.destroy(true); - Assert.assertEquals(true, glWindow1.isDestroyed()); - Assert.assertEquals(true, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow1.isValid()); + Assert.assertEquals(false, glWindow2.isValid()); glWindow2.destroy(true); - Assert.assertEquals(true, glWindow1.isDestroyed()); - Assert.assertEquals(true, glWindow2.isDestroyed()); + Assert.assertEquals(false, glWindow1.isValid()); + Assert.assertEquals(false, glWindow2.isValid()); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java index af28c8236..5d4ddc153 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java @@ -89,7 +89,7 @@ public class TestParenting01aAWT { GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); @@ -99,7 +99,7 @@ public class TestParenting01aAWT { NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); Frame frame1 = new Frame("AWT Parent Frame"); @@ -133,20 +133,20 @@ public class TestParenting01aAWT { Assert.assertEquals(false, animator1.isAnimating()); frame1.setVisible(false); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); frame1.setVisible(true); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); frame1.remove(newtCanvasAWT); // Assert.assertNull(glWindow1.getParentNativeWindow()); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); frame1.dispose(); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); glWindow1.destroy(true); - //Assert.assertEquals(true, glWindow1.isDestroyed()); + //Assert.assertEquals(false, glWindow1.isValid()); } @Test @@ -159,7 +159,7 @@ public class TestParenting01aAWT { GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); @@ -168,7 +168,7 @@ public class TestParenting01aAWT { NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); Frame frame = new Frame("AWT Parent Frame"); @@ -259,12 +259,12 @@ public class TestParenting01aAWT { switch(state) { case 0: glWindow1.reparentWindow(null, null); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); break; case 1: glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), null); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); break; } @@ -314,12 +314,12 @@ public class TestParenting01aAWT { switch(state) { case 0: glWindow1.reparentWindow(null, null); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); break; case 1: glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), null); - Assert.assertEquals(true, glWindow1.isNativeWindowValid()); + Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); break; } diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java index 15dd8a5c6..669ff0a42 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java @@ -88,7 +88,7 @@ public class TestParenting01cAWT { GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); @@ -98,7 +98,7 @@ public class TestParenting01cAWT { NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); Frame frame1 = new Frame("AWT Parent Frame"); @@ -128,20 +128,20 @@ public class TestParenting01cAWT { } frame1.setVisible(false); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); frame1.setVisible(true); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); frame1.remove(newtCanvasAWT); // Assert.assertNull(glWindow1.getParentNativeWindow()); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); frame1.dispose(); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); glWindow1.destroy(true); - //Assert.assertEquals(true, glWindow1.isDestroyed()); + //Assert.assertEquals(false, glWindow1.isValid()); } @Test diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 7342b4169..3277999e2 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -95,7 +95,7 @@ public class TestParenting01cSwingAWT { GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); @@ -123,7 +123,7 @@ public class TestParenting01cSwingAWT { NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); Container container1 = new Container(); @@ -169,14 +169,14 @@ public class TestParenting01cSwingAWT { System.out.println("Demos: 3 - !Visible"); _jFrame1.setVisible(false); } }); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { System.out.println("Demos: 4 - Visible"); _jFrame1.setVisible(true); } }); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -184,16 +184,16 @@ public class TestParenting01cSwingAWT { _jPanel1.remove(_container1); } }); // Assert.assertNull(glWindow1.getParentNativeWindow()); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { _jFrame1.dispose(); } }); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); glWindow1.destroy(true); - //Assert.assertEquals(true, glWindow1.isDestroyed()); + //Assert.assertEquals(false, glWindow1.isValid()); } @Test @@ -209,7 +209,7 @@ public class TestParenting01cSwingAWT { GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); @@ -236,7 +236,7 @@ public class TestParenting01cSwingAWT { NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); - Assert.assertEquals(false, glWindow1.isNativeWindowValid()); + Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParentNativeWindow()); Container container1 = new Container(); @@ -318,17 +318,17 @@ public class TestParenting01cSwingAWT { _jFrame1.setVisible(false); _jFrame2.setVisible(false); } }); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { _jFrame1.dispose(); _jFrame2.dispose(); } }); - Assert.assertEquals(false, glWindow1.isDestroyed()); + Assert.assertEquals(true, glWindow1.isValid()); glWindow1.destroy(true); - //Assert.assertEquals(true, glWindow1.isDestroyed()); + //Assert.assertEquals(false, glWindow1.isValid()); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java index 736967d21..f67d93da3 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java @@ -113,7 +113,7 @@ public class TestParenting02AWT { NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow.isVisible()); - Assert.assertEquals(false, glWindow.isNativeWindowValid()); + Assert.assertEquals(false, glWindow.isNativeValid()); Assert.assertNull(glWindow.getParentNativeWindow()); Frame frame = new Frame("AWT Parent Frame"); @@ -154,9 +154,9 @@ public class TestParenting02AWT { Thread.yield(); // 1st display .. creation glWindow.display(); - } while(!glWindow.isNativeWindowValid()) ; + } while(!glWindow.isNativeValid()) ; - Assert.assertEquals(true, glWindow.isNativeWindowValid()); + Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertNotNull(glWindow.getParentNativeWindow()); if(verbose) { System.out.println("+++++++++++++++++++ 1st ADDED"); @@ -167,7 +167,7 @@ public class TestParenting02AWT { // test some fancy re-layout .. frame.remove(newtCanvasAWT); Assert.assertEquals(false, glWindow.isVisible()); - Assert.assertEquals(true, glWindow.isNativeWindowValid()); + Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertNull(glWindow.getParentNativeWindow()); if(verbose) { System.out.println("+++++++++++++++++++ REMOVED!"); @@ -178,7 +178,7 @@ public class TestParenting02AWT { frame.add(newtCanvasAWT, BorderLayout.CENTER); glWindow.display(); Assert.assertEquals(true, glWindow.isVisible()); - Assert.assertEquals(true, glWindow.isNativeWindowValid()); + Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertNotNull(glWindow.getParentNativeWindow()); if(verbose) { System.out.println("+++++++++++++++++++ 2nd ADDED"); |