diff options
author | Sven Gothel <[email protected]> | 2011-12-18 18:00:53 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-12-18 18:00:53 +0100 |
commit | 57140d444b3b783bfd5e400674eb46ab780a483e (patch) | |
tree | bd92015805839375baa16ef3ea9a3f79454421e8 | |
parent | 927521af10162f2bf8c02b12cce75bd7de71dafe (diff) |
TestInitConcurrentNEWT: Nice window layout - don't wait/sync for start thread, only for shutdown.
-rwxr-xr-x | make/scripts/tests.sh | 4 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java | 68 |
2 files changed, 54 insertions, 18 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 091bd350c..f8205b637 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -173,7 +173,7 @@ function testswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* @@ -288,7 +288,7 @@ function testswt() { #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo02 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* # diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java index b6c6e0a91..fc025d023 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java @@ -30,12 +30,17 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.InsetsImmutable; 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.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -43,33 +48,61 @@ import com.jogamp.opengl.util.Animator; public class TestInitConcurrentNEWT extends UITestCase { + static final int demoSize = 128; + static long duration = 300; // ms + static InsetsImmutable insets = null; + static int scrnHeight, scrnWidth; + static int num_x, num_y; + + @BeforeClass + public static void initClass() { + 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(); + } + public class JOGLTask implements Runnable { + private int id; private Object postSync; private boolean done = false; - public JOGLTask(Object postSync) { + public JOGLTask(Object postSync, int id) { this.postSync = postSync; + this.id = id; } public void run() { - System.err.println(Thread.currentThread().getName()+" START"); + int x = ( id % num_x ) * ( demoSize + insets.getTotalHeight() ); + int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ); + + System.err.println("JOGLTask "+id+": START: "+x+"/"+y+" - "+Thread.currentThread().getName()); GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault())); Assert.assertNotNull(glWindow); - glWindow.setTitle("Gears NEWT Test"); + glWindow.setTitle("Task "+id); + glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() ); glWindow.addGLEventListener(new GearsES2(0)); Animator animator = new Animator(glWindow); - glWindow.setSize(128, 128); + glWindow.setSize(demoSize, demoSize); glWindow.setVisible(true); - animator.setUpdateFPSFrames(60, System.err); + animator.setUpdateFPSFrames(60, null); animator.start(); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(true, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertEquals(true, glWindow.isRealized()); + System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName()); while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) { try { @@ -82,10 +115,10 @@ public class TestInitConcurrentNEWT extends UITestCase { animator.stop(); glWindow.destroy(); - System.err.println(Thread.currentThread().getName()+" sync"); + System.err.println("JOGLTask "+id+": DONE/SYNC: "+Thread.currentThread().getName()); synchronized (postSync) { done = true; - System.err.println(Thread.currentThread().getName()+" END"); + System.err.println("JOGLTask "+id+": END: "+Thread.currentThread().getName()); postSync.notifyAll(); } } @@ -142,13 +175,13 @@ public class TestInitConcurrentNEWT extends UITestCase { final Thread[] threads = new Thread[num]; int i; for(i=0; i<num; i++) { - tasks[i] = new JOGLTask(sync); + tasks[i] = new JOGLTask(sync, i); threads[i] = new Thread(tasks[i], currentThreadName+"-jt"+i); } + for(i=0; i<num; i++) { + threads[i].start(); + } synchronized (sync) { - for(i=0; i<num; i++) { - threads[i].start(); - } while(!done(tasks)) { try { sync.wait(); @@ -177,16 +210,19 @@ public class TestInitConcurrentNEWT extends UITestCase { } @Test - public void test04FourThreads() throws InterruptedException { - runJOGLTasks(4); - } - - @Test public void test16SixteenThreads() throws InterruptedException { runJOGLTasks(16); } public static void main(String args[]) throws IOException { + for(int i=0; i<args.length; i++) { + if(args[i].equals("-time")) { + i++; + try { + duration = Integer.parseInt(args[i]); + } catch (Exception ex) { ex.printStackTrace(); } + } + } String tstname = TestInitConcurrentNEWT.class.getName(); org.junit.runner.JUnitCore.main(tstname); } |