From 64041218f3d5965b9525e8699aa97e9ec751cd95 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 12 Jan 2013 09:08:55 +0100 Subject: Move all Exclusive Context Thread (ECT) tests to it's own package to de-clutter core test package --- .../junit/jogl/acore/ExclusiveContextBase00.java | 420 --------------------- .../jogl/acore/ExclusiveContextBase00AWT.java | 161 -------- .../jogl/acore/ExclusiveContextBase00NEWT.java | 94 ----- .../junit/jogl/acore/ExclusiveContextBase10.java | 213 ----------- .../jogl/acore/ExclusiveContextBase10AWT.java | 161 -------- .../jogl/acore/ExclusiveContextBase10NEWT.java | 94 ----- .../acore/TestExclusiveContext01VSyncAnimAWT.java | 70 ---- .../acore/TestExclusiveContext01VSyncAnimNEWT.java | 67 ---- .../acore/TestExclusiveContext02FPSAnimAWT.java | 70 ---- .../acore/TestExclusiveContext02FPSAnimNEWT.java | 67 ---- .../acore/TestExclusiveContext11VSyncAnimNEWT.java | 66 ---- .../acore/TestExclusiveContext12FPSAnimNEWT.java | 67 ---- .../jogl/acore/ect/ExclusiveContextBase00.java | 420 +++++++++++++++++++++ .../jogl/acore/ect/ExclusiveContextBase00AWT.java | 161 ++++++++ .../jogl/acore/ect/ExclusiveContextBase00NEWT.java | 94 +++++ .../jogl/acore/ect/ExclusiveContextBase10.java | 213 +++++++++++ .../jogl/acore/ect/ExclusiveContextBase10AWT.java | 161 ++++++++ .../jogl/acore/ect/ExclusiveContextBase10NEWT.java | 94 +++++ .../ect/TestExclusiveContext01VSyncAnimAWT.java | 70 ++++ .../ect/TestExclusiveContext01VSyncAnimNEWT.java | 67 ++++ .../ect/TestExclusiveContext02FPSAnimAWT.java | 70 ++++ .../ect/TestExclusiveContext02FPSAnimNEWT.java | 67 ++++ .../ect/TestExclusiveContext11VSyncAnimNEWT.java | 66 ++++ .../ect/TestExclusiveContext12FPSAnimNEWT.java | 67 ++++ 24 files changed, 1550 insertions(+), 1550 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext11VSyncAnimNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext12FPSAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext01VSyncAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext01VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext02FPSAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext02FPSAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext11VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext12FPSAnimNEWT.java (limited to 'src/test/com/jogamp') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java deleted file mode 100644 index c6eb3a103..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java +++ /dev/null @@ -1,420 +0,0 @@ -/** - * Copyright 2013 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.opengl.test.junit.jogl.acore; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; - -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.AnimatorBase; - -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; - -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.util.InsetsImmutable; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -/** - * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase. - */ -public abstract class ExclusiveContextBase00 extends UITestCase { - static boolean testExclusiveWithAWT = false; - static final int durationParts = 9; - static long duration = 320 * durationParts; // ms ~ 20 frames - - static boolean showFPS = false; - static int showFPSRate = 100; - - static final int demoSize = 128; - - static InsetsImmutable insets = null; - static int scrnHeight, scrnWidth; - static int num_x, num_y; - - static int swapInterval = 0; - - @BeforeClass - public static void initClass00() { - Window dummyWindow = NewtFactory.createWindow(new Capabilities()); - dummyWindow.setSize(demoSize, demoSize); - dummyWindow.setVisible(true); - Assert.assertEquals(true, dummyWindow.isVisible()); - Assert.assertEquals(true, dummyWindow.isNativeValid()); - insets = dummyWindow.getInsets(); - scrnHeight = dummyWindow.getScreen().getHeight(); - scrnWidth = dummyWindow.getScreen().getWidth(); - num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; - num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; - dummyWindow.destroy(); - } - - @AfterClass - public static void releaseClass00() { - } - - protected abstract boolean isAWTTestCase(); - protected abstract Thread getAWTRenderThread(); - protected abstract AnimatorBase createAnimator(); - protected abstract GLAutoDrawable createGLAutoDrawable(String title, int x, int y, int width, int height, GLCapabilitiesImmutable caps); - protected abstract void setGLAutoDrawableVisible(GLAutoDrawable[] glads); - protected abstract void destroyGLAutoDrawableVisible(GLAutoDrawable glad); - - protected void runTestGL(GLCapabilitiesImmutable caps, int drawableCount, boolean exclusive, boolean preAdd, boolean shortenTest) throws InterruptedException { - final boolean useAWTRenderThread = isAWTTestCase(); - if( useAWTRenderThread && exclusive ) { - if( testExclusiveWithAWT ) { - System.err.println("Warning: Testing AWT + Exclusive -> Not advised!"); - } else { - System.err.println("Info: Skip test: AWT + Exclusive!"); - return; - } - } - if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { - System.err.println("Skip test: AWT + Exclusive -> Not advised!"); - return; - } - final Thread awtRenderThread = getAWTRenderThread(); - final AnimatorBase animator = createAnimator(); - if( !useAWTRenderThread ) { - animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - } - final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; - for(int i=0; i0) { - System.err.println("Clearing drawable ECT was done 'later' @ "+(c*20)+"ms, ok "+ok); - } - Assert.assertEquals(true, ok); - } - final Thread t = drawables[i].setExclusiveContextThread(ect); - Assert.assertEquals(null, t); - } - - Thread.sleep(duration/durationParts); // 3 - } - - // Disable/Enable exclusive mode via Animator for all GLAutoDrawable - if(exclusive) { - final Thread ect = animator.getExclusiveContextThread(); - if( useAWTRenderThread ) { - Assert.assertEquals(awtRenderThread, ect); - } else { - Assert.assertEquals(animator.getThread(), ect); - } - - Assert.assertEquals(true, animator.setExclusiveContext(false)); - Assert.assertFalse(animator.isExclusiveContextEnabled()); - for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); - System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); - System.err.println("OSType "+Platform.getOSType()); - System.err.println("Java Version "+Platform.getJavaVersionNumber()); - - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - awtEDT = Thread.currentThread(); - } } ); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - } - - @AfterClass - public static void releaseClass00AWT() { - } - - @Override - protected boolean isAWTTestCase() { return true; } - - @Override - protected Thread getAWTRenderThread() { - return awtEDT; - } - - @Override - protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { - final GLCanvas glCanvas = new GLCanvas(); - - // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow - // final Dimension sz = new Dimension(width, height); - // glCanvas.setMinimumSize(sz); - // glCanvas.setPreferredSize(sz); - // glCanvas.setSize(sz); - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final Frame frame = new Frame(); - frame.setLayout(new BorderLayout()); - frame.setMinimumSize(new Dimension(width, height)); - frame.setBounds(x, y, width, height); - frame.add(glCanvas, BorderLayout.CENTER); - // frame.pack(); - frame.validate(); - if( !osxCALayerAWTModBug ) { - frame.setTitle(title); - } - } }); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - return glCanvas; - } - - protected Frame getFrame(GLAutoDrawable glad) { - Container p = ((Component)glad).getParent(); - while( null != p && !( p instanceof Frame ) ) { - p = p.getParent(); - } - return (Frame)p; - } - - @Override - protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final int count = glads.length; - for(int i=0; i Not advised!"); - } else { - System.err.println("Info: Skip test: AWT + Exclusive!"); - return; - } - } - if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { - System.err.println("Skip test: AWT + Exclusive -> Not advised!"); - return; - } - final Thread awtRenderThread = getAWTRenderThread(); - final AnimatorBase animator = createAnimator(); - if( !useAWTRenderThread ) { - animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - } - final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; - for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); - System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); - System.err.println("OSType "+Platform.getOSType()); - System.err.println("Java Version "+Platform.getJavaVersionNumber()); - - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - awtEDT = Thread.currentThread(); - } } ); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - } - - @AfterClass - public static void releaseClass00AWT() { - } - - @Override - protected boolean isAWTTestCase() { return true; } - - @Override - protected Thread getAWTRenderThread() { - return awtEDT; - } - - @Override - protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { - final GLCanvas glCanvas = new GLCanvas(); - - // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow - // final Dimension sz = new Dimension(width, height); - // glCanvas.setMinimumSize(sz); - // glCanvas.setPreferredSize(sz); - // glCanvas.setSize(sz); - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final Frame frame = new Frame(); - frame.setLayout(new BorderLayout()); - frame.setMinimumSize(new Dimension(width, height)); - frame.setBounds(x, y, width, height); - frame.add(glCanvas, BorderLayout.CENTER); - // frame.pack(); - frame.validate(); - if( !osxCALayerAWTModBug ) { - frame.setTitle(title); - } - } }); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - return glCanvas; - } - - protected Frame getFrame(GLAutoDrawable glad) { - Container p = ((Component)glad).getParent(); - while( null != p && !( p instanceof Frame ) ) { - p = p.getParent(); - } - return (Frame)p; - } - - @Override - protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final int count = glads.length; - for(int i=0; i Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i0) { + System.err.println("Clearing drawable ECT was done 'later' @ "+(c*20)+"ms, ok "+ok); + } + Assert.assertEquals(true, ok); + } + final Thread t = drawables[i].setExclusiveContextThread(ect); + Assert.assertEquals(null, t); + } + + Thread.sleep(duration/durationParts); // 3 + } + + // Disable/Enable exclusive mode via Animator for all GLAutoDrawable + if(exclusive) { + final Thread ect = animator.getExclusiveContextThread(); + if( useAWTRenderThread ) { + Assert.assertEquals(awtRenderThread, ect); + } else { + Assert.assertEquals(animator.getThread(), ect); + } + + Assert.assertEquals(true, animator.setExclusiveContext(false)); + Assert.assertFalse(animator.isExclusiveContextEnabled()); + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i