summaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/junit/com/jogamp/test')
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java35
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java264
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java25
3 files changed, 280 insertions, 44 deletions
diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
index fa15e3fef..5abf02b97 100755
--- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -40,6 +40,8 @@ import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.After;
import org.junit.Test;
import javax.media.opengl.*;
@@ -50,21 +52,29 @@ import com.jogamp.newt.opengl.*;
public class TestDrawable01NEWT {
static GLProfile glp;
+ static GLDrawableFactory factory;
static int width, height;
GLCapabilities caps;
Window window;
GLDrawable drawable;
GLContext context;
- GLDrawableFactory factory;
@BeforeClass
public static void initClass() {
glp = GLProfile.getDefault();
Assert.assertNotNull(glp);
+ factory = GLDrawableFactory.getFactory(glp);
+ Assert.assertNotNull(factory);
width = 640;
height = 480;
}
+ @AfterClass
+ public static void releaseClass() {
+ factory.shutdown();
+ factory=null;
+ }
+
@Before
public void initTest() {
caps = new GLCapabilities(glp);
@@ -106,8 +116,6 @@ public class TestDrawable01NEWT {
Assert.assertTrue(glCaps.getDoubleBuffered()==!onscreen);
Assert.assertTrue(glCaps.getDepthBits()>4);
- factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
- Assert.assertNotNull(factory);
drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
// System.out.println("Pre: "+drawable);
@@ -149,10 +157,6 @@ public class TestDrawable01NEWT {
drawable = null;
context = null;
window = null;
-
- // test code cont ..
- factory.shutdown();
- factory = null;
}
@Test
@@ -174,7 +178,22 @@ public class TestDrawable01NEWT {
}
public static void main(String args[]) {
- org.junit.runner.JUnitCore.main(TestDrawable01NEWT.class.getName());
+ String tstname = TestDrawable01NEWT.class.getName();
+ try {
+ 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" } );
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
index 436167dbf..e5e7c4a52 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
@@ -40,6 +40,8 @@ import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.After;
import org.junit.Test;
import javax.media.opengl.*;
@@ -52,48 +54,223 @@ import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
public class TestOffscreen01NEWT {
- int width, height;
- GLProfile glp;
+ static GLProfile glp;
+ static GLDrawableFactory factory;
+ static int width, height;
GLCapabilities caps;
- @Before
- public void init() {
+ @BeforeClass
+ public static void initClass() {
glp = GLProfile.getDefault();
+ Assert.assertNotNull(glp);
+ factory = GLDrawableFactory.getFactory(glp);
+ Assert.assertNotNull(factory);
width = 640;
height = 480;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ factory.shutdown();
+ factory=null;
+ }
+
+ @Before
+ public void init() {
caps = new GLCapabilities(glp);
}
+ private void do01OffscreenWindowPBuffer(GLCapabilities caps) {
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Window window = NewtFactory.createWindow(screen, caps, false /* undecorated */);
+ Assert.assertNotNull(window);
+ window.setSize(width, height);
+ GLWindow glWindow = GLWindow.create(window);
+ Assert.assertNotNull(glWindow);
+ glWindow.setVisible(true);
+ GLEventListener demo = new RedSquare();
+ WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
+
+ while ( glWindow.getTotalFrames() < 2) {
+ glWindow.display();
+ }
+
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
+ }
+ if(null!=screen) {
+ screen.destroy();
+ }
+ if(null!=display) {
+ display.destroy();
+ }
+ }
+
+ @Test
+ public void test01aOffscreenWindowPBuffer() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ do01OffscreenWindowPBuffer(caps2);
+ }
+
+ @Test
+ public void test01bOffscreenWindowPBufferStencil() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ caps2.setStencilBits(8);
+ do01OffscreenWindowPBuffer(caps2);
+ }
+
@Test
- public void test01OffscreenWindow() {
+ public void test01cOffscreenWindowPBufferStencilAlpha() {
GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ caps2.setStencilBits(8);
+ caps2.setAlphaBits(8);
+ do01OffscreenWindowPBuffer(caps2);
+ }
+
+ @Test
+ public void test01cOffscreenWindowPBuffer555() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ caps2.setRedBits(5);
+ caps2.setGreenBits(5);
+ caps2.setBlueBits(5);
+ do01OffscreenWindowPBuffer(caps2);
+ }
+
+ @Test
+ public void test02Offscreen3Windows1DisplayPBuffer() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ int winnum = 3, i;
+ Window windows[] = new Window[winnum];
+ GLWindow glWindows[] = new GLWindow[winnum];
+ GLEventListener demos[] = new GLEventListener[winnum];
Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
Assert.assertNotNull(screen);
+
+ for(i=0; i<winnum; i++) {
+ System.out.println("Create Window "+i);
+ windows[i] = NewtFactory.createWindow(screen, caps2, false /* undecorated */);
+ Assert.assertNotNull(windows[i]);
+ windows[i].setSize(width, height);
+ glWindows[i] = GLWindow.create(windows[i]);
+ Assert.assertNotNull(glWindows[i]);
+ glWindows[i].setVisible(true);
+ demos[i] = new RedSquare();
+ WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
+ }
+
+ while ( glWindows[0].getTotalFrames() < 2) {
+ for(i=0; i<winnum; i++) {
+ glWindows[i].display();
+ }
+ }
+
+ for(i=0; i<winnum; i++) {
+ if(null!=glWindows[i]) {
+ glWindows[i].destroy();
+ }
+ if(null!=windows[i]) {
+ windows[i].destroy();
+ }
+ }
+ if(null!=screen) {
+ screen.destroy();
+ }
+ if(null!=display) {
+ display.destroy();
+ }
+ }
+
+ @Test
+ public void test03Offscreen3Windows3DisplaysPBuffer() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ int winnum = 3, i;
+ Display displays[] = new Display[winnum];
+ Screen screens[] = new Screen[winnum];
+ Window windows[] = new Window[winnum];
+ GLWindow glWindows[] = new GLWindow[winnum];
+ GLEventListener demos[] = new GLEventListener[winnum];
+
+ for(i=0; i<winnum; i++) {
+ System.out.println("Create Window "+i);
+ displays[i] = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(displays[i]);
+ screens[i] = NewtFactory.createScreen(displays[i], 0); // screen 0
+ Assert.assertNotNull(screens[i]);
+ windows[i] = NewtFactory.createWindow(screens[i], caps2, false /* undecorated */);
+ Assert.assertNotNull(windows[i]);
+ windows[i].setSize(width, height);
+ glWindows[i] = GLWindow.create(windows[i]);
+ Assert.assertNotNull(glWindows[i]);
+ glWindows[i].setVisible(true);
+ demos[i] = new RedSquare();
+ WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
+ }
+
+ while ( glWindows[0].getTotalFrames() < 2) {
+ for(i=0; i<winnum; i++) {
+ glWindows[i].display();
+ }
+ }
+
+ for(i=0; i<winnum; i++) {
+ if(null!=glWindows[i]) {
+ glWindows[i].destroy();
+ }
+ if(null!=windows[i]) {
+ windows[i].destroy();
+ }
+ if(null!=screens[i]) {
+ screens[i].destroy();
+ }
+ if(null!=displays[i]) {
+ displays[i].destroy();
+ }
+ }
+ }
+
+ @Test
+ public void test04OffscreenSnapshotWithDemoPBuffer() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+
+ System.out.println("Create Window 1");
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
Window window = NewtFactory.createWindow(screen, caps2, false /* undecorated */);
Assert.assertNotNull(window);
window.setSize(width, height);
- GLWindow windowOffScreen = GLWindow.create(window);
- Assert.assertNotNull(windowOffScreen);
- windowOffScreen.setVisible(true);
+ GLWindow glWindow = GLWindow.create(window);
+ Assert.assertNotNull(glWindow);
+ glWindow.setVisible(true);
GLWindow windowOnScreen = null;
WindowListener wl=null;
MouseListener ml=null;
SurfaceUpdatedListener ul=null;
- WindowUtilNEWT.run(windowOffScreen, null, windowOnScreen, wl, ml, ul, 2, false /*snapshot*/, false /*debug*/);
- try {
- Thread.sleep(1000); // 1000 ms
- } catch (Exception e) {}
+ GLEventListener demo = new RedSquare();
+ Assert.assertNotNull(demo);
+
+ WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
if(null!=windowOnScreen) {
windowOnScreen.destroy();
}
- if(null!=windowOffScreen) {
- windowOffScreen.destroy();
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
}
if(null!=screen) {
screen.destroy();
@@ -104,8 +281,8 @@ public class TestOffscreen01NEWT {
}
@Test
- public void test02OffscreenSnapshotWithDemo() {
- GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false);
+ public void test11OffscreenWindowPixmap() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
@@ -114,9 +291,45 @@ public class TestOffscreen01NEWT {
Window window = NewtFactory.createWindow(screen, caps2, false /* undecorated */);
Assert.assertNotNull(window);
window.setSize(width, height);
- GLWindow windowOffScreen = GLWindow.create(window);
- Assert.assertNotNull(windowOffScreen);
- windowOffScreen.setVisible(true);
+ GLWindow glWindow = GLWindow.create(window);
+ Assert.assertNotNull(glWindow);
+ glWindow.setVisible(true);
+ GLEventListener demo = new RedSquare();
+ WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
+
+ while ( glWindow.getTotalFrames() < 2) {
+ glWindow.display();
+ }
+
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
+ }
+ if(null!=screen) {
+ screen.destroy();
+ }
+ if(null!=display) {
+ display.destroy();
+ }
+ }
+
+ @Test
+ public void test14OffscreenSnapshotWithDemoPixmap() {
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
+
+ System.out.println("Create Window 1");
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Window window = NewtFactory.createWindow(screen, caps2, false /* undecorated */);
+ Assert.assertNotNull(window);
+ window.setSize(width, height);
+ GLWindow glWindow = GLWindow.create(window);
+ Assert.assertNotNull(glWindow);
+ glWindow.setVisible(true);
GLWindow windowOnScreen = null;
WindowListener wl=null;
@@ -126,16 +339,16 @@ public class TestOffscreen01NEWT {
GLEventListener demo = new RedSquare();
Assert.assertNotNull(demo);
- WindowUtilNEWT.run(windowOffScreen, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
- try {
- Thread.sleep(1000); // 1000 ms
- } catch (Exception e) {}
+ WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
if(null!=windowOnScreen) {
windowOnScreen.destroy();
}
- if(null!=windowOffScreen) {
- windowOffScreen.destroy();
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
}
if(null!=screen) {
screen.destroy();
@@ -144,7 +357,6 @@ public class TestOffscreen01NEWT {
display.destroy();
}
}
-
public static void main(String args[]) {
String tstname = TestOffscreen01NEWT.class.getName();
try {
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
index f6a6dc4be..7afa7b1e5 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -52,22 +52,27 @@ public class WindowUtilNEWT {
return caps2;
}
+ public static void setDemoFields(GLEventListener demo, Window window, GLWindow glWindow, boolean debug) {
+ Assert.assertNotNull(demo);
+ Assert.assertNotNull(window);
+ if(debug) {
+ MiscUtils.setField(demo, "glDebug", new Boolean(true));
+ MiscUtils.setField(demo, "glTrace", new Boolean(true));
+ }
+ if(!MiscUtils.setField(demo, "window", window)) {
+ MiscUtils.setField(demo, "glWindow", glWindow);
+ }
+ }
+
public static void run(GLWindow windowOffScreen, GLEventListener demo,
GLWindow windowOnScreen, WindowListener wl, MouseListener ml,
SurfaceUpdatedListener ul, int frames, boolean snapshot, boolean debug) {
try {
Assert.assertNotNull(windowOffScreen);
+ Assert.assertNotNull(demo);
- if(debug && null!=demo) {
- MiscUtils.setField(demo, "glDebug", new Boolean(true));
- MiscUtils.setField(demo, "glTrace", new Boolean(true));
- }
- if(null!=demo) {
- if(!MiscUtils.setField(demo, "window", windowOffScreen)) {
- MiscUtils.setField(demo, "glWindow", windowOffScreen);
- }
- windowOffScreen.addGLEventListener(demo);
- }
+ setDemoFields(demo, windowOffScreen, windowOffScreen, debug);
+ windowOffScreen.addGLEventListener(demo);
if ( null != windowOnScreen ) {
if(null!=wl) {