From c2e02b9964860dc59af92187ae124695e1e2f1dc Mon Sep 17 00:00:00 2001 From: Julien Gouesse Date: Fri, 5 Apr 2013 19:11:38 +0200 Subject: Adds a unit test and a fix for the bug 697 --- .../newt/TestGLWindowInvisiblePointer01NEWT.java | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestGLWindowInvisiblePointer01NEWT.java (limited to 'src') diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindowInvisiblePointer01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindowInvisiblePointer01NEWT.java new file mode 100644 index 000000000..ba69481a3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindowInvisiblePointer01NEWT.java @@ -0,0 +1,114 @@ +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Screen; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestGLWindowInvisiblePointer01NEWT extends UITestCase { + static GLProfile glp; + static int width, height; + static long durationPerTest = 4000; // ms + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + static GLWindow createWindow(Screen screen, GLCapabilitiesImmutable caps) + throws InterruptedException + { + Assert.assertNotNull(caps); + // + // Create native windowing resources .. X11/Win/OSX + // + GLWindow glWindow; + if(null!=screen) { + glWindow = GLWindow.create(screen, caps); + Assert.assertNotNull(glWindow); + } else { + glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + } + glWindow.setUpdateFPSFrames(1, null); + + GLEventListener demo = new GearsES1(); + glWindow.addGLEventListener(demo); + + glWindow.setSize(512, 512); + glWindow.setVisible(true); + Assert.assertEquals(true,glWindow.isVisible()); + Assert.assertEquals(true,glWindow.isNativeValid()); + + return glWindow; + } + + static void destroyWindow(GLWindow glWindow) { + if(null!=glWindow) { + glWindow.destroy(); + Assert.assertEquals(false,glWindow.isNativeValid()); + } + } + + @Test + public void testWindow00() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + GLWindow window1 = createWindow(null, caps); // local + Assert.assertEquals(true,window1.isNativeValid()); + Assert.assertEquals(true,window1.isVisible()); + Animator animator = new Animator(); + animator.setUpdateFPSFrames(1, null); + animator.add(window1); + animator.start(); + AbstractGraphicsDevice device1 = window1.getScreen().getDisplay().getGraphicsDevice(); + + System.err.println("GLProfiles window1: "+device1.getConnection()+": "+GLProfile.glAvailabilityToString(device1)); + + window1.warpPointer(width / 2, height / 2); + window1.requestFocus(); + while(animator.isAnimating() && animator.getTotalFPSDuration()