summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java125
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java2
5 files changed, 114 insertions, 23 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
index 6d9801d48..9e0bebc9c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
@@ -101,8 +101,9 @@ public class TestSharedContextListAWT extends UITestCase {
frame.pack();
frame.setSize(width, height);
frame.setLocation(x, y);
- frame.validate();
+ frame.invalidate();
frame.setVisible(true);
+ frame.validate();
} });
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
index 939a85631..f05c20c4c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
@@ -40,10 +40,8 @@ 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 TestGearsNewtAWTWrapper extends UITestCase {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
index 94231a88d..96204d148 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
@@ -54,6 +54,14 @@ import org.junit.After;
import org.junit.Test;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.ProxySurface;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLDrawable;
+import jogamp.nativewindow.swt.SWTAccessor;
+import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Canvas;
/**
* Tests that a basic SWT app can open without crashing under different GL profiles. Uses the SWT GL canvas.
@@ -61,12 +69,14 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
*/
public class TestSWT01GLn extends UITestCase {
- static final int duration = 250;
+ static int duration = 250;
+
+ static final int iwidth = 640;
+ static final int iheight = 480;
Display display = null;
Shell shell = null;
Composite composite = null;
- GLCanvas glcanvas = null;
@BeforeClass
public static void startup() {
@@ -91,9 +101,7 @@ public class TestSWT01GLn extends UITestCase {
Assert.assertNotNull( display );
Assert.assertNotNull( shell );
Assert.assertNotNull( composite );
- Assert.assertNotNull( glcanvas );
try {
- glcanvas.dispose();
composite.dispose();
shell.dispose();
display.dispose();
@@ -105,15 +113,14 @@ public class TestSWT01GLn extends UITestCase {
display = null;
shell = null;
composite = null;
- glcanvas = null;
}
- protected void runTestGL( GLProfile glprofile ) throws InterruptedException {
+ protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
GLData gldata = new GLData();
gldata.doubleBuffer = true;
// need SWT.NO_BACKGROUND to prevent SWT from clearing the window
// at the wrong times (we use glClear for this instead)
- glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
+ final GLCanvas glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
Assert.assertNotNull( glcanvas );
glcanvas.setCurrent();
final GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
@@ -127,7 +134,8 @@ public class TestSWT01GLn extends UITestCase {
glcontext.makeCurrent();
GL2 gl = glcontext.getGL().getGL2();
OneTriangle.setup( gl, rectangle );
- glcontext.release();
+ glcontext.release();
+ System.err.println("resize");
}
});
@@ -140,7 +148,8 @@ public class TestSWT01GLn extends UITestCase {
GL2 gl = glcontext.getGL().getGL2();
OneTriangle.render( gl, rectangle );
glcanvas.swapBuffers();
- glcontext.release();
+ glcontext.release();
+ System.err.println("paint");
}
});
@@ -157,28 +166,116 @@ public class TestSWT01GLn extends UITestCase {
Thread.sleep(10);
}
}
- }
- catch( Throwable throwable ) {
+ } catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ glcanvas.dispose();
}
+ /**
+ protected void runTestBGL( GLProfile glprofile ) throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(glprofile);
+ WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory) GLDrawableFactory.getFactory(glprofile);
+
+ GLData gldata = new GLData();
+ gldata.doubleBuffer = true;
+ // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
+ // at the wrong times (we use glClear for this instead)
+ final Canvas canvas = new Canvas(composite, SWT.NO_BACKGROUND);
+ Assert.assertNotNull( canvas );
+ canvas.setSize(iwidth, iheight);
+ long windowHandle = SWTAccessor.getHandle(canvas);
+ Point sz = canvas.getSize();
+ ProxySurface surface = factory.createProxySurfaceImpl(caps, caps, null, windowHandle, sz.x, sz.y);
+ final GLDrawable glDrawable = factory.createGLDrawable(surface);
+
+ glDrawable.setRealized(true);
+ final GLContext glContext = glDrawable.createContext(null);
+
+ // fix the viewport when the user resizes the window
+ canvas.addListener( SWT.Resize, new Listener() {
+ public void handleEvent( Event event ) {
+ Rectangle rectangle = canvas.getClientArea();
+ glContext.makeCurrent();
+ GL2 gl = glContext.getGL().getGL2();
+ OneTriangle.setup( gl, rectangle );
+ glContext.release();
+ System.err.println("resize");
+ }
+ });
+
+ // draw the triangle when the OS tells us that any part of the window needs drawing
+ canvas.addPaintListener( new PaintListener() {
+ public void paintControl( PaintEvent paintevent ) {
+ Rectangle rectangle = canvas.getClientArea();
+ glContext.makeCurrent();
+ GL2 gl = glContext.getGL().getGL2();
+ OneTriangle.render( gl, rectangle );
+ glDrawable.swapBuffers();
+ glContext.release();
+ System.err.println("paint");
+ }
+ });
+
+ shell.setText( getClass().getName() );
+ shell.setSize( iwidth, iheight );
+ shell.open();
+
+ long lStartTime = System.currentTimeMillis();
+ long lEndTime = lStartTime + duration;
+ try {
+ while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) {
+ if( !display.readAndDispatch() ) {
+ // blocks on linux .. display.sleep();
+ Thread.sleep(10);
+ }
+ }
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ glContext.destroy();
+ glDrawable.setRealized(false);
+ canvas.dispose();
+ } */
+
@Test
- public void test01GLDefault() throws InterruptedException {
+ public void testA01GLDefault() throws InterruptedException {
GLProfile glprofile = GLProfile.getDefault();
System.out.println( "GLProfile Default: " + glprofile );
- runTestGL( glprofile );
+ runTestAGL( glprofile );
}
+ /* @Test
+ public void testB01GLDefault() throws InterruptedException {
+ GLProfile glprofile = GLProfile.getDefault();
+ System.out.println( "GLProfile Default: " + glprofile );
+ runTestBGL( glprofile );
+ } */
+
@Test
public void test02GL2() throws InterruptedException {
GLProfile glprofile = GLProfile.get(GLProfile.GL2);
System.out.println( "GLProfile GL2: " + glprofile );
- runTestGL( glprofile );
+ runTestAGL( glprofile );
+ }
+
+ static int atoi(String a) {
+ int i=0;
+ try {
+ i = Integer.parseInt(a);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ return i;
}
public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ duration = atoi(args[++i]);
+ }
+ }
+ System.out.println("durationPerTest: "+duration);
org.junit.runner.JUnitCore.main(TestSWT01GLn.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
index 846013b1d..7de63e6a6 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
@@ -30,22 +30,17 @@ package com.jogamp.opengl.test.junit.newt;
import java.io.IOException;
import javax.media.nativewindow.NativeWindowFactory;
-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.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
import com.jogamp.newt.ScreenMode;
-import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.util.MonitorMode;
import com.jogamp.newt.util.ScreenModeUtil;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
import com.jogamp.opengl.test.junit.util.UITestCase;
import java.util.Iterator;
import java.util.List;
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
index 35522f681..40c1e0528 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -45,7 +45,7 @@ import javax.swing.JFrame;
public class AWTRobotUtil {
- public static int TIME_OUT = 1000; // 1s
+ public static int TIME_OUT = 2000; // 2s
public static int ROBOT_DELAY = 50; // ms
public static int POLL_DIVIDER = 20; // TO/20