From 4d56491c3f8e76676e1c860d018bbe991d28ebac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Nov 2010 01:58:32 +0100 Subject: Seperated unit tests (newt/awt/headless) and cleaned up some imports and comments Seperated unit tests (newt/awt/headless) - no more *CORE* tests - junit.run.newt.headless: all NEWT headless (no-AWT) tests, without any AWT classes and with -Djava.awt.headless=true. Disabled for 'isOSX'. - junit.run.newt: all NEWT non AWT tests (same as above), but with full AWT. This test is not enabled via junit.run. Disabled for 'isOSX'. - junit.run.awt: all AWT tests without NEWT - using newt.event.jar to add AWT agnostic NEWT event adapter - junit.run.newt.awt: all NEWT + AWT tests - junit.run: junit.run.newt.headless,junit.run.awt,junit.run.newt.awt - swizzling around a few tests to achieve the above: TEST rules: - A runnable unit test must start with 'Test' - Only pure NEWT tests must have 'NEWT' in their name - AWT tests must have 'AWT' in their name. - AWT + NEWT tests must have '.newt.' in their package name, hence - Pure AWT tests (without NEWT) must not have '.newt.' in their package name --- .../jogamp/test/junit/jogl/acore/DumpVersion.java | 61 ---- .../test/junit/jogl/acore/TestGLProfile01NEWT.java | 1 + ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 330 --------------------- .../test/junit/jogl/demos/gl2/gears/Gears.java | 65 +--- .../junit/jogl/demos/gl2/gears/QuitAdapter.java | 53 ---- .../junit/jogl/demos/gl2/gears/TestGearsAWT.java | 1 + .../junit/jogl/demos/gl2/gears/TestGearsNEWT.java | 124 -------- .../demos/gl2/gears/TestGearsNewtAWTWrapper.java | 113 ------- .../jogl/demos/gl2/gears/newt/TestGearsNEWT.java | 126 ++++++++ .../gl2/gears/newt/TestGearsNewtAWTWrapper.java | 114 +++++++ ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 330 +++++++++++++++++++++ .../com/jogamp/test/junit/util/DumpVersion.java | 61 ++++ .../com/jogamp/test/junit/util/QuitAdapter.java | 53 ++++ 13 files changed, 699 insertions(+), 733 deletions(-) delete mode 100644 src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java create mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java create mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java create mode 100644 src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java create mode 100644 src/junit/com/jogamp/test/junit/util/DumpVersion.java create mode 100644 src/junit/com/jogamp/test/junit/util/QuitAdapter.java (limited to 'src/junit/com/jogamp/test') diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java b/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java deleted file mode 100644 index 3fa7f111f..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java +++ /dev/null @@ -1,61 +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.jogl.acore; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -import javax.media.opengl.*; -import com.jogamp.opengl.util.VersionInfo; -import com.jogamp.common.os.Platform; - -import java.io.IOException; - -public class DumpVersion implements GLEventListener { - - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - - String prefix = Thread.currentThread().getName(); - - System.err.println(VersionInfo.getInfo(null, prefix, gl).toString()); - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void display(GLAutoDrawable drawable) { - } - - public void dispose(GLAutoDrawable drawable) { - } -} diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java index e6988582c..0c64cfdf2 100644 --- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java @@ -29,6 +29,7 @@ package com.jogamp.test.junit.jogl.acore; import com.jogamp.test.junit.util.UITestCase; +import com.jogamp.test.junit.util.DumpVersion; import org.junit.Assert; import org.junit.Before; diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java deleted file mode 100644 index 326a6942a..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ /dev/null @@ -1,330 +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.jogl.awt; - -import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; -import com.jogamp.test.junit.util.*; - -import java.lang.reflect.InvocationTargetException; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.Animator; - -import com.jogamp.newt.Screen; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.awt.NewtCanvasAWT; - -import java.awt.BorderLayout; -import java.awt.Canvas; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import javax.media.opengl.GLEventListener; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.BorderFactory; -import javax.swing.border.Border; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { - static long durationPerTest = 500; // ms - static Robot robot; - static Border border; - static JFrame frame; - static JButton button; - static JPanel panel; - static JPanel colorPanel; - static boolean windowClosing; - - boolean modLightBrighter = true; - - Color modLight(Color c) { - Color c2; - if(modLightBrighter) { - c2 = c.brighter(); - } else { - c2 = c.darker(); - } - if(c2.equals(c)) { - modLightBrighter = !modLightBrighter; - } - return c2; - } - - class SwingGLAction implements GLEventListener { - public void init(GLAutoDrawable glad) { - } - - public void dispose(GLAutoDrawable glad) { - } - - public void display(GLAutoDrawable glad) { - colorPanel.setBackground(modLight(colorPanel.getBackground())); - colorPanel.repaint(); - } - - public void reshape(GLAutoDrawable glad, final int x, final int y, final int width, final int height) { - } - } - - @BeforeClass - public static void setup() throws InterruptedException, InvocationTargetException, AWTException { - int count; - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Start Pre-JOGL-Swing"); - - // GLProfile.initSingleton(false); - // GLProfile.initSingleton(true); - - // simulate AWT usage before JOGL's initialization of X11 threading - windowClosing=false; - border = BorderFactory.createLineBorder (Color.yellow, 2); - - panel = new JPanel(); - panel.setLayout(new BorderLayout()); - - button = new JButton("Click me"); - button.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - System.err.println("Test: "+e); - } - }); - panel.add(button, BorderLayout.NORTH); - - colorPanel = new JPanel(); - Dimension size = new Dimension(400,100); - colorPanel.setPreferredSize(size); - colorPanel.setBorder(border); - panel.add(colorPanel, BorderLayout.SOUTH); - - frame = new JFrame("PRE JOGL"); - frame.addWindowListener( new WindowAdapter() { - public void windowClosing(WindowEvent ev) { - windowClosing=true; - } - }); - frame.setContentPane(panel); - frame.setSize(512, 512); - frame.setLocation(0, 0); - frame.pack(); - - // AWT/Swing: From here on (post setVisible(true) - // you need to use AWT/Swing's invokeAndWait() - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(true); - colorPanel.setBackground(Color.white); - colorPanel.repaint(); - }}); - - robot = new Robot(); - robot.setAutoWaitForIdle(true); - - AWTRobotUtil.toFront(robot, frame); - AWTRobotUtil.requestFocus(robot, button); - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Before JOGL init"); - - GLProfile.initSingleton(false); - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): End Pre-JOGL-Swing"); - } - - @AfterClass - public static void release() throws InterruptedException, InvocationTargetException { - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.release(): Start"); - robot = null; - Assert.assertNotNull(frame); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.dispose(); - } - }); - frame=null; - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.release(): End"); - } - - protected void runTestGL(final Canvas canvas, GLAutoDrawable drawable) - throws AWTException, InterruptedException, InvocationTargetException { - - Dimension size = new Dimension(400,400); - canvas.setPreferredSize(size); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - panel.add(canvas, BorderLayout.CENTER); - frame.pack(); - } - }); - - AWTRobotUtil.toFront(robot, frame); - - drawable.addGLEventListener(new Gears()); - - for(int i=0; i<100; i++) { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - colorPanel.setBackground(modLight(colorPanel.getBackground())); - colorPanel.repaint(); - } - }); - drawable.display(); // one in process display - Thread.sleep(10); - } - - colorPanel.setBackground(Color.blue); - drawable.addGLEventListener(new SwingGLAction()); - - Point p0 = canvas.getLocationOnScreen(); - Rectangle r0 = canvas.getBounds(); - robot.mouseMove( (int) ( p0.getX() + .5 ) , - (int) ( p0.getY() + .5 ) ); - robot.mousePress(InputEvent.BUTTON1_MASK); - for(int i=0; !windowClosing && i - * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel)

+ * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)

