aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/test/junit/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/junit/com/jogamp/test/junit/newt')
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestCloseNewtAWT.java141
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java264
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java386
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java110
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java201
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java301
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java133
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java384
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java303
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java167
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java161
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestRemoteWindow01NEWT.java139
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java140
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java284
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java187
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java179
-rw-r--r--src/junit/com/jogamp/test/junit/newt/WindowEventCom1.java42
-rw-r--r--src/junit/com/jogamp/test/junit/newt/WindowEventCom2.java48
-rw-r--r--src/junit/com/jogamp/test/junit/newt/WindowEventCom3.java44
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/GLRunnableDummy.java57
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/KeyAction.java45
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java716
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java443
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java205
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java243
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java365
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java267
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java235
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java203
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java258
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/WindowAction.java44
31 files changed, 0 insertions, 6695 deletions
diff --git a/src/junit/com/jogamp/test/junit/newt/TestCloseNewtAWT.java b/src/junit/com/jogamp/test/junit/newt/TestCloseNewtAWT.java
deleted file mode 100644
index 1899a6b81..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestCloseNewtAWT.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import org.junit.Test;
-
-import java.lang.reflect.InvocationTargetException;
-import java.awt.EventQueue;
-import java.awt.Toolkit;
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
-import javax.media.nativewindow.NativeWindow;
-import javax.media.nativewindow.util.Point;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-import com.jogamp.newt.Window;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.test.junit.util.UITestCase;
-
-public class TestCloseNewtAWT extends UITestCase {
-
- GLWindow newtWindow = null;
- NewtCanvasAWT newtCanvas = null;
- JFrame frame = null;
-
- class MyCanvas extends NewtCanvasAWT {
- public MyCanvas(Window window) {
- super(window);
- }
-
- public void addNotify() {
- System.err.println("MyCanvas START add: "+Thread.currentThread()+", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
- super.addNotify();
- System.err.println("MyCanvas END add: "+Thread.currentThread()+", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
- }
-
- public void removeNotify() {
- System.err.println("MyCanvas START remove: "+Thread.currentThread()+", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
-
- // trigger critical situation around the AWT TreeLock
- newtWindow.runOnEDTIfAvail(true, new Runnable() {
- public void run() {
- // NEWT EDT while AWT is locked
- System.err.println("MyCanvas On NEWT-EDT From AWT-EDT: "+Thread.currentThread()+
- ", holds AWTTreeLock: "+Thread.holdsLock(MyCanvas.this.getTreeLock()));
-
- // Critical: Within NEWT EDT, while AWT is locked
- NativeWindow nw = MyCanvas.this.getNativeWindow();
- if(null != nw) {
- Point p = nw.getLocationOnScreen(null);
- System.err.println("MyCanvas On NEWT-EDT: position: "+p);
- } else {
- System.err.println("MyCanvas On NEWT-EDT: position n/a, null NativeWindow");
- }
- }
- });
- System.err.println("MyCanvas passed critical: "+Thread.currentThread()+", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
-
- super.removeNotify();
-
- System.err.println("MyCanvas END remove: "+Thread.currentThread()+", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
- }
- }
-
- class NEWTWindowClosingAdapter extends WindowAdapter {
- public void windowDestroyNotify(WindowEvent e) {
- System.err.println("Destroy NEWT: windowDestroyNotify "+Thread.currentThread() + ", "+ e);
- }
- }
-
- class AWTClosingWindowAdapter extends java.awt.event.WindowAdapter {
- public void windowClosing(WindowEvent ev) {
- System.err.println("Destroy AWT: windowClosing "+Thread.currentThread() + ", "+ ev);
- }
- }
-
-
- @Test
- public void testCloseNewtAWT() throws InterruptedException, InvocationTargetException {
- newtWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
- newtWindow.addWindowListener(new NEWTWindowClosingAdapter());
- newtCanvas = new MyCanvas(newtWindow);
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- frame = new JFrame("NEWT Close Test");
- frame.addWindowListener(new AWTClosingWindowAdapter());
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.getContentPane().add(newtCanvas);
- frame.pack();
- frame.setSize(800, 600);
- frame.setVisible(true);
- }
- });
- Thread.sleep(1000);
-
- // programatically issue windowClosing
- Toolkit tk = Toolkit.getDefaultToolkit();
- EventQueue evtQ = tk.getSystemEventQueue();
- evtQ.postEvent(new java.awt.event.WindowEvent(frame, java.awt.event.WindowEvent.WINDOW_CLOSING));
- Thread.sleep(200);
-
- GLProfile.shutdown();
- }
-
- public static void main(String[] args) {
- String tstname = TestCloseNewtAWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java
deleted file mode 100644
index 94f915834..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-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.UITestCase;
-import com.jogamp.test.junit.util.MiscUtils;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestDisplayLifecycle01NEWT extends UITestCase {
- static GLProfile glp;
- static GLCapabilities caps;
- static int width, height;
- static long durationPerTest = 100; // ms
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- 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);
- Assert.assertNotNull(window);
- glWindow = GLWindow.create(window);
- } else {
- glWindow = GLWindow.create(caps);
- }
-
- 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) 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());
-
- // 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(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
-
- Assert.assertNotNull(window.getScreen());
- Assert.assertEquals(true,window.isValid());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- // lazy native creation sequence: Display, Screen and Window
- Assert.assertEquals(0, window.getTotalFrames());
- window.setVisible(true);
-
- 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());
- System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames());
- Assert.assertTrue(0 < window.getTotalFrames());
-
- while(window.getDuration()<1*durationPerTest) {
- window.display();
- Thread.sleep(100);
- }
- System.err.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.resetCounter();
- Assert.assertEquals(0, window.getTotalFrames());
- window.setVisible(true);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
- System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames());
- Assert.assertTrue(0 < window.getTotalFrames());
-
- while(window.getDuration()<2*durationPerTest) {
- window.display();
- Thread.sleep(100);
- }
- System.err.println("duration: "+window.getDuration());
-
- // destruction ..
- window.destroy();
- Assert.assertEquals(screen,window.getScreen());
- 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(true, window.isValid());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
- window.resetCounter();
- Assert.assertEquals(0, window.getTotalFrames());
-
- // a display call shall not change a thing
- window.display();
- Assert.assertEquals(0, window.getTotalFrames());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- // recover Window
- window.setVisible(true);
-
- 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());
- System.err.println("Frames for setVisible(true) 2: "+window.getTotalFrames());
- Assert.assertTrue(0 < window.getTotalFrames());
-
- while(window.getDuration()<1*durationPerTest) {
- window.display();
- Thread.sleep(100);
- }
- System.err.println("duration: "+window.getDuration());
-
- // destruction ..
- window.destroy();
- display.dumpDisplayList("Post destroy(true)");
-
- // 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.assertNotNull(window.getScreen());
- Assert.assertEquals(true,window.isValid());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
- }
-
- @Test
- public void testDisplayCreate01_AutoDestroyLifecycle() 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);
- testDisplayCreate01(display, screen);
-
- 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)) {
- 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.err.println("durationPerTest: "+durationPerTest);
- String tstname = TestDisplayLifecycle01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java
deleted file mode 100644
index 9fc6e3bc9..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-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.UITestCase;
-import com.jogamp.test.junit.util.MiscUtils;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestDisplayLifecycle02NEWT extends UITestCase {
- static GLProfile glp;
- static GLCapabilities caps;
- static int width, height;
- static long durationPerTest = 100; // ms
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- caps = new GLCapabilities(glp);
- }
-
- static GLWindow createWindow(GLCapabilities caps, int width, int height)
- throws InterruptedException
- {
- Assert.assertNotNull(caps);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- GLWindow glWindow = GLWindow.create(caps);
-
- GLEventListener demo = new Gears();
- setDemoFields(demo, glWindow);
- glWindow.addGLEventListener(demo);
- glWindow.addWindowListener(new TraceWindowAdapter());
- glWindow.setSize(width, height);
- return glWindow;
- }
-
- private void testDisplayCreate01Impl() throws InterruptedException {
- // start-state == end-state
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- // Create Window, pending lazy native creation
- GLWindow window = createWindow(caps, width, height);
- Screen screen = window.getScreen();
- Display display = screen.getDisplay();
-
- Assert.assertEquals(screen,window.getScreen());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- Assert.assertEquals(0,display.getReferenceCount());
- Assert.assertEquals(false,display.isNativeValid());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(0,Screen.getActiveScreenNumber());
- 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
- Assert.assertEquals(0, window.getTotalFrames());
- window.setVisible(true);
-
- 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.getActiveScreenNumber());
- Assert.assertEquals(1,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
- System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames());
- Assert.assertTrue(0 < window.getTotalFrames());
-
- while(window.getDuration()<1*durationPerTest) {
- window.display();
- Thread.sleep(100);
- }
- System.err.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.resetCounter();
- Assert.assertEquals(0, window.getTotalFrames());
- window.setVisible(true);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
- System.err.println("Frames for setVisible(true) 1: "+window.getTotalFrames());
- Assert.assertTrue(0 < window.getTotalFrames());
-
- while(window.getDuration()<2*durationPerTest) {
- window.display();
- Thread.sleep(100);
- }
- System.err.println("duration: "+window.getDuration());
-
- // destruction.. ref count down, but keep all
- window.destroy();
- Assert.assertEquals(screen,window.getScreen());
- 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.getActiveScreenNumber());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertNotNull(window.getScreen());
- Assert.assertEquals(true,window.isValid());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- window.resetCounter();
- Assert.assertEquals(0, window.getTotalFrames());
-
- // a display call shall not change a thing
- window.display();
- Assert.assertEquals(0, window.getTotalFrames());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- // recover Window
- window.setVisible(true);
-
- Assert.assertEquals(screen,window.getScreen());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,window.isValid());
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(1,Screen.getActiveScreenNumber());
- Assert.assertEquals(1,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
- System.err.println("Frames for setVisible(true) 2: "+window.getTotalFrames());
- Assert.assertTrue(0 < window.getTotalFrames());
-
- while(window.getDuration()<1*durationPerTest) {
- window.display();
- Thread.sleep(100);
- }
- System.err.println("duration: "+window.getDuration());
-
- // destruction + invalidate, ie Display/Screen will be unreferenced
- window.invalidate();
- Assert.assertNull(window.getScreen());
- Assert.assertEquals(false,window.isValid());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- display.dumpDisplayList("Post destroy(true)");
-
- // 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.getActiveScreenNumber());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
- }
-
- @Test
- public void testDisplayCreate01() throws InterruptedException {
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- // Create Display/Screen, pending lazy native creation
- testDisplayCreate01Impl();
- testDisplayCreate01Impl();
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- }
-
- private void testDisplayCreate02Impl() throws InterruptedException {
- // start-state == end-state
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- // Create Window, pending lazy native creation
- GLWindow window1 = createWindow(caps, width, height);
- window1.setPosition(0, 0);
- Screen screen = window1.getScreen();
- Display display = screen.getDisplay();
-
- GLWindow window2 = createWindow(caps, width, height);
- Assert.assertSame(screen, window2.getScreen());
- Assert.assertSame(display, window2.getScreen().getDisplay());
- window2.setPosition(screen.getWidth()-width, 0);
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- Assert.assertEquals(0,display.getReferenceCount());
- Assert.assertEquals(false,display.isNativeValid());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(0,Screen.getActiveScreenNumber());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,window1.isNativeValid());
- Assert.assertEquals(false,window1.isVisible());
- Assert.assertEquals(false,window2.isNativeValid());
- Assert.assertEquals(false,window2.isVisible());
-
- // lazy native creation sequence: Display, Screen and Window
- Assert.assertEquals(0, window1.getTotalFrames());
- window1.setVisible(true);
-
- 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.getActiveScreenNumber());
- Assert.assertEquals(1,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(true,window1.isVisible());
- System.err.println("Frames for setVisible(true) 1: "+window1.getTotalFrames());
- Assert.assertTrue(0 < window1.getTotalFrames());
-
- Assert.assertEquals(0, window2.getTotalFrames());
- window2.setVisible(true);
-
- 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.getActiveScreenNumber());
- Assert.assertEquals(2,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(true,window2.isNativeValid());
- Assert.assertEquals(true,window2.isVisible());
- System.err.println("Frames for setVisible(true) 2: "+window2.getTotalFrames());
- Assert.assertTrue(0 < window2.getTotalFrames());
-
- while(window1.getDuration()<1*durationPerTest) {
- window1.display();
- Thread.sleep(100);
- }
- System.err.println("duration: "+window1.getDuration());
-
- // just make the Window invisible
- window1.setVisible(false);
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(false,window1.isVisible());
-
- // destruction ...
- window1.destroy();
- Assert.assertNotNull(window1.getScreen());
- Assert.assertEquals(true,window1.isValid());
- Assert.assertEquals(false,window1.isNativeValid());
- Assert.assertEquals(false,window1.isVisible());
-
- 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.getActiveScreenNumber());
- Assert.assertEquals(1,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
-
- // destruction
- window2.destroy();
- Assert.assertNotNull(window2.getScreen());
- Assert.assertEquals(true,window2.isValid());
- Assert.assertEquals(false,window2.isNativeValid());
- Assert.assertEquals(false,window2.isVisible());
-
- // 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.getActiveScreenNumber());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
-
- // invalidate .. remove all refs
- window1.invalidate();
- Assert.assertNull(window1.getScreen());
- Assert.assertEquals(false,window1.isValid());
- Assert.assertEquals(false,window1.isNativeValid());
- Assert.assertEquals(false,window1.isVisible());
-
- // invalidate .. remove all refs
- window2.invalidate();
- Assert.assertNull(window2.getScreen());
- Assert.assertEquals(false,window2.isValid());
- Assert.assertEquals(false,window2.isNativeValid());
- Assert.assertEquals(false,window2.isVisible());
-
- }
-
- @Test
- public void testDisplayCreate02() throws InterruptedException {
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- // Create Display/Screen, pending lazy native creation
- testDisplayCreate02Impl();
- testDisplayCreate02Impl();
-
- 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)) {
- 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.err.println("durationPerTest: "+durationPerTest);
- String tstname = TestDisplayLifecycle02NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java b/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java
deleted file mode 100644
index ff791b03a..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-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 java.io.IOException;
-
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-import javax.swing.WindowConstants;
-
-import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-import com.jogamp.test.junit.util.*;
-
-/**
- * This simple program will throw a {@link RuntimeException} when the application is closed.
- */
-public class TestEventSourceNotAWTBug extends UITestCase {
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- }
-
- @Test
- public void testEventSourceNotNewtBug() throws InterruptedException {
- JFrame jf = new JFrame();
-
- jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-
- final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
- final GLWindow glWindow = GLWindow.create(caps);
- final NewtCanvasAWT canvas = new NewtCanvasAWT(glWindow);
- jf.getContentPane().add(canvas);
-
- // The following line isn't event necessary to see the problem.
- glWindow.addGLEventListener(new Gears());
-
- final JFrame f_jf = jf;
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- f_jf.setSize(800, 600);
- f_jf.setVisible(true);
- }
- });
-
- Thread.sleep(500);
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- f_jf.dispose();
- }
- });
- glWindow.invalidate();
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestEventSourceNotAWTBug.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" } ); */
- org.junit.runner.JUnitCore.main(tstname);
- }
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
deleted file mode 100644
index d597af889..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import org.junit.Assert;
-import org.junit.AfterClass;
-
-import java.awt.AWTException;
-import java.awt.BorderLayout;
-import java.awt.Button;
-import java.awt.Robot;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLProfile;
-import javax.swing.JFrame;
-
-import java.util.ArrayList;
-import java.io.IOException;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-
-import com.jogamp.test.junit.util.*;
-
-public class TestFocus01SwingAWTRobot extends UITestCase {
- static int width, height;
- static long durationPerTest = 800;
- static long awtWaitTimeout = 1000;
-
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glCaps = new GLCapabilities(null);
- }
-
- @AfterClass
- public static void release() {
- }
-
- @Test
- public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException {
- testFocus01ProgrFocusImpl(null);
- }
-
- @Test
- public void testFocus02RobotFocus() throws AWTException, InterruptedException, InvocationTargetException {
- Robot robot = new Robot();
- robot.setAutoWaitForIdle(true);
- testFocus01ProgrFocusImpl(robot);
- }
-
- private void testFocus01ProgrFocusImpl(Robot robot) throws AWTException,
- InvocationTargetException, InterruptedException {
- ArrayList eventCountAdapters = new ArrayList();
-
- // Create a window.
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.setTitle("testNewtChildFocus");
- GLEventListener demo1 = new RedSquare();
- TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
- NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
- eventCountAdapters.add(glWindow1FA);
- glWindow1.addWindowListener(glWindow1FA);
-
- // Monitor NEWT focus and keyboard events.
- NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1");
- eventCountAdapters.add(glWindow1KA);
- glWindow1.addKeyListener(glWindow1KA);
-
- // Wrap the window in a canvas.
- final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- // Monitor AWT focus and keyboard events.
- AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT");
- newtCanvasAWT.addKeyListener(newtCanvasAWTKA);
- eventCountAdapters.add(newtCanvasAWTKA);
- AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT");
- newtCanvasAWT.addFocusListener(newtCanvasAWTFA);
- eventCountAdapters.add(newtCanvasAWTFA);
-
- // Add the canvas to a frame, and make it all visible.
- JFrame frame1 = new JFrame("Swing AWT Parent Frame: "
- + glWindow1.getTitle());
- frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER);
- Button button = new Button("Click me ..");
- AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button");
- button.addFocusListener(buttonFA);
- eventCountAdapters.add(buttonFA);
- AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button");
- button.addKeyListener(buttonKA);
- eventCountAdapters.add(buttonKA);
- frame1.getContentPane().add(button, BorderLayout.NORTH);
- frame1.setSize(width, height);
- frame1.setVisible(true);
- Assert.assertTrue(AWTRobotUtil.toFront(robot, frame1));
-
- int wait=0;
- while(wait<awtWaitTimeout/100 && glWindow1.getTotalFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
- System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames());
- Assert.assertTrue(glWindow1.isVisible());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
-
- // Continuous animation ..
- Animator animator = new Animator(glWindow1);
- animator.start();
-
- // Button Focus
- Thread.sleep(100); // allow event sync
- System.err.println("FOCUS AWT Button request");
- EventCountAdapterUtil.reset(eventCountAdapters);
- Assert.assertTrue(AWTRobotUtil.requestFocusAndWait(robot, button, button, buttonFA, null));
- Assert.assertEquals(1, buttonFA.getCount());
- Assert.assertEquals(0, glWindow1FA.getCount());
- Assert.assertEquals(0, newtCanvasAWTFA.getCount());
- System.err.println("FOCUS AWT Button sync");
- Assert.assertEquals(2, AWTRobotUtil.testKeyType(robot, 2, button, buttonKA));
-
- // Request the AWT focus, which should automatically provide the NEWT window with focus.
- Thread.sleep(100); // allow event sync
- System.err.println("FOCUS NEWT Canvas/GLWindow request");
- EventCountAdapterUtil.reset(eventCountAdapters);
- Assert.assertTrue(AWTRobotUtil.requestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA));
- Assert.assertTrue(AWTRobotUtil.waitForCount(0, newtCanvasAWTFA));
- Assert.assertEquals(1, glWindow1FA.getCount());
- Assert.assertEquals(0, newtCanvasAWTFA.getCount());
- Assert.assertEquals(-1, buttonFA.getCount()); // lost focus
- System.err.println("FOCUS NEWT Canvas/GLWindow sync");
- Assert.assertEquals(2, AWTRobotUtil.testKeyType(robot, 2, glWindow1, glWindow1KA));
- Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
-
- // Remove listeners to avoid logging during dispose/destroy.
- glWindow1.removeKeyListener(glWindow1KA);
- glWindow1.removeWindowListener(glWindow1FA);
- newtCanvasAWT.removeKeyListener(newtCanvasAWTKA);
- newtCanvasAWT.removeFocusListener(newtCanvasAWTFA);
-
- // Shutdown the test.
- animator.stop();
- frame1.dispose();
- glWindow1.invalidate();
- }
-
- 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 = TestFocus01SwingAWTRobot.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
deleted file mode 100644
index b96279cac..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import java.lang.reflect.*;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import org.junit.Test;
-
-import java.awt.AWTException;
-import java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.Robot;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
-import java.util.ArrayList;
-
-import javax.media.opengl.*;
-
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestFocus02SwingAWTRobot extends UITestCase {
- static int width, height;
- static long durationPerTest = 800;
- static long awtWaitTimeout = 1000;
- static long waitReparent = 0;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() throws AWTException {
- width = 640;
- height = 480;
-
- JFrame f = new JFrame();
- f.setSize(100,100);
- f.setVisible(true);
- f.dispose();
- f=null;
-
- GLProfile.initSingleton(false);
- glCaps = new GLCapabilities(null);
- }
-
- @AfterClass
- public static void release() {
- }
-
- private void testFocus01ProgrFocusImpl(Robot robot)
- throws AWTException, InterruptedException, InvocationTargetException {
- int x = 0;
- int y = 0;
-
- ArrayList eventCountAdapters = new ArrayList();
-
- /**
- * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow
- */
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new Gears();
- glWindow1.addGLEventListener(demo1);
- NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
- glWindow1.addWindowListener(glWindow1FA);
- eventCountAdapters.add(glWindow1FA);
- NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1");
- glWindow1.addKeyListener(glWindow1KA);
- eventCountAdapters.add(glWindow1KA);
- NEWTMouseAdapter glWindow1MA = new NEWTMouseAdapter("GLWindow1");
- glWindow1.addMouseListener(glWindow1MA);
- eventCountAdapters.add(glWindow1MA);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
- AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT");
- newtCanvasAWT.addFocusListener(newtCanvasAWTFA);
- eventCountAdapters.add(newtCanvasAWTFA);
- AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT");
- newtCanvasAWT.addKeyListener(newtCanvasAWTKA);
- eventCountAdapters.add(newtCanvasAWTKA);
- AWTMouseAdapter newtCanvasAWTMA = new AWTMouseAdapter("NewtCanvasAWT");
- newtCanvasAWT.addMouseListener(newtCanvasAWTMA);
- eventCountAdapters.add(newtCanvasAWTMA);
-
- Button buttonNorthInner = new Button("north");
- AWTFocusAdapter buttonNorthInnerFA = new AWTFocusAdapter("ButtonNorthInner");
- buttonNorthInner.addFocusListener(buttonNorthInnerFA);
- eventCountAdapters.add(buttonNorthInnerFA);
- AWTKeyAdapter buttonNorthInnerKA = new AWTKeyAdapter("ButtonNorthInner");
- buttonNorthInner.addKeyListener(buttonNorthInnerKA);
- eventCountAdapters.add(buttonNorthInnerKA);
- AWTMouseAdapter buttonNorthInnerMA = new AWTMouseAdapter("ButtonNorthInner");
- buttonNorthInner.addMouseListener(buttonNorthInnerMA);
- eventCountAdapters.add(buttonNorthInnerMA);
- Container container1 = new Container();
- container1.setLayout(new BorderLayout());
- container1.add(buttonNorthInner, BorderLayout.NORTH);
- container1.add(new Button("south"), BorderLayout.SOUTH);
- container1.add(new Button("east"), BorderLayout.EAST);
- container1.add(new Button("west"), BorderLayout.WEST);
- container1.add(newtCanvasAWT, BorderLayout.CENTER);
-
- Button buttonNorthOuter = new Button("north");
- AWTFocusAdapter buttonNorthOuterFA = new AWTFocusAdapter("ButtonNorthOuter");
- buttonNorthOuter.addFocusListener(buttonNorthOuterFA);
- eventCountAdapters.add(buttonNorthOuterFA);
- AWTKeyAdapter buttonNorthOuterKA = new AWTKeyAdapter("ButtonNorthOuter");
- buttonNorthOuter.addKeyListener(buttonNorthOuterKA);
- eventCountAdapters.add(buttonNorthOuterKA);
- AWTMouseAdapter buttonNorthOuterMA = new AWTMouseAdapter("ButtonNorthOuter");
- buttonNorthOuter.addMouseListener(buttonNorthOuterMA);
- eventCountAdapters.add(buttonNorthOuterMA);
- JPanel jPanel1 = new JPanel();
- jPanel1.setLayout(new BorderLayout());
- jPanel1.add(buttonNorthOuter, BorderLayout.NORTH);
- jPanel1.add(new Button("south"), BorderLayout.SOUTH);
- jPanel1.add(new Button("east"), BorderLayout.EAST);
- jPanel1.add(new Button("west"), BorderLayout.WEST);
- jPanel1.add(container1, BorderLayout.CENTER);
-
- JFrame jFrame1 = new JFrame("Swing Parent JFrame");
- AWTFocusAdapter jFrame1FA = new AWTFocusAdapter("JFrame1");
- jFrame1.addFocusListener(jFrame1FA);
- // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event!
- jFrame1.setContentPane(jPanel1);
- jFrame1.setSize(width, height);
- jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
- Assert.assertTrue(AWTRobotUtil.toFront(robot, jFrame1));
-
- int wait=0;
- while(wait<awtWaitTimeout/100 && glWindow1.getTotalFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
- System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames());
- Assert.assertTrue(glWindow1.isVisible());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
-
- // Continuous animation ..
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
-
- // Button Outer Focus
- Thread.sleep(100); // allow event sync
- System.err.println("FOCUS AWT Button Outer request");
- EventCountAdapterUtil.reset(eventCountAdapters);
- Assert.assertTrue(AWTRobotUtil.requestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, null));
- Assert.assertEquals(1, buttonNorthOuterFA.getCount());
- Assert.assertEquals(0, glWindow1FA.getCount());
- Assert.assertEquals(0, newtCanvasAWTFA.getCount());
- Assert.assertEquals(0, buttonNorthInnerFA.getCount());
- Assert.assertEquals(0, jFrame1FA.getCount());
- System.err.println("FOCUS AWT Button Outer sync");
- Assert.assertEquals(2, AWTRobotUtil.testKeyType(robot, 2, buttonNorthOuter, buttonNorthOuterKA));
- Assert.assertEquals(1, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
- buttonNorthOuter, buttonNorthOuterMA));
- Assert.assertEquals(3, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
- buttonNorthOuter, buttonNorthOuterMA));
-
- // NEWT Focus
- Thread.sleep(100); // allow event sync
- System.err.println("FOCUS NEWT Canvas/GLWindow request");
- EventCountAdapterUtil.reset(eventCountAdapters);
- Assert.assertTrue(AWTRobotUtil.requestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA));
- Assert.assertTrue(AWTRobotUtil.waitForCount(0, newtCanvasAWTFA));
- Assert.assertEquals(1, glWindow1FA.getCount());
- Assert.assertEquals(0, newtCanvasAWTFA.getCount());
- Assert.assertEquals(0, buttonNorthInnerFA.getCount());
- Assert.assertEquals(-1, buttonNorthOuterFA.getCount()); // lost focus
- Assert.assertEquals(0, jFrame1FA.getCount());
- System.err.println("FOCUS NEWT Canvas/GLWindow sync");
- Assert.assertEquals(2, AWTRobotUtil.testKeyType(robot, 2, glWindow1, glWindow1KA));
- Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
- Assert.assertEquals(1, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
- glWindow1, glWindow1MA));
- Assert.assertEquals(3, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
- glWindow1, glWindow1MA));
- Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
-
- // Button Inner Focus
- Thread.sleep(100); // allow event sync
- System.err.println("FOCUS AWT Button request");
- EventCountAdapterUtil.reset(eventCountAdapters);
- Assert.assertTrue(AWTRobotUtil.requestFocusAndWait(robot, buttonNorthInner, buttonNorthInner, buttonNorthInnerFA, glWindow1FA));
- Assert.assertEquals(1, buttonNorthInnerFA.getCount());
- Assert.assertEquals(-1, glWindow1FA.getCount()); // lost focus
- Assert.assertEquals(0, newtCanvasAWTFA.getCount());
- Assert.assertEquals(0, buttonNorthOuterFA.getCount());
- Assert.assertEquals(0, jFrame1FA.getCount());
- System.err.println("FOCUS AWT Button sync");
- Assert.assertEquals(2, AWTRobotUtil.testKeyType(robot, 2, buttonNorthInner, buttonNorthInnerKA));
- Assert.assertEquals(1, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
- buttonNorthInner, buttonNorthInnerMA));
- Assert.assertEquals(3, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
- buttonNorthInner, buttonNorthInnerMA));
-
- // NEWT Focus
- Thread.sleep(100); // allow event sync
- System.err.println("FOCUS NEWT Canvas/GLWindow request");
- EventCountAdapterUtil.reset(eventCountAdapters);
- Assert.assertTrue(AWTRobotUtil.requestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA));
- Assert.assertTrue(AWTRobotUtil.waitForCount(0, newtCanvasAWTFA));
- Assert.assertEquals(1, glWindow1FA.getCount());
- Assert.assertEquals(0, newtCanvasAWTFA.getCount());
- Assert.assertEquals(-1, buttonNorthInnerFA.getCount()); // lost focus
- Assert.assertEquals(0, buttonNorthOuterFA.getCount());
- Assert.assertEquals(0, jFrame1FA.getCount());
- System.err.println("FOCUS NEWT Canvas/GLWindow sync");
- Assert.assertEquals(2, AWTRobotUtil.testKeyType(robot, 2, glWindow1, glWindow1KA));
- Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
- Assert.assertEquals(1, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
- glWindow1, glWindow1MA));
- Assert.assertEquals(3, AWTRobotUtil.testMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
- glWindow1, glWindow1MA));
- Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
-
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- final JFrame _jFrame1 = jFrame1;
- final JPanel _jPanel1 = jPanel1;
- final Container _container1 = container1;
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- _jFrame1.setVisible(false);
- _jPanel1.remove(_container1);
- _jFrame1.dispose();
- } });
-
- glWindow1.invalidate();
- }
-
- @Test
- public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException {
- testFocus01ProgrFocusImpl(null);
- }
-
- @Test
- public void testFocus02RobotFocus() throws AWTException, InterruptedException, InvocationTargetException {
- Robot robot = new Robot();
- robot.setAutoWaitForIdle(true);
- testFocus01ProgrFocusImpl(robot);
- }
-
- 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]);
- } else if(args[i].equals("-wait")) {
- waitReparent = atoi(args[++i]);
- }
- }
- System.err.println("durationPerTest "+durationPerTest);
- System.err.println("waitReparent "+waitReparent);
- String tstname = TestFocus02SwingAWTRobot.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-}
-
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
deleted file mode 100644
index 2769dc550..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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.UITestCase;
-import com.jogamp.test.junit.util.MiscUtils;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-
-public class TestGLWindows00NEWT extends UITestCase {
- static GLProfile glp;
- static int width, height;
- static long durationPerTest = 100; // ms
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- // GLProfile.initSingleton(false);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- }
-
- static GLWindow createWindow(Screen screen, GLCapabilitiesImmutable caps)
- throws InterruptedException
- {
- Assert.assertNotNull(caps);
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- GLWindow glWindow;
- if(null!=screen) {
- glWindow = GLWindow.create(screen, caps);
- Assert.assertNotNull(glWindow);
- } else {
- glWindow = GLWindow.create(caps);
- Assert.assertNotNull(glWindow);
- }
-
- GLEventListener demo = new Gears();
- glWindow.addGLEventListener(demo);
-
- glWindow.setSize(512, 512);
- glWindow.setVisible(true);
- Assert.assertEquals(true,glWindow.isVisible());
- Assert.assertEquals(true,glWindow.isNativeValid());
-
- return glWindow;
- }
-
- static void destroyWindow(GLWindow glWindow) {
- if(null!=glWindow) {
- glWindow.invalidate();
- Assert.assertEquals(false,glWindow.isNativeValid());
- Assert.assertEquals(false,glWindow.isValid());
- }
- }
-
- @Test
- public void testWindow00() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window1 = createWindow(null, caps); // local
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(true,window1.isVisible());
- AbstractGraphicsDevice device1 = window1.getScreen().getDisplay().getGraphicsDevice();
-
- System.err.println("GLProfiles window1: "+device1.getConnection()+": "+GLProfile.glAvailabilityToString(device1));
-
- for(int state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
-
- destroyWindow(window1);
- }
-
- 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 = TestGLWindows00NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
deleted file mode 100644
index e2c65adb8..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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.UITestCase;
-import com.jogamp.test.junit.util.MiscUtils;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestGLWindows01NEWT extends UITestCase {
- static GLProfile glp;
- static int width, height;
- static long durationPerTest = 100; // ms
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- // GLProfile.initSingleton(false);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- }
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps,
- int width, int height, boolean onscreen, boolean undecorated,
- boolean addGLEventListenerAfterVisible)
- throws InterruptedException
- {
- Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
- // System.out.println("Requested: "+caps);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- GLWindow glWindow;
- if(null!=screen) {
- glWindow = GLWindow.create(screen, caps);
- Assert.assertNotNull(glWindow);
- } else {
- glWindow = GLWindow.create(caps);
- Assert.assertNotNull(glWindow);
- }
-
- glWindow.setUndecorated(onscreen && undecorated);
- Assert.assertEquals(false,glWindow.isVisible());
- Assert.assertEquals(false,glWindow.isNativeValid());
-
- GLEventListener demo = new Gears();
- setDemoFields(demo, glWindow);
- if(!addGLEventListenerAfterVisible) {
- glWindow.addGLEventListener(demo);
- }
- glWindow.addWindowListener(new TraceWindowAdapter());
-
- glWindow.setSize(width, height);
-
- Assert.assertEquals(0, glWindow.getTotalFrames());
- glWindow.setVisible(true);
- Assert.assertEquals(true,glWindow.isVisible());
- Assert.assertEquals(true,glWindow.isNativeValid());
- System.out.println("Frames for initial setVisible(true): "+glWindow.getTotalFrames());
- Assert.assertTrue(0 < glWindow.getTotalFrames());
-
- //
- // Create native OpenGL resources .. XGL/WGL/CGL ..
- // equivalent to GLAutoDrawable methods: setVisible(true)
- //
- GLCapabilitiesImmutable caps2 = glWindow.getChosenGLCapabilities();
- Assert.assertNotNull(caps2);
- Assert.assertTrue(caps2.getGreenBits()>=5);
- Assert.assertTrue(caps2.getBlueBits()>=5);
- Assert.assertTrue(caps2.getRedBits()>=5);
- Assert.assertEquals(caps2.isOnscreen(),onscreen);
-
- if(addGLEventListenerAfterVisible) {
- glWindow.addGLEventListener(demo);
- glWindow.display();
- }
-
- return glWindow;
- }
-
- static void destroyWindow(GLWindow glWindow) {
- if(null!=glWindow) {
- glWindow.invalidate();
- Assert.assertEquals(false,glWindow.isNativeValid());
- Assert.assertEquals(false,glWindow.isValid());
- }
- }
-
- @Test
- public void testWindowNativeRecreate01aSimple() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- false /*addGLEventListenerAfterVisible*/);
-
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
- window.destroy();
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- window.display();
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- window.setVisible(true);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
-
- window.setVisible(false);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- destroyWindow(window);
- }
-
- @Test
- public void testWindowNativeRecreate01bSimple() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- true /*addGLEventListenerAfterVisible*/);
-
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
- window.destroy();
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- window.display();
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- window.setVisible(true);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
-
- window.setVisible(false);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- destroyWindow(window);
- }
-
- @Test
- public void testWindowDecor01aSimple() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- false /*addGLEventListenerAfterVisible*/);
- System.out.println("Created: "+window);
- int state;
- for(state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
- System.out.println("duration: "+window.getDuration());
- destroyWindow(window);
- }
-
- @Test
- public void testWindowDecor01bSimple() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- true /*addGLEventListenerAfterVisible*/);
- System.out.println("Created: "+window);
- int state;
- for(state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
- System.out.println("duration: "+window.getDuration());
- destroyWindow(window);
- }
-
- @Test
- public void testWindowDecor02DestroyWinTwiceA() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- false /*addGLEventListenerAfterVisible*/);
- int state;
- for(state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
- System.out.println("duration: "+window.getDuration());
- destroyWindow(window);
- }
-
- @Test
- 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 */,
- false /*addGLEventListenerAfterVisible*/);
- Assert.assertNotNull(window1);
-
- GLWindow window2 = createWindow(screen, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- false /*addGLEventListenerAfterVisible*/);
- Assert.assertNotNull(window2);
-
- 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(2,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
-
- int state;
- for(state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
- System.out.println("duration1: "+window1.getDuration());
- System.out.println("duration2: "+window2.getDuration());
-
- destroyWindow(window1);
- destroyWindow(window2);
-
- 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());
- }
-
- @Test
- public void testWindowDecor03TwoWinTwoDisplays() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
-
- Display display1 = NewtFactory.createDisplay(null, false); // local display
- Assert.assertNotNull(display1);
- Display display2 = NewtFactory.createDisplay(null, false); // local display
- Assert.assertNotNull(display2);
- Assert.assertNotSame(display1, display2);
-
- Screen screen1 = NewtFactory.createScreen(display1, 0); // screen 0
- Assert.assertNotNull(screen1);
- GLWindow window1 = createWindow(screen1, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- false /*addGLEventListenerAfterVisible*/);
- Assert.assertNotNull(window1);
-
- Screen screen2 = NewtFactory.createScreen(display2, 0); // screen 0
- Assert.assertNotNull(screen2);
- GLWindow window2 = createWindow(screen2, caps, width, height,
- true /* onscreen */, false /* undecorated */,
- false /*addGLEventListenerAfterVisible*/);
- Assert.assertNotNull(window2);
-
- Assert.assertEquals(2,Display.getActiveDisplayNumber());
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(1,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
-
- Assert.assertEquals(1,display2.getReferenceCount());
- Assert.assertEquals(true,display2.isNativeValid());
- Assert.assertNotNull(display2.getEDTUtil());
- Assert.assertEquals(true,display2.getEDTUtil().isRunning());
- Assert.assertEquals(1,screen2.getReferenceCount());
- Assert.assertEquals(true,screen2.isNativeValid());
-
- int state;
- for(state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
- System.out.println("duration1: "+window1.getDuration());
- System.out.println("duration2: "+window2.getDuration());
-
- // It is observed that some X11 drivers, eg ATI, fglrx 8.78.6,
- // are quite sensitive to multiple Display connections (NEWT Display -> X11 Display).
- // In such cases, closing displays shall happen in the same order as
- // opening them, otherwise some driver related bug appears.
- // You may test this, ie just reverse the destroy order below.
- // See also native test: jogl/test/native/displayMultiple02.c
- destroyWindow(window1);
- destroyWindow(window2);
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- Assert.assertEquals(0,display1.getReferenceCount());
- Assert.assertEquals(false,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(false,display1.getEDTUtil().isRunning());
- 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());
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- if(!MiscUtils.setFieldIfExists(demo, "window", glWindow)) {
- 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 = TestGLWindows01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
deleted file mode 100644
index e73181604..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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 java.io.IOException;
-
-import com.jogamp.test.junit.util.UITestCase;
-import com.jogamp.test.junit.util.MiscUtils;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestGLWindows02NEWTAnimated extends UITestCase {
- static GLProfile glp;
- static int width, height;
- static long durationPerTest = 100; // ms
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- }
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
- Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
- // System.out.println("Requested: "+caps);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- GLWindow glWindow;
- if(null!=screen) {
- Window window = NewtFactory.createWindow(screen, caps);
- Assert.assertNotNull(window);
- glWindow = GLWindow.create(window);
- } else {
- glWindow = GLWindow.create(caps);
- }
- Assert.assertNotNull(glWindow);
- glWindow.setUndecorated(onscreen && undecorated);
-
- GLEventListener demo = new Gears();
- setDemoFields(demo, glWindow);
- glWindow.addGLEventListener(demo);
- glWindow.addWindowListener(new TraceWindowAdapter());
- 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.isNativeValid());
- // Assert.assertEquals(width,glWindow.getWidth());
- // Assert.assertEquals(height,glWindow.getHeight());
- // System.out.println("Created: "+glWindow);
-
- //
- // Create native OpenGL resources .. XGL/WGL/CGL ..
- // equivalent to GLAutoDrawable methods: setVisible(true)
- //
- GLCapabilitiesImmutable caps2 = glWindow.getChosenGLCapabilities();
- Assert.assertNotNull(caps2);
- Assert.assertTrue(caps2.getGreenBits()>=5);
- Assert.assertTrue(caps2.getBlueBits()>=5);
- Assert.assertTrue(caps2.getRedBits()>=5);
- Assert.assertEquals(caps2.isOnscreen(),onscreen);
-
- return glWindow;
- }
-
- static void destroyWindow(GLWindow glWindow) {
- if(null!=glWindow) {
- glWindow.destroy();
- }
- }
-
- @Test
- public void testWindowDecor01Simple() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */);
- Animator animator = new Animator(window);
- Assert.assertTrue(animator.start());
- while(animator.isAnimating() && animator.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- destroyWindow(window);
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertTrue(animator.stop());
- }
-
- @Test
- public void testWindowDecor02DestroyWinTwiceA() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */);
- Animator animator = new Animator(window);
- Assert.assertTrue(animator.start());
- while(animator.isAnimating() && animator.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- destroyWindow(window);
- destroyWindow(window);
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertTrue(animator.stop());
- }
-
- @Test
- 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);
- window1.setPosition(0, 0);
-
- GLWindow window2 = createWindow(screen, caps, width-10, height-10, true /* onscreen */, false /* undecorated */);
- Assert.assertNotNull(window2);
- window2.setPosition(screen.getWidth()-width, 0);
-
- Animator animator = new Animator();
- Assert.assertEquals(false, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- Assert.assertTrue(animator.start());
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- animator.add(window1);
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- animator.add(window2);
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- while(animator.isAnimating() && animator.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- window1.invalidate();
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- while(animator.isAnimating() && animator.getDuration()<2*durationPerTest) {
- Thread.sleep(100);
- }
- window2.invalidate();
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
- Assert.assertTrue(animator.stop());
- }
-
- @Test
- public void testWindowDecor03TwoWinTwoDisplays() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
-
- Display display1 = NewtFactory.createDisplay(null, false); // local display
- Assert.assertNotNull(display1);
- Display display2 = NewtFactory.createDisplay(null, false); // local display
- Assert.assertNotNull(display2);
- Assert.assertNotSame(display1, display2);
-
- Screen screen1 = NewtFactory.createScreen(display1, 0); // screen 0
- Assert.assertNotNull(screen1);
- GLWindow window1 = createWindow(screen1, caps, width, height, true /* onscreen */, false /* undecorated */);
- Assert.assertNotNull(window1);
- window1.setPosition(0, 0);
-
- Screen screen2 = NewtFactory.createScreen(display2, 0); // screen 0
- Assert.assertNotNull(screen2);
- GLWindow window2 = createWindow(screen2, caps, width-10, height-10, true /* onscreen */, false /* undecorated */);
- Assert.assertNotNull(window2);
- window2.setPosition(screen2.getWidth()-width, 0);
-
- Animator animator = new Animator();
- Assert.assertEquals(false, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- Assert.assertTrue(animator.start());
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- animator.add(window1);
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- animator.add(window2);
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- while(animator.isAnimating() && animator.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- destroyWindow(window1);
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- while(animator.isAnimating() && animator.getDuration()<2*durationPerTest) {
- Thread.sleep(100);
- }
- destroyWindow(window2);
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- Assert.assertEquals(true, animator.pause());
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(true, animator.isPaused());
-
- Assert.assertEquals(true, animator.resume());
- Assert.assertEquals(true, animator.isStarted());
- Assert.assertEquals(true, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
-
- Assert.assertTrue(animator.stop());
- Assert.assertEquals(false, animator.isStarted());
- Assert.assertEquals(false, animator.isAnimating());
- Assert.assertEquals(false, animator.isPaused());
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- if(!MiscUtils.setFieldIfExists(demo, "window", glWindow)) {
- 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]);
- }
- }
- String tstname = TestGLWindows02NEWTAnimated.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java
deleted file mode 100644
index 4407ffef1..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Frame;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-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;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestListenerCom01AWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 500;
- static boolean verbose = false;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- }
-
- @Test
- public void testListenerStringPassingAndOrder() throws InterruptedException {
- // setup NEWT GLWindow ..
- GLWindow glWindow = GLWindow.create(new GLCapabilities(null));
- Assert.assertNotNull(glWindow);
- glWindow.setTitle("NEWT - CHILD");
-
- System.out.println("durationPerTest "+durationPerTest);
-
- GLEventListener demo = new Gears();
- setDemoFields(demo, glWindow, false);
- glWindow.addGLEventListener(demo);
-
- WindowEventCom1 wl1 = new WindowEventCom1();
- WindowEventCom2 wl2 = new WindowEventCom2();
- WindowEventCom3 wl3 = new WindowEventCom3();
-
- // TraceWindowAdapter wlT = new TraceWindowAdapter();
- // glWindow.addWindowListener(0, wlT);
- // Assert.assertEquals(wlT, glWindow.getWindowListener(0));
-
- glWindow.addWindowListener(0, wl3);
- glWindow.addWindowListener(0, wl2);
- glWindow.addWindowListener(0, wl1);
-
- Assert.assertEquals(wl1, glWindow.getWindowListener(0));
- Assert.assertEquals(wl2, glWindow.getWindowListener(1));
- Assert.assertEquals(wl3, glWindow.getWindowListener(2));
-
- // attach NEWT GLWindow to AWT Canvas
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
- Frame frame = new Frame("AWT Parent Frame");
- frame.add(newtCanvasAWT);
- frame.setSize(width, height);
- frame.setVisible(true);
-
- Animator animator1 = new Animator(glWindow);
- animator1.start();
- while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) {
- Thread.sleep(100);
- width+=10; height+=10;
- frame.setSize(width, height);
- }
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- frame.dispose();
- glWindow.invalidate();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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 {
- verbose = true;
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- durationPerTest = atoi(args[++i]);
- }
- }
- String tstname = TestListenerCom01AWT.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/TestRemoteGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java
deleted file mode 100644
index fc5327c9d..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.media.opengl.*;
-import com.jogamp.opengl.util.Animator;
-
-import com.jogamp.newt.*;
-import com.jogamp.newt.opengl.*;
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.UITestCase;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.NativeWindowException;
-
-public class TestRemoteGLWindows01NEWT extends UITestCase {
- static GLProfile glp;
- static int width, height;
- static long durationPerTest = 100; // ms
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- // GLProfile.initSingleton(false);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- }
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps)
- throws InterruptedException
- {
- Assert.assertNotNull(caps);
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- GLWindow glWindow;
- if(null!=screen) {
- glWindow = GLWindow.create(screen, caps);
- Assert.assertNotNull(glWindow);
- } else {
- glWindow = GLWindow.create(caps);
- Assert.assertNotNull(glWindow);
- }
-
- GLEventListener demo = new Gears();
- glWindow.addGLEventListener(demo);
-
- glWindow.setSize(512, 512);
- glWindow.setVisible(true);
- Assert.assertEquals(true,glWindow.isVisible());
- Assert.assertEquals(true,glWindow.isNativeValid());
-
- return glWindow;
- }
-
- static void destroyWindow(GLWindow glWindow) {
- if(null!=glWindow) {
- glWindow.invalidate();
- Assert.assertEquals(false,glWindow.isNativeValid());
- Assert.assertEquals(false,glWindow.isValid());
- }
- }
-
- @Test
- public void testRemoteWindow01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- GLWindow window1 = createWindow(null, caps); // local
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(true,window1.isVisible());
- AbstractGraphicsDevice device1 = window1.getScreen().getDisplay().getGraphicsDevice();
-
- System.err.println("GLProfiles window1: "+device1.getConnection()+": "+GLProfile.glAvailabilityToString(device1));
-
- Animator animator1 = new Animator(window1);
- animator1.start();
-
- // Eager initialization of NEWT Display -> AbstractGraphicsDevice -> GLProfile (device)
- Display display2 = NewtFactory.createDisplay("charelle:0.0"); // remote display
- try {
- display2.createNative();
- } catch (NativeWindowException nwe) {
- System.err.println(nwe);
- Assume.assumeNoException(nwe);
- destroyWindow(window1);
- return;
- }
- AbstractGraphicsDevice device2 = display2.getGraphicsDevice();
- GLProfile.initProfiles(device2); // just to make sure
- System.err.println("");
- System.err.println("GLProfiles window2: "+device2.getConnection()+": "+GLProfile.glAvailabilityToString(device2));
-
- Screen screen2 = NewtFactory.createScreen(display2, 0); // screen 0
- GLWindow window2 = createWindow(screen2, caps); // remote
- Assert.assertEquals(true,window2.isNativeValid());
- Assert.assertEquals(true,window2.isVisible());
-
- Animator animator2 = new Animator(window2);
- animator2.start();
-
- for(int state=0; state*100<durationPerTest; state++) {
- Thread.sleep(100);
- }
-
- destroyWindow(window1);
- destroyWindow(window2);
- }
-
- 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 = TestRemoteGLWindows01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestRemoteWindow01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestRemoteWindow01NEWT.java
deleted file mode 100644
index bfb012e3c..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestRemoteWindow01NEWT.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.media.nativewindow.*;
-
-import com.jogamp.newt.*;
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.UITestCase;
-
-public class TestRemoteWindow01NEWT extends UITestCase {
- static int width, height;
-
- @BeforeClass
- public static void initClass() {
- NativeWindowFactory.initSingleton(true);
- width = 640;
- height = 480;
- }
-
- static Window createWindow(Screen screen, Capabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
- Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
- // System.out.println("Requested: "+caps);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- Window window = NewtFactory.createWindow(screen, caps);
- Assert.assertNotNull(window);
- window.setUndecorated(onscreen && undecorated);
- window.setSize(width, height);
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
- window.setVisible(true);
- Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(true,window.isNativeValid());
- // Assert.assertEquals(width,window.getWidth());
- // Assert.assertEquals(height,window.getHeight());
- // System.out.println("Created: "+window);
-
- //
- // Create native OpenGL resources .. XGL/WGL/CGL ..
- // equivalent to GLAutoDrawable methods: setVisible(true)
- //
- CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- Assert.assertNotNull(chosenCapabilities);
- Assert.assertTrue(chosenCapabilities.getGreenBits()>5);
- Assert.assertTrue(chosenCapabilities.getBlueBits()>5);
- Assert.assertTrue(chosenCapabilities.getRedBits()>5);
- Assert.assertEquals(chosenCapabilities.isOnscreen(),onscreen);
-
- return window;
- }
-
- static void destroyWindow(Display display, Screen screen, Window window) {
- if(null!=window) {
- window.destroy();
- }
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
- }
-
- @Test
- public void testRemoteWindow01() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Display display1 = NewtFactory.createDisplay(null); // local display
- Screen screen1 = NewtFactory.createScreen(display1, 0); // screen 0
- Window window1 = createWindow(screen1, caps, width, height, true /* onscreen */, false /* undecorated */);
- window1.setVisible(true);
-
- Assert.assertEquals(true,window1.isNativeValid());
- Assert.assertEquals(true,window1.isVisible());
-
- Display display2 = NewtFactory.createDisplay("charelle:0.0"); // remote display
- try {
- display2.createNative();
- } catch (NativeWindowException nwe) {
- System.err.println(nwe);
- Assume.assumeNoException(nwe);
- destroyWindow(display1, screen1, window1);
- return;
- }
- Screen screen2 = NewtFactory.createScreen(display2, 0); // screen 0
- Window window2 = createWindow(screen2, caps, width, height, true /* onscreen */, false /* undecorated */);
- window2.setVisible(true);
-
- Assert.assertEquals(true,window2.isNativeValid());
- Assert.assertEquals(true,window2.isVisible());
-
- Thread.sleep(500); // 500 ms
-
- destroyWindow(display1, screen1, window1);
- destroyWindow(display2, screen2, window2);
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestRemoteWindow01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java
deleted file mode 100644
index 9f39274c5..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import java.io.IOException;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.jogamp.newt.Display;
-import com.jogamp.newt.NewtFactory;
-import com.jogamp.newt.Screen;
-import com.jogamp.newt.Window;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.MonitorMode;
-import com.jogamp.newt.util.ScreenModeUtil;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-import com.jogamp.test.junit.util.UITestCase;
-import java.util.Iterator;
-import java.util.List;
-import javax.media.nativewindow.Capabilities;
-import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionReadOnly;
-import javax.media.nativewindow.util.SurfaceSize;
-
-public class TestScreenMode00NEWT extends UITestCase {
- static int width, height;
-
- static int waitTimeShort = 4; //1 sec
- static int waitTimeLong = 6; //6 sec
-
-
-
- @BeforeClass
- public static void initClass() {
- NativeWindowFactory.initSingleton(true);
- width = 640;
- height = 480;
- }
-
- @Test
- public void testScreenModeInfo00() throws InterruptedException {
- DimensionReadOnly res = new Dimension(640, 480);
- SurfaceSize surfsz = new SurfaceSize(res, 32);
- DimensionReadOnly mm = new Dimension(500, 400);
- MonitorMode mon = new MonitorMode(surfsz, mm, 60);
- ScreenMode sm_out = new ScreenMode(mon, 90);
- System.err.println("00 out: "+sm_out);
-
- int[] props = ScreenModeUtil.streamOut(sm_out);
- ScreenMode sm_in = ScreenModeUtil.streamIn(props, 0);
- System.err.println("00 in : "+sm_in);
-
- Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize().getResolution(),
- sm_out.getMonitorMode().getSurfaceSize().getResolution());
-
- Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize(),
- sm_out.getMonitorMode().getSurfaceSize());
-
- Assert.assertEquals(sm_in.getMonitorMode().getScreenSizeMM(),
- sm_out.getMonitorMode().getScreenSizeMM());
-
- Assert.assertEquals(sm_in.getMonitorMode(), sm_out.getMonitorMode());
-
- Assert.assertEquals(sm_in, sm_out);
-
- Assert.assertEquals(sm_out.hashCode(), sm_in.hashCode());
- }
-
- @Test
- public void testScreenModeInfo01() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Window window = NewtFactory.createWindow(caps);
- window.setSize(width, height);
- window.setVisible(true);
-
- Screen screen = window.getScreen();
-
- List screenModes = screen.getScreenModes();
- if(null != screenModes) {
- Assert.assertTrue(screenModes.size()>0);
- int i=0;
- for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) {
- System.err.println(i+": "+iter.next());
- }
- ScreenMode sm_o = screen.getOriginalScreenMode();
- Assert.assertNotNull(sm_o);
- ScreenMode sm_c = screen.getOriginalScreenMode();
- Assert.assertNotNull(sm_c);
- System.err.println("orig: "+sm_o);
- System.err.println("curr: "+sm_c);
- } else {
- // no support ..
- System.err.println("Your platform has no ScreenMode change support, sorry");
- }
-
- window.invalidate();
-
- Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,screen.getDisplay().isNativeValid());
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestScreenMode00NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
deleted file mode 100644
index de4def2fa..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import java.io.IOException;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import com.jogamp.opengl.util.Animator;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.jogamp.newt.Display;
-import com.jogamp.newt.NewtFactory;
-import com.jogamp.newt.Screen;
-import com.jogamp.newt.Window;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.ScreenModeUtil;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-import com.jogamp.test.junit.util.UITestCase;
-import java.util.List;
-import javax.media.nativewindow.util.Dimension;
-
-public class TestScreenMode01NEWT extends UITestCase {
- static GLProfile glp;
- static int width, height;
-
- static int waitTimeShort = 1000; // 1 sec
- static int waitTimeLong = 5000; // 5 sec
-
-
-
- @BeforeClass
- public static void initClass() {
- NativeWindowFactory.initSingleton(true);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- }
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
- Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
-
- GLWindow window = GLWindow.create(screen, caps);
- window.setSize(width, height);
- window.addGLEventListener(new Gears());
- Assert.assertNotNull(window);
- window.setVisible(true);
- return window;
- }
-
- static void destroyWindow(Window window) {
- if(null!=window) {
- window.destroy();
- }
- }
-
- @Test
- public void testFullscreenChange01() 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 window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Animator animator = new Animator(window);
- animator.start();
-
- window.setFullscreen(true);
- Assert.assertEquals(true, window.isFullscreen());
-
- Thread.sleep(waitTimeShort);
-
- window.setFullscreen(false);
- Assert.assertEquals(false, window.isFullscreen());
-
- Thread.sleep(waitTimeShort);
-
- animator.stop();
- destroyWindow(window);
- }
-
- @Test
- public void testScreenModeChange01() throws InterruptedException {
- Thread.sleep(waitTimeShort);
-
- 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 window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Assert.assertNotNull(window);
-
- List screenModes = screen.getScreenModes();
- if(null==screenModes) {
- // no support ..
- System.err.println("Your platform has no ScreenMode change support, sorry");
- destroyWindow(window);
- return;
- }
- Assert.assertTrue(screenModes.size()>0);
-
- Animator animator = new Animator(window);
- animator.start();
-
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- Assert.assertNotNull(smCurrent);
- ScreenMode smOrig = screen.getOriginalScreenMode();
- Assert.assertNotNull(smOrig);
- Assert.assertEquals(smCurrent, smOrig);
- System.err.println("[0] current/orig: "+smCurrent);
-
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
-
- ScreenMode sm = (ScreenMode) screenModes.get(0);
- System.err.println("[0] set current: "+sm);
- screen.setCurrentScreenMode(sm);
- Assert.assertEquals(sm, screen.getCurrentScreenMode());
- Assert.assertNotSame(smOrig, screen.getCurrentScreenMode());
-
- Thread.sleep(waitTimeLong);
-
- // check reset ..
-
- ScreenMode saveOrigMode = (ScreenMode) smOrig.clone();
-
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
-
- animator.stop();
- destroyWindow(window);
-
- Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,display.isNativeValid());
-
- screen.createNative(); // trigger native re-creation
-
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertEquals(true,screen.isNativeValid());
-
- smCurrent = screen.getCurrentScreenMode();
- System.err.println("[1] current/orig: "+smCurrent);
-
- Assert.assertNotNull(smCurrent);
- Assert.assertEquals(saveOrigMode, smOrig);
-
- screen.destroy();
-
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,display.isNativeValid());
-
- Thread.sleep(waitTimeShort);
- }
-
- @Test
- public void testScreenModeChangeWithFS01Pre() throws InterruptedException {
- Thread.sleep(waitTimeShort);
- testScreenModeChangeWithFS01Impl(true) ;
- Thread.sleep(waitTimeShort);
- }
-
- @Test
- public void testScreenModeChangeWithFS01Post() throws InterruptedException {
- Thread.sleep(waitTimeShort);
- testScreenModeChangeWithFS01Impl(false) ;
- Thread.sleep(waitTimeShort);
- }
-
- protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
- Display display = NewtFactory.createDisplay(null); // local display
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Animator animator = new Animator(window);
- animator.start();
-
- ScreenMode smOrig = screen.getOriginalScreenMode();
- List screenModes = screen.getScreenModes();
- if(null==screenModes) {
- // no support ..
- destroyWindow(window);
- return;
- }
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
-
- ScreenMode screenMode = (ScreenMode) screenModes.get(0);
- Assert.assertNotNull(screenMode);
-
- if(preFS) {
- System.err.println("[0] set FS pre 0: "+window.isFullscreen());
- window.setFullscreen(true);
- Assert.assertEquals(true, window.isFullscreen());
- System.err.println("[0] set FS pre X: "+window.isFullscreen());
- }
-
- System.err.println("[0] set current: "+screenMode);
- screen.setCurrentScreenMode(screenMode);
-
- if(!preFS) {
- System.err.println("[0] set FS post 0: "+window.isFullscreen());
- window.setFullscreen(true);
- Assert.assertEquals(true, window.isFullscreen());
- System.err.println("[0] set FS post X: "+window.isFullscreen());
- }
-
- Thread.sleep(waitTimeLong);
-
- // check reset ..
-
- ScreenMode saveOrigMode = (ScreenMode) smOrig.clone();
-
- animator.stop();
- destroyWindow(window);
-
- screen.createNative(); // trigger native re-creation
-
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- System.err.println("[1] current/orig: "+smCurrent);
-
- Assert.assertNotNull(smCurrent);
- Assert.assertEquals(saveOrigMode, smOrig);
-
- screen.destroy();
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestScreenMode01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
deleted file mode 100644
index 011af6330..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import java.io.IOException;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import com.jogamp.opengl.util.Animator;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.jogamp.newt.Display;
-import com.jogamp.newt.NewtFactory;
-import com.jogamp.newt.Screen;
-import com.jogamp.newt.Window;
-import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.newt.util.ScreenModeUtil;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-import com.jogamp.test.junit.util.UITestCase;
-import java.util.List;
-import javax.media.nativewindow.util.Dimension;
-
-public class TestScreenMode02NEWT extends UITestCase {
- static GLProfile glp;
- static int width, height;
-
- static int waitTimeShort = 1000; // 1 sec
- static int waitTimeLong = 5000; // 5 sec
-
- @BeforeClass
- public static void initClass() {
- NativeWindowFactory.initSingleton(true);
- width = 640;
- height = 480;
- glp = GLProfile.getDefault();
- }
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
- Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
-
- GLWindow window = GLWindow.create(screen, caps);
- window.setSize(width, height);
- window.addGLEventListener(new Gears());
- Assert.assertNotNull(window);
- window.setVisible(true);
- Assert.assertTrue(window.isVisible());
- return window;
- }
-
- static void destroyWindow(Window window) {
- if(null!=window) {
- window.destroy();
- }
- }
-
- @Test
- public void testScreenRotationChange01() throws InterruptedException {
- Thread.sleep(waitTimeShort);
-
- 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 window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Assert.assertNotNull(window);
-
- List screenModes = screen.getScreenModes();
- if(null==screenModes) {
- // no support ..
- System.err.println("Your platform has no ScreenMode change support, sorry");
- destroyWindow(window);
- return;
- }
- Assert.assertTrue(screenModes.size()>0);
-
- Animator animator = new Animator(window);
- animator.start();
-
- ScreenMode smCurrent = screen.getCurrentScreenMode();
- Assert.assertNotNull(smCurrent);
- ScreenMode smOrig = screen.getOriginalScreenMode();
- Assert.assertNotNull(smOrig);
- Assert.assertEquals(smCurrent, smOrig);
- System.err.println("[0] current/orig: "+smCurrent);
-
- screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate());
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByRotation(screenModes, 90);
- if(null==screenModes) {
- // no rotation support ..
- System.err.println("Your platform has no rotation support, sorry");
- destroyWindow(window);
- return;
- }
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601));
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
- screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
- Assert.assertNotNull(screenModes);
- Assert.assertTrue(screenModes.size()>0);
-
- ScreenMode sm = (ScreenMode) screenModes.get(0);
- System.err.println("[0] set current: "+sm);
- screen.setCurrentScreenMode(sm);
- Assert.assertEquals(sm, screen.getCurrentScreenMode());
- Assert.assertNotSame(smOrig, screen.getCurrentScreenMode());
-
- Thread.sleep(waitTimeLong);
-
- // check reset ..
-
- ScreenMode saveOrigMode = (ScreenMode) smOrig.clone();
-
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
-
- animator.stop();
- destroyWindow(window);
-
- Assert.assertEquals(false,window.isVisible());
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,display.isNativeValid());
-
- screen.createNative(); // trigger native re-creation
-
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertEquals(true,screen.isNativeValid());
-
- smCurrent = screen.getCurrentScreenMode();
- System.err.println("[1] current/orig: "+smCurrent);
-
- Assert.assertNotNull(smCurrent);
- Assert.assertEquals(saveOrigMode, smOrig);
-
- screen.destroy();
-
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(false,display.isNativeValid());
-
- Thread.sleep(waitTimeShort);
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestScreenMode02NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
deleted file mode 100644
index 033542bea..000000000
--- a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-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 com.jogamp.newt.*;
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.UITestCase;
-
-public class TestWindows01NEWT extends UITestCase {
- static int width, height;
-
- @BeforeClass
- public static void initClass() {
- NativeWindowFactory.initSingleton(true);
- width = 640;
- height = 480;
- }
-
- static Window createWindow(Screen screen, Capabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
- Assert.assertNotNull(caps);
- caps.setOnscreen(onscreen);
- // System.out.println("Requested: "+caps);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- Window window = NewtFactory.createWindow(screen, caps);
- Assert.assertNotNull(window);
- window.setUndecorated(onscreen && undecorated);
- window.setSize(width, height);
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
- window.setVisible(true);
- Assert.assertEquals(true,window.isVisible());
- Assert.assertEquals(true,window.isNativeValid());
- // Assert.assertEquals(width,window.getWidth());
- // Assert.assertEquals(height,window.getHeight());
- // System.out.println("Created: "+window);
-
- //
- // Create native OpenGL resources .. XGL/WGL/CGL ..
- // equivalent to GLAutoDrawable methods: setVisible(true)
- //
- CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- Assert.assertNotNull(chosenCapabilities);
- Assert.assertTrue(chosenCapabilities.getGreenBits()>5);
- Assert.assertTrue(chosenCapabilities.getBlueBits()>5);
- Assert.assertTrue(chosenCapabilities.getRedBits()>5);
- Assert.assertEquals(chosenCapabilities.isOnscreen(),onscreen);
-
- return window;
- }
-
- static void destroyWindow(Display display, Screen screen, Window window) {
- if(null!=window) {
- window.destroy();
- }
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
- }
-
- @Test
- public void testWindowNativeRecreate01Simple() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
-
- Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- window.destroy();
- Assert.assertEquals(false,window.isNativeValid());
- Assert.assertEquals(false,window.isVisible());
-
- window.setVisible(true);
- Assert.assertEquals(true,window.isNativeValid());
- Assert.assertEquals(true,window.isVisible());
-
- Thread.sleep(100); // 100 ms
- destroyWindow(display, screen, window);
- }
-
- @Test
- public void testWindowDecor01Simple() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
-
- Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Thread.sleep(100); // 100 ms
- destroyWindow(display, screen, window);
- }
-
- @Test
- public void testWindowDecor02DestroyWinTwiceA() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
-
- Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Thread.sleep(100); // 100 ms
- destroyWindow(null, null, window);
- destroyWindow(display, screen, window);
- }
-
- @Test
- public void testWindowDecor03TwoWin() throws InterruptedException {
- Capabilities caps = new Capabilities();
- Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
-
- Window window1 = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Window window2 = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
- Thread.sleep(100); // 100 ms
- destroyWindow(null, null, window2);
- destroyWindow(display, screen, window1);
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestWindows01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/WindowEventCom1.java b/src/junit/com/jogamp/test/junit/newt/WindowEventCom1.java
deleted file mode 100644
index 74b2ed176..000000000
--- a/src/junit/com/jogamp/test/junit/newt/WindowEventCom1.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import com.jogamp.newt.event.*;
-
-class WindowEventCom1 extends WindowAdapter {
-
- public void windowResized(WindowEvent e) {
- e.setAttachment(new String("WindowEventCom1.windowResized: "+e));
- }
- public void windowMoved(WindowEvent e) {
- e.setAttachment(new String("WindowEventCom1.windowMoved: "+e));
- }
-}
-
diff --git a/src/junit/com/jogamp/test/junit/newt/WindowEventCom2.java b/src/junit/com/jogamp/test/junit/newt/WindowEventCom2.java
deleted file mode 100644
index 551c84acb..000000000
--- a/src/junit/com/jogamp/test/junit/newt/WindowEventCom2.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import com.jogamp.newt.event.*;
-
-class WindowEventCom2 extends WindowAdapter {
-
- public void windowResized(WindowEvent e) {
- String str = (String) e.getAttachment();
- if(null==str) {
- e.setAttachment(new String("WindowEventCom2.windowResized: "+e));
- }
- }
- public void windowMoved(WindowEvent e) {
- String str = (String) e.getAttachment();
- if(null==str) {
- e.setAttachment(new String("WindowEventCom2.windowMoved: "+e));
- }
- }
-}
-
diff --git a/src/junit/com/jogamp/test/junit/newt/WindowEventCom3.java b/src/junit/com/jogamp/test/junit/newt/WindowEventCom3.java
deleted file mode 100644
index 0c097fc4f..000000000
--- a/src/junit/com/jogamp/test/junit/newt/WindowEventCom3.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt;
-
-import com.jogamp.newt.event.*;
-
-class WindowEventCom3 extends WindowAdapter {
-
- public void windowResized(WindowEvent e) {
- String str = (String) e.getAttachment();
- System.out.println("WindowEventCom3.windowResized: "+str);
- }
- public void windowMoved(WindowEvent e) {
- String str = (String) e.getAttachment();
- System.out.println("WindowEventCom3.windowMoved: "+str);
- }
-}
-
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/GLRunnableDummy.java b/src/junit/com/jogamp/test/junit/newt/parenting/GLRunnableDummy.java
deleted file mode 100644
index 2459c8687..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/GLRunnableDummy.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import org.junit.Test;
-
-import javax.media.opengl.*;
-
-public class GLRunnableDummy implements GLRunnable {
- float r=0.0f;
- float g=0.0f;
- float b=0.0f;
- float d=0.001f;
-
- public void run(GLAutoDrawable drawable) {
- GL2ES1 gl = drawable.getGL().getGL2ES1();
- gl.glClearColor(r, g, b, 1f);
- r+=d;
- if(r>1f) {
- r=1f;
- d*=-1f;
- } else if(r<0f) {
- r=0f;
- d*=-1f;
- }
- }
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/KeyAction.java b/src/junit/com/jogamp/test/junit/newt/parenting/KeyAction.java
deleted file mode 100644
index 4948ce9f4..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/KeyAction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-
-package com.jogamp.test.junit.newt.parenting;
-
-import com.jogamp.newt.event.*;
-
-class KeyAction extends KeyAdapter {
- NEWTEventFiFo eventFifo;
-
- public KeyAction(NEWTEventFiFo eventFifo) {
- this.eventFifo = eventFifo;
- }
-
- public void keyTyped(KeyEvent e) {
- eventFifo.put(e);
- }
-}
-
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java
deleted file mode 100644
index 21c0a479c..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java
+++ /dev/null
@@ -1,716 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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 java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting01NEWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 500;
- static long waitAbout10FramesAt30fps = 10*34; // 10 frames @ 30fps
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glCaps = new GLCapabilities(null);
- }
-
- @Test
- public void testWindowParenting01CreateVisibleDestroy() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- Display display = null;
- Screen screen = null;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- Assert.assertNotNull(glWindow1);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- screen = glWindow1.getScreen();
- display = screen.getDisplay();
- Assert.assertEquals(0,display.getReferenceCount());
- Assert.assertEquals(false,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- glWindow1.setSize(640, 480);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- GLWindow glWindow2 = GLWindow.create(glWindow1, glCaps);
- Assert.assertNotNull(glWindow2);
- Assert.assertEquals(false, glWindow2.isVisible());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- Assert.assertSame(glWindow1,glWindow2.getParent());
- Assert.assertSame(screen,glWindow2.getScreen());
- Assert.assertSame(display,glWindow2.getScreen().getDisplay());
- glWindow2.setSize(320, 240);
- GLEventListener demo2 = new Gears();
- setDemoFields(demo2, glWindow2, false);
- glWindow2.addGLEventListener(demo2);
-
- Assert.assertEquals(0,display.getReferenceCount());
- Assert.assertEquals(false,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning()); // GLWindow -> invoke ..
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- // visible test
- Assert.assertEquals(0, glWindow1.getTotalFrames());
- Assert.assertEquals(0, glWindow2.getTotalFrames());
- glWindow1.setVisible(true);
- System.err.println("Frames for setVisible(true): A1: "+glWindow1.getTotalFrames()+", B1: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- Assert.assertEquals(true, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- glWindow1.setVisible(false);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(false, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
-
- glWindow1.resetCounter();
- glWindow2.resetCounter();
- Assert.assertEquals(0, glWindow1.getTotalFrames());
- Assert.assertEquals(0, glWindow2.getTotalFrames());
- glWindow1.setVisible(true);
- System.err.println("Frames for setVisible(true): A2: "+glWindow1.getTotalFrames()+", B2: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- Assert.assertEquals(true, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
-
- glWindow1.resetCounter();
- glWindow2.resetCounter();
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- Assert.assertEquals(true, animator1.isAnimating());
- Assert.assertEquals(false, animator1.isPaused());
- Assert.assertNotNull(animator1.getThread());
- Animator animator2 = new Animator(glWindow2);
- animator2.start();
- Assert.assertEquals(true, animator2.isAnimating());
- Assert.assertEquals(false, animator2.isPaused());
- Assert.assertNotNull(animator2.getThread());
- while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- System.err.println("Frames for setVisible(true): A3: "+glWindow1.getTotalFrames()+", B3: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- Assert.assertEquals(true, animator1.pause());
- Assert.assertEquals(false, animator1.isAnimating());
- Assert.assertEquals(true, animator1.isPaused());
- Assert.assertNotNull(animator1.getThread());
- Assert.assertEquals(true, animator2.pause());
- Assert.assertEquals(false, animator2.isAnimating());
- Assert.assertEquals(true, animator2.isPaused());
- Assert.assertNotNull(animator2.getThread());
-
- glWindow1.resetCounter();
- glWindow2.resetCounter();
- Assert.assertEquals(true, animator1.resume());
- Assert.assertEquals(true, animator1.isAnimating());
- Assert.assertEquals(false, animator1.isPaused());
- Assert.assertNotNull(animator1.getThread());
- Assert.assertEquals(true, animator2.resume());
- Assert.assertEquals(true, animator2.isAnimating());
- Assert.assertEquals(false, animator2.isPaused());
- Assert.assertNotNull(animator2.getThread());
- Thread.sleep(waitAbout10FramesAt30fps);
- System.err.println("Frames for setVisible(true): A4: "+glWindow1.getTotalFrames()+", B4: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
- 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());
-
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- glWindow2.destroy(); // can be recreated, refs are hold
- Assert.assertEquals(true, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isVisible());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- Assert.assertEquals(true, glWindow2.isValid());
-
- 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(1,Display.getActiveDisplayNumber());
-
- glWindow1.destroy(); // can be recreated, refs are hold
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isVisible());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- Assert.assertEquals(true, glWindow2.isValid());
-
- 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(0,Display.getActiveDisplayNumber());
-
- // recreation ..
- glWindow1.resetCounter();
- glWindow2.resetCounter();
- Assert.assertEquals(0, glWindow1.getTotalFrames());
- Assert.assertEquals(0, glWindow2.getTotalFrames());
- glWindow1.setVisible(true);
- Assert.assertEquals(true, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
-
- System.err.println("Frames for setVisible(true): A3: "+glWindow1.getTotalFrames()+", B3: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- // chain glwindow1 -> glwindow2 ; can be recreated ..
- glWindow1.destroy();
- Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow2.isValid());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- 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(0,Display.getActiveDisplayNumber());
-
- glWindow1.invalidate();
- Assert.assertEquals(false, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isValid());
-
- // test double destroy/invalidate ..
- glWindow2.invalidate();
- Assert.assertEquals(false, glWindow2.isValid());
-
- 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(0,Display.getActiveDisplayNumber());
- }
-
- @Test
- public void testWindowParenting02ReparentTop2WinReparentRecreate() throws InterruptedException {
- testWindowParenting02ReparentTop2WinImpl(true);
- }
-
- @Test
- public void testWindowParenting02ReparentTop2WinReparentNative() throws InterruptedException {
- testWindowParenting02ReparentTop2WinImpl(false);
- }
-
- /**
- * @param reparentRecreate true, if the followup reparent should utilize destroy/create, instead of native reparenting
- */
- protected void testWindowParenting02ReparentTop2WinImpl(boolean reparentRecreate) throws InterruptedException {
- int x = 0;
- int y = 0;
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- Display display1 = null;
- Screen screen1 = null;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.setTitle("testWindowParenting02ReparentTop2Win");
- glWindow1.setSize(640, 480);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
- screen1 = glWindow1.getScreen();
- display1 = screen1.getDisplay();
-
- Assert.assertEquals(0,display1.getReferenceCount());
- Assert.assertEquals(false,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen1.getReferenceCount());
- Assert.assertEquals(false,screen1.isNativeValid());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- GLWindow glWindow2 = GLWindow.create(glCaps);
- glWindow2.setSize(320, 240);
- GLEventListener demo2 = new Gears();
- setDemoFields(demo2, glWindow2, false);
- glWindow2.addGLEventListener(demo2);
- Assert.assertSame(screen1, glWindow2.getScreen());
- Assert.assertSame(display1, glWindow2.getScreen().getDisplay());
-
- Assert.assertEquals(0,display1.getReferenceCount());
- Assert.assertEquals(false,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen1.getReferenceCount());
- Assert.assertEquals(false,screen1.isNativeValid());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- Assert.assertEquals(0, glWindow1.getTotalFrames());
- glWindow1.setVisible(true);
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(1,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(true, glWindow1.isVisible());
- System.err.println("Frames for setVisible(true) A1: "+glWindow1.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
-
- Assert.assertEquals(0, glWindow2.getTotalFrames());
- glWindow2.setVisible(true);
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(true, glWindow2.isVisible());
- System.err.println("Frames for setVisible(true) B1: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- Animator animator2 = new Animator(glWindow2);
- animator2.start();
-
- int state = 0;
- int reparentAction;
- while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- // glWindow2 -- child --> glWindow1: compatible
- Assert.assertEquals(true, glWindow2.isVisible());
- System.err.println("Frames(1) "+glWindow2.getTotalFrames());
- reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate);
- System.err.println("Frames(2) "+glWindow2.getTotalFrames());
- Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction);
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
- Assert.assertSame(glWindow1,glWindow2.getParent());
- System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertSame(screen1,glWindow2.getScreen());
- Assert.assertSame(display1,glWindow2.getScreen().getDisplay());
- Assert.assertEquals(2,screen1.getReferenceCount());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- break;
-
- case 1:
- // glWindow2 --> top
- Assert.assertEquals(true, glWindow2.isVisible());
-
- reparentAction = glWindow2.reparentWindow(null, reparentRecreate);
- Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction);
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
- Assert.assertNull(glWindow2.getParent());
- System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertSame(screen1,glWindow2.getScreen());
- Assert.assertSame(display1,glWindow2.getScreen().getDisplay());
- Assert.assertEquals(2,screen1.getReferenceCount());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- break;
- }
- state++;
- }
- //
- // both windows are now top level
- //
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
- 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());
-
- // pre-destroy check (both valid and running)
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- // destroy glWindow2
- glWindow2.destroy();
- Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(true, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow2.isValid());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- Assert.assertEquals(false, glWindow2.isVisible());
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(1,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
-
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- // destroy glWindow1
- glWindow1.destroy();
- Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow2.isValid());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- Assert.assertEquals(false, glWindow2.isVisible());
-
- Assert.assertEquals(0,display1.getReferenceCount());
- Assert.assertEquals(false,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(false,display1.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen1.getReferenceCount());
- Assert.assertEquals(false,screen1.isNativeValid());
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- glWindow1.invalidate();
- Assert.assertEquals(false, glWindow1.isValid());
- Assert.assertEquals(true, glWindow2.isValid());
-
- glWindow2.invalidate();
- Assert.assertEquals(false, glWindow2.isValid());
- }
-
- @Test
- public void testWindowParenting03ReparentWin2TopReparentRecreate() throws InterruptedException {
- testWindowParenting03ReparentWin2TopImpl(true);
- }
-
- @Test
- public void testWindowParenting03ReparentWin2TopReparentNative() throws InterruptedException {
- testWindowParenting03ReparentWin2TopImpl(false);
- }
-
- protected void testWindowParenting03ReparentWin2TopImpl(boolean reparentRecreate) throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- Display display1 = null;
- Screen screen1 = null;
- Display display2 = null;
- Screen screen2 = null;
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- screen1 = glWindow1.getScreen();
- display1 = screen1.getDisplay();
- glWindow1.setTitle("testWindowParenting03ReparentWin2Top");
- glWindow1.setSize(640, 480);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- Assert.assertEquals(0,display1.getReferenceCount());
- Assert.assertEquals(false,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen1.getReferenceCount());
- Assert.assertEquals(false,screen1.isNativeValid());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- GLWindow glWindow2 = GLWindow.create(glWindow1, glCaps);
- screen2 = glWindow2.getScreen();
- display2 = screen2.getDisplay();
- glWindow2.setSize(320, 240);
- GLEventListener demo2 = new Gears();
- setDemoFields(demo2, glWindow2, false);
- glWindow2.addGLEventListener(demo2);
-
- Assert.assertEquals(0,display2.getReferenceCount());
- Assert.assertEquals(false,display2.isNativeValid());
- Assert.assertNotNull(display2.getEDTUtil());
- Assert.assertEquals(true,display2.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen2.getReferenceCount());
- Assert.assertEquals(false,screen2.isNativeValid());
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- Assert.assertSame(screen1,glWindow2.getScreen());
- Assert.assertSame(display1,glWindow2.getScreen().getDisplay());
-
- Assert.assertEquals(0, glWindow1.getTotalFrames());
- Assert.assertEquals(0, glWindow2.getTotalFrames());
- glWindow1.setVisible(true);
- System.err.println("Frames for setVisible(): A1: "+glWindow1.getTotalFrames()+", B1: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow1.getTotalFrames());
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertSame(glWindow1,glWindow2.getParent());
- Assert.assertSame(screen1,glWindow2.getScreen());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- Animator animator2 = new Animator(glWindow2);
- animator2.start();
-
- int state = 0;
- int reparentAction;
- while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- Assert.assertEquals(true, glWindow2.isVisible());
- reparentAction = glWindow2.reparentWindow(null, reparentRecreate);
- Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction);
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
- System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
- Assert.assertNull(glWindow2.getParent());
- Assert.assertSame(screen1,glWindow2.getScreen());
- Assert.assertSame(display1,glWindow2.getScreen().getDisplay());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- break;
- case 1:
- Assert.assertEquals(true, glWindow2.isVisible());
- reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate);
- Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction);
- Assert.assertEquals(true, glWindow2.isVisible());
- Assert.assertEquals(true, glWindow2.isNativeValid());
- System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3 "+glWindow2.getTotalFrames());
- Assert.assertTrue(0 < glWindow2.getTotalFrames());
- Assert.assertSame(glWindow1,glWindow2.getParent());
- Assert.assertSame(screen1,glWindow2.getScreen());
- Assert.assertSame(display1,glWindow2.getScreen().getDisplay());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- break;
- }
- state++;
- }
- //
- // glwindow2 is child of glwindow1
- //
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
- 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());
-
- Assert.assertEquals(1,display1.getReferenceCount());
- Assert.assertEquals(true,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(true,display1.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen1.getReferenceCount());
- Assert.assertEquals(true,screen1.isNativeValid());
- Assert.assertSame(glWindow1,glWindow2.getParent());
- Assert.assertSame(screen1,glWindow2.getScreen());
-
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
-
- glWindow1.destroy(); // should destroy both windows, actually, since glWindow2 is a child
- Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(true, glWindow2.isValid());
- Assert.assertEquals(false, glWindow2.isNativeValid());
- Assert.assertEquals(false, glWindow2.isVisible());
-
- Assert.assertEquals(0,display1.getReferenceCount());
- Assert.assertEquals(false,display1.isNativeValid());
- Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(false,display1.getEDTUtil().isRunning());
- 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());
-
- glWindow2.destroy(); // dbl destroy check ..
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertEquals(false, glWindow2.isNativeValid());
-
- glWindow1.invalidate(); // parent -> child
- Assert.assertEquals(false, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isValid());
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getWindow())) {
- 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.err.println("durationPerTest: "+durationPerTest);
- String tstname = TestParenting01NEWT.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
-
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java
deleted file mode 100644
index fd52c86a1..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Container;
-import java.awt.Frame;
-import java.awt.Dimension;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-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;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting01aAWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 800;
- static long waitReparent = 0;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() throws InterruptedException {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glCaps = new GLCapabilities(null);
- // Thread.sleep(10000);
- }
-
- @Test
- public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- Assert.assertNotNull(glWindow1);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- 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");
- frame1.setLayout(new BorderLayout());
- frame1.add(new Button("North"), BorderLayout.NORTH);
- frame1.add(new Button("South"), BorderLayout.SOUTH);
- frame1.add(new Button("East"), BorderLayout.EAST);
- frame1.add(new Button("West"), BorderLayout.WEST);
-
- Container container1 = new Container();
- container1.setLayout(new BorderLayout());
- container1.add(new Button("north"), BorderLayout.NORTH);
- container1.add(new Button("south"), BorderLayout.SOUTH);
- container1.add(new Button("east"), BorderLayout.EAST);
- container1.add(new Button("west"), BorderLayout.WEST);
- container1.add(newtCanvasAWT, BorderLayout.CENTER);
-
- frame1.add(container1, BorderLayout.CENTER);
- frame1.setSize(width, height);
-
- // visible test
- frame1.setVisible(true);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- frame1.setVisible(false);
- Assert.assertEquals(true, glWindow1.isValid());
-
- frame1.setVisible(true);
- Assert.assertEquals(true, glWindow1.isValid());
-
- frame1.remove(newtCanvasAWT);
- // Assert.assertNull(glWindow1.getParent());
- Assert.assertEquals(true, glWindow1.isValid());
-
- frame1.dispose();
- Assert.assertEquals(true, glWindow1.isValid());
-
- glWindow1.invalidate();
- //Assert.assertEquals(false, glWindow1.isValid());
- }
-
- @Test
- public void testWindowParenting02CreateVisibleDestroy2Defered() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- Assert.assertNotNull(glWindow1);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- 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");
- Assert.assertNotNull(frame);
- frame.setSize(width, height);
-
- // visible test
- frame.setVisible(true);
-
- frame.add(newtCanvasAWT);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- frame.dispose();
- glWindow1.invalidate();
- }
-
- @Test
- public void testWindowParenting02CreateVisibleDestroy3Odd() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- Frame frame = new Frame("AWT Parent Frame");
- Assert.assertNotNull(frame);
- frame.setSize(width, height);
-
- // visible test
- frame.setVisible(true);
-
- frame.add(newtCanvasAWT);
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- Assert.assertEquals(true, animator1.isStarted());
- Assert.assertEquals(true, animator1.isAnimating());
- while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
-
- Assert.assertEquals(true, animator1.isAnimating()); // !!!
-
- frame.dispose();
- glWindow1.invalidate();
- }
-
- @Test
- public void testWindowParenting03ReparentNewtWin2Top() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- Frame frame = new Frame("AWT Parent Frame");
- frame.setSize(width, height);
- frame.setLocation(640, 480);
- frame.setVisible(true);
-
- frame.add(newtCanvasAWT);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
-
- int state = 0;
- while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- glWindow1.reparentWindow(null);
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- break;
- case 1:
- glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
- break;
- }
- state++;
- }
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- frame.dispose();
- glWindow1.invalidate();
- }
-
- @Test
- public void testWindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- 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);
- frame.add(new Button("East"), BorderLayout.EAST);
- frame.add(new Button("West"), BorderLayout.WEST);
- frame.setSize(width, height);
- frame.setLocation(640, 480);
- frame.setVisible(true);
-
- frame.add(newtCanvasAWT, BorderLayout.CENTER);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
-
- int state = 0;
- while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- glWindow1.reparentWindow(null);
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- break;
- case 1:
- glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow());
- Assert.assertEquals(true, glWindow1.isNativeValid());
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
- break;
- }
- state++;
- }
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- frame.dispose();
- glWindow1.invalidate();
- }
-
- @Test
- public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.setUndecorated(true);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- 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);
- frame1.add(new Button("East"), BorderLayout.EAST);
- frame1.add(new Button("West"), BorderLayout.WEST);
- frame1.setSize(width, height);
- frame1.setLocation(0, 0);
- frame1.setVisible(true);
-
- 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);
- frame2.add(new Button("East"), BorderLayout.EAST);
- frame2.add(new Button("West"), BorderLayout.WEST);
- frame2.setSize(width, height);
- frame2.setLocation(640, 480);
- frame2.setVisible(true);
-
- frame1.add(newtCanvasAWT, BorderLayout.CENTER);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
-
- int state = 0;
- while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- frame1.remove(newtCanvasAWT);
- frame2.add(newtCanvasAWT, BorderLayout.CENTER);
- break;
- case 1:
- frame2.remove(newtCanvasAWT);
- frame1.add(newtCanvasAWT, BorderLayout.CENTER);
- break;
- }
- state++;
- }
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- frame1.dispose();
- frame2.dispose();
- glWindow1.invalidate();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getWindow())) {
- 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]);
- } else if(args[i].equals("-wait")) {
- waitReparent = atoi(args[++i]);
- }
- }
- String tstname = TestParenting01aAWT.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/parenting/TestParenting01bAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java
deleted file mode 100644
index 89cefa8b1..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Frame;
-import java.awt.Dimension;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.FPSAnimator;
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting01bAWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 800;
- static long waitReparent = 0;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glCaps = new GLCapabilities(null);
- }
-
- @Test
- public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException {
- testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(25);
- }
-
- @Test
- public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException {
- testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(0);
- }
-
- public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.setUndecorated(true);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- 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);
- frame1.add(new Button("East"), BorderLayout.EAST);
- frame1.add(new Button("West"), BorderLayout.WEST);
- frame1.setSize(width, height);
- frame1.setLocation(0, 0);
- frame1.setVisible(true);
-
- 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);
- frame2.add(new Button("East"), BorderLayout.EAST);
- frame2.add(new Button("West"), BorderLayout.WEST);
- frame2.setSize(width, height);
- frame2.setLocation(640, 480);
- frame2.setVisible(true);
-
- frame1.add(newtCanvasAWT, BorderLayout.CENTER);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- GLAnimatorControl animator1;
- if(fps>0) {
- animator1 = new FPSAnimator(glWindow1, fps);
- } else {
- animator1 = new Animator(glWindow1);
- }
- animator1.start();
-
- int state;
- for(state=0; state<3; state++) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- frame1.remove(newtCanvasAWT);
- frame2.add(newtCanvasAWT, BorderLayout.CENTER);
- break;
- case 1:
- frame2.remove(newtCanvasAWT);
- frame1.add(newtCanvasAWT, BorderLayout.CENTER);
- break;
- }
- }
-
- Assert.assertEquals(true, animator1.isAnimating());
- Assert.assertEquals(false, animator1.isPaused());
- Assert.assertNotNull(animator1.getThread());
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
- Assert.assertEquals(false, animator1.isPaused());
- Assert.assertEquals(null, animator1.getThread());
-
- frame1.dispose();
- frame2.dispose();
- glWindow1.invalidate();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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]);
- } else if(args[i].equals("-wait")) {
- waitReparent = atoi(args[++i]);
- }
- }
- String tstname = TestParenting01bAWT.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/parenting/TestParenting01cAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java
deleted file mode 100644
index b79f4c57c..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Container;
-import java.awt.Frame;
-import java.awt.Dimension;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting01cAWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 800;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glCaps = new GLCapabilities(null);
- }
-
- @Test
- public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException {
- int x = 0;
- int y = 0;
- int i;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- Assert.assertNotNull(glWindow1);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- 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");
- frame1.setLayout(new BorderLayout());
- frame1.add(new Button("North"), BorderLayout.NORTH);
- frame1.add(new Button("South"), BorderLayout.SOUTH);
- frame1.add(new Button("East"), BorderLayout.EAST);
- frame1.add(new Button("West"), BorderLayout.WEST);
-
- Container container1 = new Container();
- container1.setLayout(new BorderLayout());
- container1.add(new Button("north"), BorderLayout.NORTH);
- container1.add(new Button("south"), BorderLayout.SOUTH);
- container1.add(new Button("east"), BorderLayout.EAST);
- container1.add(new Button("west"), BorderLayout.WEST);
- container1.add(newtCanvasAWT, BorderLayout.CENTER);
-
- frame1.add(container1, BorderLayout.CENTER);
- frame1.setSize(width, height);
-
- // visible test
- frame1.setVisible(true);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- for(i=0; i*100<durationPerTest; i++) {
- Thread.sleep(100);
- }
-
- frame1.setVisible(false);
- Assert.assertEquals(true, glWindow1.isValid());
-
- frame1.setVisible(true);
- Assert.assertEquals(true, glWindow1.isValid());
-
- frame1.remove(newtCanvasAWT);
- // Assert.assertNull(glWindow1.getParent());
- Assert.assertEquals(true, glWindow1.isValid());
-
- frame1.dispose();
- Assert.assertEquals(true, glWindow1.isValid());
-
- glWindow1.invalidate();
- //Assert.assertEquals(false, glWindow1.isValid());
- }
-
- @Test
- public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.setUndecorated(true);
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
- 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);
- frame1.add(new Button("East"), BorderLayout.EAST);
- frame1.add(new Button("West"), BorderLayout.WEST);
- frame1.setSize(width, height);
- frame1.setLocation(0, 0);
- frame1.setVisible(true);
-
- 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);
- frame2.add(new Button("East"), BorderLayout.EAST);
- frame2.add(new Button("West"), BorderLayout.WEST);
- frame2.setSize(width, height);
- frame2.setLocation(640, 480);
- frame2.setVisible(true);
-
- frame1.add(newtCanvasAWT, BorderLayout.CENTER);
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- int state;
- for(state=0; state<3; state++) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- frame1.remove(newtCanvasAWT);
- frame2.add(newtCanvasAWT, BorderLayout.CENTER);
- break;
- case 1:
- frame2.remove(newtCanvasAWT);
- frame1.add(newtCanvasAWT, BorderLayout.CENTER);
- break;
- }
- }
-
- frame1.dispose();
- frame2.dispose();
- glWindow1.invalidate();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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]);
- }
- }
- String tstname = TestParenting01cAWT.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/parenting/TestParenting01cSwingAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java
deleted file mode 100644
index fb2c74455..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-import java.lang.reflect.*;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
-
-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;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-
-public class TestParenting01cSwingAWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 800;
- static long waitReparent = 0;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- glCaps = new GLCapabilities(null);
- }
-
- @Test
- public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- /**
- * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow
- */
- GLWindow glWindow1 = GLWindow.create(glCaps);
- Assert.assertNotNull(glWindow1);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- final GLWindow _glWindow1 = glWindow1;
- final GLRunnable _glRunnable = new GLRunnableDummy();
- Thread disturbanceThread = new Thread(new Runnable() {
- public void run() {
- System.out.println("$");
- while(true)
- {
- try {
- _glWindow1.invoke(true, _glRunnable);
- Thread.yield();
- } catch (Throwable t) {}
- }
- }
- });
- disturbanceThread.start();
-
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
- Assert.assertNotNull(newtCanvasAWT);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
-
- Container container1 = new Container();
- container1.setLayout(new BorderLayout());
- container1.add(new Button("north"), BorderLayout.NORTH);
- container1.add(new Button("south"), BorderLayout.SOUTH);
- container1.add(new Button("east"), BorderLayout.EAST);
- container1.add(new Button("west"), BorderLayout.WEST);
- container1.add(newtCanvasAWT, BorderLayout.CENTER);
-
- JPanel jPanel1 = new JPanel();
- jPanel1.setLayout(new BorderLayout());
- jPanel1.add(new Button("north"), BorderLayout.NORTH);
- jPanel1.add(new Button("south"), BorderLayout.SOUTH);
- jPanel1.add(new Button("east"), BorderLayout.EAST);
- jPanel1.add(new Button("west"), BorderLayout.WEST);
- jPanel1.add(container1, BorderLayout.CENTER);
-
- JFrame jFrame1 = new JFrame("Swing Parent JFrame");
- // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event!
- 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
-
- final JFrame _jFrame1 = jFrame1;
- final JPanel _jPanel1 = jPanel1;
- final Container _container1 = container1;
-
- // visible test
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) {
- Thread.sleep(100);
- }
- System.out.println("Demos: 2 - StopAnimator");
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- System.out.println("Demos: 3 - !Visible");
- _jFrame1.setVisible(false);
- } });
- Assert.assertEquals(true, glWindow1.isValid());
-
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- System.out.println("Demos: 4 - Visible");
- _jFrame1.setVisible(true);
- } });
- Assert.assertEquals(true, glWindow1.isValid());
-
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- System.out.println("Demos: 5 - X Container");
- _jPanel1.remove(_container1);
- } });
- // Assert.assertNull(glWindow1.getParent());
- Assert.assertEquals(true, glWindow1.isValid());
-
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- _jFrame1.dispose();
- } });
- Assert.assertEquals(true, glWindow1.isValid());
-
- glWindow1.invalidate();
- //Assert.assertEquals(false, glWindow1.isValid());
- }
-
- @Test
- public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- /**
- * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow
- */
- GLWindow glWindow1 = GLWindow.create(glCaps);
- Assert.assertNotNull(glWindow1);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
- glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, glWindow1, false);
- glWindow1.addGLEventListener(demo1);
- Animator animator1 = new Animator(glWindow1);
- animator1.start();
- final GLWindow _glWindow1 = glWindow1;
- final GLRunnable _glRunnable = new GLRunnableDummy();
- Thread disturbanceThread = new Thread(new Runnable() {
- public void run() {
- System.out.println("$");
- while(true)
- {
- try {
- _glWindow1.invoke(true, _glRunnable);
- Thread.yield();
- } catch (Throwable t) {}
- }
- }
- });
- disturbanceThread.start();
-
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
- Assert.assertNotNull(newtCanvasAWT);
- Assert.assertEquals(false, glWindow1.isVisible());
- Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertNull(glWindow1.getParent());
-
- Container container1 = new Container();
- container1.setLayout(new BorderLayout());
- container1.add(new Button("north"), BorderLayout.NORTH);
- container1.add(new Button("south"), BorderLayout.SOUTH);
- container1.add(new Button("east"), BorderLayout.EAST);
- container1.add(new Button("west"), BorderLayout.WEST);
- container1.add(newtCanvasAWT, BorderLayout.CENTER);
-
- JPanel jPanel1 = new JPanel();
- jPanel1.setLayout(new BorderLayout());
- jPanel1.add(new Button("north"), BorderLayout.NORTH);
- jPanel1.add(new Button("south"), BorderLayout.SOUTH);
- jPanel1.add(new Button("east"), BorderLayout.EAST);
- jPanel1.add(new Button("west"), BorderLayout.WEST);
- jPanel1.add(container1, BorderLayout.CENTER);
-
- JFrame jFrame1 = new JFrame("Swing Parent JFrame");
- // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event!
- jFrame1.setContentPane(jPanel1);
- jFrame1.setLocation(0, 0);
- jFrame1.setSize(width, height);
- jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
-
- JPanel jPanel2 = new JPanel();
- jPanel2.setLayout(new BorderLayout());
- jPanel2.add(new Button("north"), BorderLayout.NORTH);
- jPanel2.add(new Button("south"), BorderLayout.SOUTH);
- jPanel2.add(new Button("east"), BorderLayout.EAST);
- jPanel2.add(new Button("west"), BorderLayout.WEST);
-
- JFrame jFrame2 = new JFrame("Swing Parent JFrame");
- // jFrame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- jFrame2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event!
- jFrame2.setContentPane(jPanel2);
- jFrame2.setLocation(640, 480);
- jFrame2.setSize(width, height);
- jFrame2.setVisible(true); // from here on, we need to run modifications on EDT
-
- final NewtCanvasAWT _newtCanvasAWT = newtCanvasAWT;
- final JFrame _jFrame1 = jFrame1;
- final JPanel _jPanel1 = jPanel1;
- final Container _container1 = container1;
- final JFrame _jFrame2 = jFrame2;
- final JPanel _jPanel2 = jPanel2;
-
- // visible test
- Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
-
- int state = 0;
- while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) {
- Thread.sleep(durationPerTest);
- switch(state) {
- case 0:
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- _container1.remove(_newtCanvasAWT);
- _jPanel2.add(_newtCanvasAWT, BorderLayout.CENTER);
- } });
- break;
- case 1:
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- _jPanel2.remove(_newtCanvasAWT);
- _container1.add(_newtCanvasAWT, BorderLayout.CENTER);
- } });
- break;
- }
- state++;
- }
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
-
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- _jFrame1.setVisible(false);
- _jFrame2.setVisible(false);
- } });
- Assert.assertEquals(true, glWindow1.isValid());
-
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- _jFrame1.dispose();
- _jFrame2.dispose();
- } });
- Assert.assertEquals(true, glWindow1.isValid());
-
- glWindow1.invalidate();
- //Assert.assertEquals(false, glWindow1.isValid());
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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]);
- } else if(args[i].equals("-wait")) {
- waitReparent = atoi(args[++i]);
- }
- }
- System.out.println("durationPerTest "+durationPerTest);
- System.out.println("waitReparent "+waitReparent);
- String tstname = TestParenting01cSwingAWT.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/parenting/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java
deleted file mode 100644
index 6c9e5b2b2..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Frame;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-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;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting02AWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 500;
- static long waitReparent = 300;
- static boolean verbose = false;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- }
-
- @Test
- public void testWindowParenting01NewtChildOnAWTParentLayouted() throws InterruptedException {
- runNewtChildOnAWTParent(true, false);
- }
-
- @Test
- public void testWindowParenting02NewtChildOnAWTParentLayoutedDef() throws InterruptedException {
- runNewtChildOnAWTParent(true, true);
- }
-
- @Test
- public void testWindowParenting03NewtChildOnAWTParentDirect() throws InterruptedException {
- runNewtChildOnAWTParent(false, false);
- }
-
- @Test
- public void testWindowParenting04NewtChildOnAWTParentDirectDef() throws InterruptedException {
- runNewtChildOnAWTParent(false, true);
- }
-
- public void runNewtChildOnAWTParent(boolean useLayout, boolean deferredPeer) throws InterruptedException {
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- // setup NEWT GLWindow ..
- GLWindow glWindow = GLWindow.create(new GLCapabilities(null));
- Assert.assertNotNull(glWindow);
- glWindow.setTitle("NEWT - CHILD");
- glWindow.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
- glWindow.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo)));
- GLEventListener demo = new Gears();
- setDemoFields(demo, glWindow, false);
- glWindow.addGLEventListener(demo);
-
- // attach NEWT GLWindow to AWT Canvas
- NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
- Assert.assertNotNull(newtCanvasAWT);
- Assert.assertEquals(false, glWindow.isVisible());
- Assert.assertEquals(false, glWindow.isNativeValid());
- Assert.assertNull(glWindow.getParent());
-
- Frame frame = new Frame("AWT Parent Frame");
- Assert.assertNotNull(frame);
- if(useLayout) {
- frame.setLayout(new BorderLayout());
- frame.add(new Button("North"), BorderLayout.NORTH);
- frame.add(new Button("South"), BorderLayout.SOUTH);
- frame.add(new Button("East"), BorderLayout.EAST);
- frame.add(new Button("West"), BorderLayout.WEST);
- if(!deferredPeer) {
- frame.add(newtCanvasAWT, BorderLayout.CENTER);
- }
- } else {
- if(!deferredPeer) {
- frame.add(newtCanvasAWT);
- }
- }
-
- frame.setSize(width, height);
-
- frame.setVisible(true);
- // X11: true, Windows: false - Assert.assertEquals(true, glWindow.isVisible());
-
- if(deferredPeer) {
- if(useLayout) {
- frame.add(newtCanvasAWT, BorderLayout.CENTER);
- } else {
- frame.add(newtCanvasAWT);
- }
- }
-
- // Since it is not defined when AWT's addNotify call happen
- // we just have to wait for it in this junit test
- // because we have assertions on the state.
- // Regular application shall not need to do that.
- do {
- Thread.yield();
- // 1st display .. creation
- glWindow.display();
- } while(!glWindow.isNativeValid()) ;
-
- Assert.assertEquals(true, glWindow.isNativeValid());
- Assert.assertNotNull(glWindow.getParent());
- if(verbose) {
- System.out.println("+++++++++++++++++++ 1st ADDED");
- }
- Thread.sleep(waitReparent);
-
- if(useLayout) {
- // test some fancy re-layout ..
- frame.remove(newtCanvasAWT);
- Assert.assertEquals(false, glWindow.isVisible());
- Assert.assertEquals(true, glWindow.isNativeValid());
- Assert.assertNull(glWindow.getParent());
- if(verbose) {
- System.out.println("+++++++++++++++++++ REMOVED!");
- }
- Thread.sleep(waitReparent);
-
- // should recreate properly ..
- frame.add(newtCanvasAWT, BorderLayout.CENTER);
- glWindow.display();
- Assert.assertEquals(true, glWindow.isVisible());
- Assert.assertEquals(true, glWindow.isNativeValid());
- Assert.assertNotNull(glWindow.getParent());
- if(verbose) {
- System.out.println("+++++++++++++++++++ 2nd ADDED");
- }
- Thread.sleep(waitReparent);
- }
-
- long duration = durationPerTest;
- long step = 20;
- NEWTEvent event;
- boolean shouldQuit = false;
-
- while (duration>0 && !shouldQuit) {
- glWindow.display();
- Thread.sleep(step);
- duration -= step;
-
- while( null != ( event = (NEWTEvent) eventFifo.get() ) ) {
- Window source = (Window) event.getSource();
- if(event instanceof KeyEvent) {
- KeyEvent keyEvent = (KeyEvent) event;
- switch(keyEvent.getKeyChar()) {
- case 'q':
- shouldQuit = true;
- break;
- case 'f':
- source.setFullscreen(!source.isFullscreen());
- break;
- }
- }
- }
- }
- if(verbose) {
- System.out.println("+++++++++++++++++++ END");
- }
- Thread.sleep(waitReparent);
-
- glWindow.invalidate();
- if(useLayout) {
- frame.remove(newtCanvasAWT);
- }
- frame.dispose();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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 {
- verbose = true;
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- durationPerTest = atoi(args[++i]);
- } else if(args[i].equals("-wait")) {
- waitReparent = atoi(args[++i]);
- }
- }
- String tstname = TestParenting02AWT.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/parenting/TestParenting02NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java
deleted file mode 100644
index 23e3e1c44..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02NEWT.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-
-package com.jogamp.test.junit.newt.parenting;
-
-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.opengl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.*;
-
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting02NEWT extends UITestCase {
- static int width, height;
- static long durationPerTest = 500;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- width = 640;
- height = 480;
- }
-
- static Window createWindow(Screen screen, Capabilities caps) {
- Assert.assertNotNull(caps);
- Window window = NewtFactory.createWindow(screen, caps) ;
- Assert.assertNotNull(window);
- return window;
- }
-
- static Window createWindow(NativeWindow parent, Capabilities caps) {
- Assert.assertNotNull(caps);
- Window window = NewtFactory.createWindow(parent, caps);
- window.setUndecorated(true);
- Assert.assertNotNull(window);
- return window;
- }
-
- static void destroyWindow(Display display, Screen screen, Window window, GLWindow glWindow) {
- if(null!=glWindow) {
- glWindow.destroy();
- }
- if(null!=window) {
- window.destroy();
- }
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
- }
-
- @Test
- public void testWindowParenting01NewtOnNewtParentChildDraw() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(null);
- Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
-
- int x = 1;
- int y = 1;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- Window window1 = createWindow(screen, caps);
- Assert.assertNotNull(window1);
- GLWindow glWindow1 = GLWindow.create(window1);
- Assert.assertNotNull(glWindow1);
- glWindow1.setSize(width, height);
- Assert.assertEquals(width,glWindow1.getWidth());
- Assert.assertEquals(height,glWindow1.getHeight());
- glWindow1.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - PARENT");
- glWindow1.setPosition(x,y);
- glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
- glWindow1.addWindowListener(new TraceWindowAdapter());
-
- GLEventListener demo1 = new RedSquare();
- setDemoFields(demo1, window1, glWindow1, false);
- // glWindow1.addGLEventListener(demo1);
-
- glWindow1.setVisible(true);
- CapabilitiesImmutable capsChosen = glWindow1.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- Assert.assertNotNull(capsChosen);
- Assert.assertTrue(capsChosen.isOnscreen()==true);
-
- Window window2 = createWindow(window1, caps);
- Assert.assertNotNull(window2);
- GLWindow glWindow2 = GLWindow.create(window2);
- Assert.assertNotNull(glWindow2);
- glWindow2.setSize(width/2, height/2);
- //Assert.assertEquals(width/2,glWindow2.getWidth());
- //Assert.assertEquals(height/2,glWindow2.getHeight());
- glWindow2.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - CHILD");
- glWindow2.setPosition(glWindow1.getWidth()/2, glWindow1.getHeight()/2);
- glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
- glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo)));
- // glWindow2.addMouseListener(new TraceMouseAdapter());
-
- GLEventListener demo2 = new Gears();
- setDemoFields(demo2, window2, glWindow2, false);
- // glWindow2.addGLEventListener(demo2);
-
- glWindow2.setVisible(true);
- capsChosen = glWindow2.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- Assert.assertNotNull(capsChosen);
- Assert.assertTrue(capsChosen.isOnscreen()==true);
-
- glWindow1.addGLEventListener(demo1);
- glWindow2.addGLEventListener(demo2);
-
- boolean shouldQuit = false;
- long duration = durationPerTest;
- long step = 20;
- NEWTEvent event;
-
- while (duration>0 && !shouldQuit) {
- glWindow1.display();
- glWindow2.display();
- Thread.sleep(step);
- duration -= step;
- x += 1;
- y += 1;
- glWindow1.setPosition(x,y);
- glWindow2.setPosition(glWindow1.getWidth()/2,glWindow1.getHeight()/2-y);
-
- while( null != ( event = (NEWTEvent) eventFifo.get() ) ) {
- Window source = (Window) event.getSource();
- if(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY == event.getEventType()) {
- shouldQuit = true;
- } else if(event instanceof KeyEvent) {
- KeyEvent keyEvent = (KeyEvent) event;
- switch(keyEvent.getKeyChar()) {
- case 'q':
- shouldQuit = true;
- break;
- case 'f':
- source.setFullscreen(!source.isFullscreen());
- break;
- }
- }
- }
- }
- destroyWindow(null, null, window2, glWindow2);
- destroyWindow(display, screen, window1, glWindow1);
- }
-
- public static void setDemoFields(GLEventListener demo, Window window, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(window);
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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]);
- }
- }
- String tstname = TestParenting02NEWT.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/parenting/TestParenting03AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java
deleted file mode 100644
index 00a78a14f..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Label;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.FPSAnimator;
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting03AWT extends UITestCase {
- static Dimension size;
- static long durationPerTest = 400;
- static long waitAdd2nd = 200;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- 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 testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.enablePerfLog(true);
- glWindow1.setUndecorated(true);
- NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
- newtCanvasAWT1.setPreferredSize(size);
-
- GLEventListener demo1 = new Gears(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);
- }
- }
- }
- });
- GLAnimatorControl animator1 = new Animator(glWindow1);
- animator1.start();
-
- Container cont1 = new Container();
- cont1.setLayout(new BorderLayout());
- cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
- cont1.setVisible(true);
- final Container f_cont1 = cont1;
-
- Frame frame1 = new Frame("AWT Parent Frame");
- frame1.setLayout(new BorderLayout());
- 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;
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- f_frame1.pack();
- f_frame1.setVisible(true);
- }});
-
- Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
- Assert.assertEquals(true, animator1.isAnimating());
- Assert.assertEquals(false, animator1.isPaused());
- Assert.assertNotNull(animator1.getThread());
-
- Thread.sleep(durationPerTest);
-
- animator1.stop();
- Assert.assertEquals(false, animator1.isAnimating());
- Assert.assertEquals(false, animator1.isPaused());
- Assert.assertEquals(null, animator1.getThread());
-
- frame1.dispose();
- glWindow1.invalidate();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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]);
- } else if(args[i].equals("-wait")) {
- waitAdd2nd = atoi(args[++i]);
- }
- }
- String tstname = TestParenting03AWT.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" } ); */
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java
deleted file mode 100644
index 5f42d9f7e..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-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 java.awt.Button;
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Label;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.FPSAnimator;
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-
-import java.io.IOException;
-
-import com.jogamp.test.junit.util.*;
-import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
-
-public class TestParenting03bAWT extends UITestCase {
- static Dimension size;
- static long durationPerTest = 800;
- static long waitAdd2nd = 500;
- static GLCapabilities glCaps;
-
- @BeforeClass
- public static void initClass() {
- GLProfile.initSingleton(true);
- size = new Dimension(400,200);
- glCaps = new GLCapabilities(null);
- }
-
- @Test
- public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException {
- testWindowParenting1AWTTwoNewtChilds();
- }
-
- public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException {
- int x = 0;
- int y = 0;
-
- NEWTEventFiFo eventFifo = new NEWTEventFiFo();
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
- glWindow1.enablePerfLog(true);
- glWindow1.setUndecorated(true);
- NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
- newtCanvasAWT1.setPreferredSize(size);
-
- GLEventListener demo1 = new Gears(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);
- }
- }
- }
- });
- GLAnimatorControl animator1 = new Animator(glWindow1);
- animator1.start();
-
- GLWindow glWindow2 = GLWindow.create(glCaps);
- glWindow2.enablePerfLog(true);
- glWindow2.setUndecorated(true);
- NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
- newtCanvasAWT2.setPreferredSize(size);
-
- GLEventListener demo2 = new Gears(1);
- setDemoFields(demo2, glWindow2, false);
- glWindow2.addGLEventListener(demo2);
- final NewtCanvasAWT f_newtCanvasAWT2 = newtCanvasAWT2;
- final GLWindow f_glWindow2 = glWindow2;
- glWindow2.addKeyListener(new KeyAdapter() {
- public void keyTyped(KeyEvent e) {
- if(e.getKeyChar()=='d') {
- f_glWindow2.setUndecorated(!f_glWindow2.isUndecorated());
- } else if(e.getKeyChar()=='f') {
- f_glWindow2.setFullscreen(!f_glWindow2.isFullscreen());
- } else if(e.getKeyChar()=='r') {
- if(f_glWindow2.getParent()==null) {
- System.err.println("XXX glWin2 to home");
- f_glWindow2.reparentWindow(f_newtCanvasAWT2.getNativeWindow());
- } else {
- System.err.println("XXX glWin2 to TOP");
- f_glWindow2.reparentWindow(null);
- }
- }
- }
- });
- GLAnimatorControl animator2 = new Animator(glWindow2);
- animator2.start();
-
- Container cont1 = new Container();
- cont1.setLayout(new BorderLayout());
- cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
- cont1.setVisible(true);
- final Container f_cont1 = cont1;
-
- Container cont2 = new Container();
- cont2.setLayout(new BorderLayout());
- cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
- cont2.setVisible(true);
- final Container f_cont2 = cont2;
-
- Frame frame1 = new Frame("AWT Parent Frame");
- frame1.setLayout(new BorderLayout());
- 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;
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- f_frame1.pack();
- f_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();
- Assert.assertEquals(false, animator1.isAnimating());
- 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.invalidate();
- glWindow2.invalidate();
- }
-
- public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
- Assert.assertNotNull(demo);
- Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
- if(debug) {
- MiscUtils.setFieldIfExists(demo, "glDebug", true);
- MiscUtils.setFieldIfExists(demo, "glTrace", true);
- }
- if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
- 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]);
- } else if(args[i].equals("-wait")) {
- waitAdd2nd = atoi(args[++i]);
- }
- }
- String tstname = TestParenting03bAWT.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" } ); */
- org.junit.runner.JUnitCore.main(tstname);
- }
-
-}
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/WindowAction.java b/src/junit/com/jogamp/test/junit/newt/parenting/WindowAction.java
deleted file mode 100644
index bcfb29440..000000000
--- a/src/junit/com/jogamp/test/junit/newt/parenting/WindowAction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.test.junit.newt.parenting;
-
-import com.jogamp.newt.event.*;
-
-class WindowAction extends WindowAdapter {
- NEWTEventFiFo eventFifo;
-
- public WindowAction(NEWTEventFiFo eventFifo) {
- this.eventFifo = eventFifo;
- }
-
- public void windowDestroyNotify(WindowEvent e) {
- eventFifo.put(e);
- }
-}
-