aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-09-27 13:23:39 +0200
committerSven Gothel <[email protected]>2013-09-27 13:23:39 +0200
commit9a8f9b9f7e6148b60b6f0f4326df8d213774284c (patch)
treeb8e060224a4a6a26cee30103fc6ae2ac0bd2e6f7 /src/test/com/jogamp/opengl
parent4ef53cf2ae509a625795bfa3a8982ce75e24e83a (diff)
Bug 816: Fix JAWTWindow's getLocationOnScreenNonBlocking(); Derive CALayer position from AWT component's location on screen. Track fixedFrame size of root CALayer; Add Split layout to unit test, add [manual] Applet tests.
- Fix JAWTWindow's getLocationOnScreenNonBlocking() Skip JRootPane while traversing up to root Container. JRootPane would duplicate the top-level container's offset (Window insets). - Derive CALayer position from AWT component's location on screen. Add Split layout to unit test, add [manual] Applet tests. AWT >= 7u40: - AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. - Use getLocationOnScreenNonBlocking() to get location-on-screen w/o insets. - Native code: flip origin AWT < 7u40 still uses fixed position 0/0 for root and sub layer. - Track fixedFrame size of root CALayer - MyCALayer: - Override layoutSublayers to validate root and sub-layer pos/size - Override setFrame to use fixedFrame, if set (similar to MyNSOpenGLLayer) - Add Split layout to unit test, add [manual] Applet tests. - Thx to 'jimthev' and 'Manu' for providing Applet unit tests
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java98
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java134
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java85
3 files changed, 304 insertions, 13 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java
index 48340aa75..358e97622 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java
@@ -33,8 +33,13 @@ import javax.media.opengl.*;
import com.jogamp.opengl.util.Animator;
import javax.media.opengl.awt.GLCanvas;
+import javax.swing.BoundedRangeModel;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.ScrollPaneConstants;
import com.jogamp.common.util.awt.AWTEDTExecutor;
import com.jogamp.newt.event.awt.AWTWindowAdapter;
@@ -68,9 +73,15 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+/**
+ * Bug 816: OSX CALayer Positioning Bug.
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug816OSXCALayerPosAWT extends UITestCase {
- public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box };
+ public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box, Split };
static long duration = 1600; // ms
static int width, height;
@@ -113,7 +124,7 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
comp2.setPreferredSize(new_sz2);
comp2.setSize(new_sz2);
}
- if( null != frame ) {
+ if( null != frame ) {
frame.pack();
}
} } );
@@ -206,6 +217,39 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
framePane.add(c);
}
break;
+ case Split: {
+ Dimension sbDim = new Dimension(16, 16);
+ JScrollPane vsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ {
+ JScrollBar vsb = vsp.getVerticalScrollBar();
+ vsb.setPreferredSize(sbDim);
+ BoundedRangeModel model = vsb.getModel();
+ model.setMinimum(0);
+ model.setMaximum(100);
+ model.setValue(50);
+ model.setExtent(1);
+ vsb.setEnabled(true);
+ }
+ JScrollPane hsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
+ {
+ JScrollBar hsb = hsp.getHorizontalScrollBar();
+ hsb.setPreferredSize(sbDim);
+ BoundedRangeModel model = hsb.getModel();
+ model.setMinimum(0);
+ model.setMaximum(100);
+ model.setValue(50);
+ model.setExtent(1);
+ hsb.setEnabled(true);
+ }
+ JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
+ twoCanvas ? glCanvas2 : vsp, glCanvas1 );
+ horizontalSplitPane.setResizeWeight(0.5);
+ JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ true, horizontalSplitPane, hsp);
+ verticalSplitPane.setResizeWeight(0.5);
+ framePane.add(verticalSplitPane);
+ }
+ break;
}
final GearsES2 demo1 = new GearsES2(swapInterval);
glCanvas1.addGLEventListener(demo1);
@@ -329,27 +373,41 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
}
@Test
- public void test04_Compo_Flow_Two() throws InterruptedException, InvocationTargetException {
+ public void test04_Compo_Split_One() throws InterruptedException, InvocationTargetException {
if( testNum != -1 && testNum != 4 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
+ runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, true /* resizeByComp */);
+ }
+
+ @Test
+ public void test05_Compo_Flow_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 5 ) { return ; }
+ final GLCapabilities caps = new GLCapabilities(getGLP());
runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, true /* resizeByComp */);
}
@Test
- public void test05_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException {
- if( testNum != -1 && testNum != 5 ) { return ; }
+ public void test06_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 6 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, true /* resizeByComp */);
}
@Test
- public void test06_Compo_Box_Two() throws InterruptedException, InvocationTargetException {
- if( testNum != -1 && testNum != 6 ) { return ; }
+ public void test07_Compo_Box_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 7 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, true /* resizeByComp */);
}
@Test
+ public void test08_Compo_Split_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 8 ) { return ; }
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+ runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, true /* resizeByComp */);
+ }
+
+ @Test
public void test10_Frame_None_One() throws InterruptedException, InvocationTargetException {
if( testNum != -1 && testNum != 10 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
@@ -378,26 +436,40 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase {
}
@Test
- public void test14_Frame_Flow_Two() throws InterruptedException, InvocationTargetException {
- if( testNum != -1 && testNum != 14 ) { return ; }
+ public void test14_Frame_Split_One() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 14) { return ; }
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+ runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, false /* resizeByComp */);
+ }
+
+ @Test
+ public void test15_Frame_Flow_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 15 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, false /* resizeByComp */);
}
@Test
- public void test15_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException {
- if( testNum != -1 && testNum != 15 ) { return ; }
+ public void test16_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 16 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, false /* resizeByComp */);
}
@Test
- public void test16_Frame_Box_Two() throws InterruptedException, InvocationTargetException {
- if( testNum != -1 && testNum != 16 ) { return ; }
+ public void test17_Frame_Box_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 17 ) { return ; }
final GLCapabilities caps = new GLCapabilities(getGLP());
runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, false /* resizeByComp */);
}
+ @Test
+ public void test18_Frame_Split_Two() throws InterruptedException, InvocationTargetException {
+ if( testNum != -1 && testNum != 18 ) { return ; }
+ final GLCapabilities caps = new GLCapabilities(getGLP());
+ runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, false /* resizeByComp */);
+ }
+
static int testNum = -1;
public static void main(String args[]) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java
new file mode 100644
index 000000000..175b053d1
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
+
+import java.applet.Applet;
+import java.awt.Color;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug.
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ * <p>
+ * Test simply positions a GLCanvas via setBounds(..) within it's Applet.
+ * </p>
+ */
+@SuppressWarnings("serial")
+public class Bug816AppletGLCanvas01 extends Applet implements GLEventListener {
+
+ public Bug816AppletGLCanvas01() {
+ }
+
+ public static JFrame frame;
+ public static JPanel appletHolder;
+ public static boolean isApplet = true;
+
+ static public void main(String args[]) {
+ Applet myApplet = null;
+ isApplet = false;
+
+ myApplet = new Bug816AppletGLCanvas01();
+ appletStarter(myApplet, "Bug861AppletGLCanvasTest01", 800, 600);
+ }
+
+ static public void appletStarter(final Applet des, String frameName, int width, int height) {
+ appletHolder = new JPanel();
+ if (frame != null) {
+ frame.dispose();
+ frame = null;
+ }
+ frame = new JFrame(frameName);
+ frame.setVisible(false);
+ frame.getContentPane().add(appletHolder);
+
+ appletHolder.setLayout(null);
+ des.setBounds(0, 0, width, height);
+ appletHolder.add(des);
+
+ frame.setVisible(true);
+ int frameBorderSize = appletHolder.getLocationOnScreen().x - frame.getLocationOnScreen().x;
+ int titleBarHeight = appletHolder.getLocationOnScreen().y - frame.getLocationOnScreen().y;
+ int frameWidth = width + 2 * frameBorderSize;
+ int frameHeight = height + titleBarHeight + frameBorderSize;
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(frameWidth, frameHeight);
+ frame.setVisible(true);
+ des.init();
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+
+ public void init() {
+ initOpenGLAWT();
+ }
+
+ public void initOpenGLAWT() {
+ setBackground(Color.gray);
+ setLayout(null);
+
+ GLProfile glp = GLProfile.getDefault();
+ GLCapabilities caps = new GLCapabilities(glp);
+ GLCanvas canvas = new GLCanvas((GLCapabilitiesImmutable) caps);
+ canvas.setBounds(50, 50, 200, 450);
+ canvas.addGLEventListener(this);
+ add(canvas);
+ }
+
+ public void init(GLAutoDrawable gLAutoDrawable) {
+ GL gl = gLAutoDrawable.getGL();
+ gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ gLAutoDrawable.swapBuffers();
+ }
+
+ public void dispose(GLAutoDrawable glad) {
+ }
+
+ public void display(GLAutoDrawable glad) {
+ }
+
+ public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) {
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java
new file mode 100644
index 000000000..9ae0a2bbd
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.es2.awt;
+
+import java.applet.Applet;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.BoxLayout;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Bug 816: OSX CALayer Positioning Bug.
+ * <p>
+ * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40
+ * </p>
+ * <p>
+ * Test uses a box layout within the Applet.
+ * </p>
+ */
+@SuppressWarnings("serial")
+public class Bug816AppletGLCanvas02 extends Applet {
+ private List<GLAnimatorControl> animators = new ArrayList<GLAnimatorControl>(2);
+
+ @Override
+ public void init() {
+ System.err.println("GearsApplet: init() - begin");
+ new BoxLayout(this, BoxLayout.X_AXIS);
+ setSize(600, 300);
+ add(createCanvas());
+ add(createCanvas());
+ System.err.println("GearsApplet: init() - end");
+ }
+
+ private GLCanvas createCanvas() {
+ GLCanvas canvas = new GLCanvas();
+ canvas.addGLEventListener(new GearsES2(1));
+ canvas.setSize(300, 300);
+ animators.add(new Animator(canvas));
+ return canvas;
+ }
+
+ @Override
+ public void start() {
+ for (GLAnimatorControl control : animators) {
+ control.start();
+ }
+ }
+
+ @Override
+ public void stop() {
+ for (GLAnimatorControl control : animators) {
+ control.stop();
+ }
+ }
+}