* * This version is equal to Brian Paul's version 1.2 1999/10/21 */ @@ -24,8 +20,8 @@ public class Gears implements GLEventListener { private float angle = 0.0f; private int swapInterval; - private int prevMouseX, prevMouseY; private boolean mouseRButtonDown = false; + private int prevMouseX, prevMouseY; public Gears(int swapInterval) { this.swapInterval = swapInterval; @@ -35,42 +31,6 @@ public class Gears implements GLEventListener { this.swapInterval = 1; } - public static void main(String[] args) { - // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example - // - // NotFirstUIActionOnProcess - // - boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ; - GLProfile.initSingleton(firstUIActionOnProcess); - - Frame frame = new Frame("Gear Demo"); - GLCanvas canvas = new GLCanvas(); - // GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - // GLCanvas canvas = new GLCanvas(caps); - - final Gears gears = new Gears(); - canvas.addGLEventListener(gears); - - frame.add(canvas); - frame.setSize(300, 300); - final Animator animator = new Animator(canvas); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent e) { - // Run this on another thread than the AWT event queue to - // make sure the call to Animator.stop() completes before - // exiting - new Thread(new Runnable() { - public void run() { - animator.stop(); - System.exit(0); - } - }).start(); - } - }); - frame.setVisible(true); - animator.start(); - } - public void init(GLAutoDrawable drawable) { System.err.println("Gears: Init"); // Use debug pipeline @@ -113,12 +73,12 @@ public class Gears implements GLEventListener { // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); MouseListener gearsMouse = new GearsMouseAdapter(); - if (drawable instanceof Component) { - Component comp = (Component) drawable; - new AWTMouseAdapter(gearsMouse).addTo(comp); - } else if (drawable instanceof Window) { + if (drawable instanceof Window) { Window window = (Window) drawable; window.addMouseListener(gearsMouse); + } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) drawable; + new AWTMouseAdapter(gearsMouse).addTo(comp); } } @@ -154,9 +114,10 @@ public class Gears implements GLEventListener { // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if ((drawable instanceof GLJPanel) && - !((GLJPanel) drawable).isOpaque() && - ((GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { + if (GLProfile.isAWTAvailable() && + (drawable instanceof javax.media.opengl.awt.GLJPanel) && + !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && + ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { gl.glClear(GL2.GL_DEPTH_BUFFER_BIT); } else { gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); @@ -335,8 +296,8 @@ public class Gears implements GLEventListener { Window window = (Window) source; width=window.getWidth(); height=window.getHeight(); - } else if (source instanceof Component) { - Component comp = (Component) source; + } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) source; width=comp.getWidth(); height=comp.getHeight(); } else { diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java deleted file mode 100644 index e60543b7c..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java +++ /dev/null @@ -1,53 +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.jogl.demos.gl2.gears; - -import com.jogamp.opengl.util.Animator; -import com.jogamp.newt.event.*; - -class QuitAdapter extends WindowAdapter implements WindowListener, KeyListener { - boolean shouldQuit = false; - - public boolean shouldQuit() { return shouldQuit; } - - public void windowDestroyNotify(WindowEvent e) { - System.out.println("QUIT Window "+Thread.currentThread()); - shouldQuit = true; - } - - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='q') { - System.out.println("QUIT Key "+Thread.currentThread()); - shouldQuit = true; - } - } - public void keyPressed(KeyEvent e) {} - public void keyReleased(KeyEvent e) {} -} - diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java index 60435cb4a..9639c384b 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java @@ -37,6 +37,7 @@ import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.test.junit.util.UITestCase; +import com.jogamp.test.junit.util.QuitAdapter; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import java.awt.Frame; diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java deleted file mode 100644 index 1589be84c..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java +++ /dev/null @@ -1,124 +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.jogl.demos.gl2.gears; - -import com.jogamp.test.junit.util.UITestCase; - -import javax.media.opengl.*; -import com.jogamp.opengl.util.Animator; - -import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; -import com.jogamp.newt.*; -import com.jogamp.newt.event.*; -import com.jogamp.newt.opengl.*; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.After; -import org.junit.Test; - -public class TestGearsNEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - @BeforeClass - public static void initClass() { - GLProfile.initSingleton(true); - glp = GLProfile.getDefault(); - Assert.assertNotNull(glp); - width = 512; - height = 512; - } - - @AfterClass - public static void releaseClass() { - } - - protected void runTestGL(GLCapabilities caps) throws InterruptedException { - GLWindow glWindow = GLWindow.create(caps); - Assert.assertNotNull(glWindow); - glWindow.setTitle("Gears NEWT Test"); - - glWindow.addGLEventListener(new Gears()); - - Animator animator = new Animator(glWindow); - QuitAdapter quitAdapter = new QuitAdapter(); - - //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); - //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - - final GLWindow f_glWindow = glWindow; - glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='f') { - f_glWindow.invoke(false, new GLRunnable() { - public void run(GLAutoDrawable drawable) { - GLWindow win = (GLWindow)drawable; - win.setFullscreen(!win.isFullscreen()); - } }); - } - } - }); - - glWindow.setSize(width, height); - glWindow.setVisible(true); - animator.start(); - - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()