From 9850c3a91a23983f1261cb38e4734524c67200f2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Sep 2014 04:53:30 +0200 Subject: Bug 1048: Add unit tests demonstrating multiple NewtCanvasAWT instances are working Enhance following performance test cases, adding NewtCanvasAWT, beside GLCanvas and GLJPanel, 25 instances: com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT Adding simple com.jogamp.opengl.test.junit.newt.TestMultipleNewtCanvasAWT w/ two instances. Manually tested on GNU/Linux and OSX (java7 and java8). --- .../jogl/perf/TestPerf001GLJPanelInit01AWT.java | 120 ++++++++++--- .../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 153 ++++++++++++----- .../test/junit/newt/TestMultipleNewtCanvasAWT.java | 185 +++++++++++++++++++++ 3 files changed, 389 insertions(+), 69 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java index 92785ef6e..0db2afc32 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java @@ -31,6 +31,8 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.GridLayout; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import javax.media.opengl.GLAnimatorControl; @@ -52,13 +54,15 @@ import org.junit.Test; import org.junit.runners.MethodSorters; import com.jogamp.common.os.Platform; +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; /** - * Multiple GLJPanels in a JFrame's Grid + * Tests multiple [GLJPanels, GLCanvas or NewtCanvasAWT] in a JFrame's Grid */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestPerf001GLJPanelInit01AWT extends UITestCase { @@ -69,15 +73,26 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase { GLProfile.initSingleton(); } + static enum CanvasType { GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T }; + + static class GLADComp { + GLADComp(final GLAutoDrawable glad, final Component comp) { + this.glad = glad; + this.comp = comp; + } + final GLAutoDrawable glad; + final Component comp; + } public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, final int rows, - final int columns, final boolean useGLJPanel, final boolean useAnim) { + final int columns, final CanvasType canvasType, final boolean useAnim) { final GLAnimatorControl animator = useAnim ? new Animator() : null; final JFrame frame; final JPanel panel; + final List newtCanvasAWTList = new ArrayList(); panel = new JPanel(); - frame = new JFrame("DemoGLJPanelGridAWT"); + frame = new JFrame(getSimpleTestName(".")); panel.setLayout(new GridLayout(rows, columns)); // panel.setBounds(0, 0, width, height); @@ -94,8 +109,21 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase { public void run() { t[0] = Platform.currentTimeMillis(); for(int i=0; i "+frameCount+" x "+eWidth+"x"+eHeight+", overlap "+overlap); System.err.println("SkipGLOrientationVerticalFlip "+skipGLOrientationVerticalFlip+", useGears "+useGears+", initMT "+initMT+", useAnim "+useAnim); final JFrame[] frame = new JFrame[frameCount]; + final List newtCanvasAWTList = new ArrayList(); + final long[] t = new long[10]; if( wait ) { UITestCase.waitForKey("Pre-Init"); @@ -103,7 +119,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { t[0] = Platform.currentTimeMillis(); int x = 32, y = 32; for(int i=0; i