aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-06-02 04:13:43 +0200
committerSven Gothel <[email protected]>2010-06-02 04:13:43 +0200
commitd94115b3d72ec556371e6d09c2967345662fc781 (patch)
treed25dbcc892cb0a7e9316123e5e2e12885a2e29d5 /src/junit
parentdd0400a41478c1f365414b8c760eee1c91105280 (diff)
NEWT: Simplified Locking
- Using Display.getEDTUtil() and Display.runCreateAndDestroyOnEDT() to determine the NEWT EDT behavior, which may be specialized by the implementation. - AWTWrapper and Newt/AWT Parenting deadlock fix. - Misc fixes in test cases
Diffstat (limited to 'src/junit')
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java52
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java36
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java8
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java18
4 files changed, 81 insertions, 33 deletions
diff --git a/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java b/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java
index 45c782d38..7fdbd59c8 100755
--- a/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java
@@ -48,29 +48,44 @@ import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
+import java.io.IOException;
+import org.junit.Assert;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
public class TestTexture01AWT {
- Frame frame;
+ static GLProfile glp;
+ static GLCapabilities caps;
BufferedImage textureImage;
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.get(GLProfile.GL2GL3);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ }
+
@Before
- public void init() {
+ public void initTest() {
// create base image
- BufferedImage baseImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB);
+ BufferedImage baseImage = new BufferedImage(256, 256, BufferedImage.TYPE_3BYTE_BGR);
+ Assert.assertNotNull(baseImage);
Graphics2D g = baseImage.createGraphics();
+ Assert.assertNotNull(g);
g.setPaint(new GradientPaint(0, 0, Color.CYAN,
baseImage.getWidth(), baseImage.getHeight(), Color.BLUE));
g.fillRect(0, 0, baseImage.getWidth(), baseImage.getHeight());
g.dispose();
// create texture image
- int imageType = BufferedImage.TYPE_INT_RGB;
+ int imageType = BufferedImage.TYPE_3BYTE_BGR;
textureImage = new BufferedImage(baseImage.getWidth(),
baseImage.getHeight(),
imageType);
+ Assert.assertNotNull(textureImage);
g = textureImage.createGraphics();
g.setComposite(AlphaComposite.Src);
g.drawImage(baseImage, 0, 0, null);
@@ -78,22 +93,21 @@ public class TestTexture01AWT {
baseImage.flush();
baseImage=null;
-
- frame = new Frame("Texture Test");
}
@After
- public void cleanup() {
+ public void cleanupTest() {
+ Assert.assertNotNull(textureImage);
textureImage.flush();
textureImage=null;
- frame.dispose();
- frame=null;
}
@Test
public void test1() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3));
GLCanvas glCanvas = new GLCanvas(caps);
+
+ Frame frame = new Frame("Texture Test");
+ Assert.assertNotNull(frame);
frame.add(glCanvas);
frame.setSize(512, 512);
@@ -111,9 +125,23 @@ public class TestTexture01AWT {
frame.setVisible(false);
frame.remove(glCanvas);
glCanvas=null;
+ Assert.assertNotNull(frame);
+ frame.dispose();
+ frame=null;
}
- public static void main(String args[]) {
- org.junit.runner.JUnitCore.main(TestTexture01AWT.class.getName());
+ public static void main(String args[]) throws IOException {
+ String tstname = TestTexture01AWT.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/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java b/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java
index eabd4b79d..c5e656572 100755
--- a/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java
+++ b/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java
@@ -53,7 +53,9 @@ public class TextureGL2ListenerDraw1 implements GLEventListener {
}
public void init(GLAutoDrawable drawable) {
- this.texture = TextureIO.newTexture(textureData);
+ if(null!=textureData) {
+ this.texture = TextureIO.newTexture(textureData);
+ }
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
@@ -89,21 +91,23 @@ public class TextureGL2ListenerDraw1 implements GLEventListener {
// Now draw one quad with the texture
- texture.enable();
- texture.bind();
- gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
- TextureCoords coords = texture.getImageTexCoords();
- gl.glBegin(GL2.GL_QUADS);
- gl.glTexCoord2f(coords.left(), coords.bottom());
- gl.glVertex3f(0, 0, 0);
- gl.glTexCoord2f(coords.right(), coords.bottom());
- gl.glVertex3f(1, 0, 0);
- gl.glTexCoord2f(coords.right(), coords.top());
- gl.glVertex3f(1, 1, 0);
- gl.glTexCoord2f(coords.left(), coords.top());
- gl.glVertex3f(0, 1, 0);
- gl.glEnd();
- texture.disable();
+ if(null!=texture) {
+ texture.enable();
+ texture.bind();
+ gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
+ TextureCoords coords = texture.getImageTexCoords();
+ gl.glBegin(GL2.GL_QUADS);
+ gl.glTexCoord2f(coords.left(), coords.bottom());
+ gl.glVertex3f(0, 0, 0);
+ gl.glTexCoord2f(coords.right(), coords.bottom());
+ gl.glVertex3f(1, 0, 0);
+ gl.glTexCoord2f(coords.right(), coords.top());
+ gl.glVertex3f(1, 1, 0);
+ gl.glTexCoord2f(coords.left(), coords.top());
+ gl.glVertex3f(0, 1, 0);
+ gl.glEnd();
+ texture.disable();
+ }
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
index b96e74182..9aec605be 100755
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
@@ -127,10 +127,16 @@ public class TestGLWindows01NEWT {
window.display();
window.destroy();
Assert.assertEquals(false,window.isNativeWindowValid());
- Assert.assertEquals(true,window.isVisible());
+ Assert.assertEquals(false,window.isVisible());
window.display();
+ Assert.assertEquals(false,window.isNativeWindowValid());
+ Assert.assertEquals(false,window.isVisible());
+
+ window.setVisible(true);
Assert.assertEquals(true,window.isNativeWindowValid());
+ Assert.assertEquals(true,window.isVisible());
+ window.display();
Animator animator = new Animator(window);
animator.start();
diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java
index 6d0791c1c..753da1836 100755
--- a/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java
@@ -68,6 +68,7 @@ public class TestParenting02AWT {
static int width, height;
static long durationPerTest = 500;
static long waitReparent = 300;
+ static boolean verbose = false;
@BeforeClass
public static void initClass() {
@@ -157,7 +158,9 @@ public class TestParenting02AWT {
Assert.assertEquals(true, glWindow.isNativeWindowValid());
Assert.assertNotNull(glWindow.getParentNativeWindow());
- System.out.println("+++++++++++++++++++ 1st ADDED");
+ if(verbose) {
+ System.out.println("+++++++++++++++++++ 1st ADDED");
+ }
Thread.sleep(waitReparent);
if(useLayout) {
@@ -166,7 +169,9 @@ public class TestParenting02AWT {
Assert.assertEquals(false, glWindow.isVisible());
Assert.assertEquals(true, glWindow.isNativeWindowValid());
Assert.assertNull(glWindow.getParentNativeWindow());
- System.out.println("+++++++++++++++++++ REMOVED!");
+ if(verbose) {
+ System.out.println("+++++++++++++++++++ REMOVED!");
+ }
Thread.sleep(waitReparent);
// should recreate properly ..
@@ -175,7 +180,9 @@ public class TestParenting02AWT {
Assert.assertEquals(true, glWindow.isVisible());
Assert.assertEquals(true, glWindow.isNativeWindowValid());
Assert.assertNotNull(glWindow.getParentNativeWindow());
- System.out.println("+++++++++++++++++++ 2nd ADDED");
+ if(verbose) {
+ System.out.println("+++++++++++++++++++ 2nd ADDED");
+ }
Thread.sleep(waitReparent);
}
@@ -204,7 +211,9 @@ public class TestParenting02AWT {
}
}
}
- System.out.println("+++++++++++++++++++ END");
+ if(verbose) {
+ System.out.println("+++++++++++++++++++ END");
+ }
Thread.sleep(waitReparent);
glWindow.destroy();
@@ -236,6 +245,7 @@ public class TestParenting02AWT {
}
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]);