summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java70
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java334
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01AWT.java225
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java23
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java71
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java1
32 files changed, 748 insertions, 78 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
index 21eb8af2d..74419e564 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
@@ -62,7 +62,7 @@ public class NEWTElektronActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new ElektronenMultiplizierer());
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index 337dafc71..ba861d012 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -62,7 +62,7 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GearsES1(1));
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index 6abb0b354..89ecf4cb9 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -65,7 +65,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
GearsES2 demo = new GearsES2(0);
// demo.enableAndroidTrace(true);
glWindow.addGLEventListener(demo);
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
index 691151ef3..d6b7507a3 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
@@ -61,7 +61,7 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GearsES2(1));
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
index 83f35879b..1efedcd6d 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
@@ -61,7 +61,7 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GPUUISceneGLListener0A(0));
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
index 17924d43d..39fb5e2cc 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
@@ -62,7 +62,7 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT));
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
index 24b4eaf0c..99d7fd723 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
@@ -61,7 +61,7 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity {
setContentView(getWindow(), glWindow);
glWindow.addGLEventListener(new RedSquareES1(1));
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
index 51cddd523..804e627a5 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
@@ -64,7 +64,7 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
final RedSquareES2 demo = new RedSquareES2(0);
// demo.enableAndroidTrace(true);
glWindow.addGLEventListener(demo);
- glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index 8d579ce5d..b5a729e02 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -21,6 +21,7 @@
package com.jogamp.opengl.test.junit.jogl.demos.es1;
+import javax.media.nativewindow.NativeWindow;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
@@ -181,8 +182,18 @@ public class GearsES1 implements GLEventListener {
// Get the GL corresponding to the drawable we are animating
GL2ES1 gl = drawable.getGL().getGL2ES1();
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
+ final boolean hasFocus;
+ if(drawable.getNativeSurface() instanceof NativeWindow) {
+ hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus();
+ } else {
+ hasFocus = true;
+ }
+ if(hasFocus) {
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ } else {
+ gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
+ }
+
// Special handling for the case where the GLJPanel is translucent
// and wants to be composited with other Java 2D content
if (GLProfile.isAWTAvailable() &&
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 3fa61bf1d..51bc7d137 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -34,6 +34,8 @@ import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
import java.nio.FloatBuffer;
+
+import javax.media.nativewindow.NativeWindow;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
@@ -244,8 +246,18 @@ public class GearsES2 implements GLEventListener {
// Get the GL corresponding to the drawable we are animating
GL2ES2 gl = drawable.getGL().getGL2ES2();
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
+ final boolean hasFocus;
+ if(drawable.getNativeSurface() instanceof NativeWindow) {
+ hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus();
+ } else {
+ hasFocus = true;
+ }
+ if(hasFocus) {
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ } else {
+ gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
+ }
+
// Special handling for the case where the GLJPanel is translucent
// and wants to be composited with other Java 2D content
if (GLProfile.isAWTAvailable() &&
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index 01790de10..d645fb9f8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -205,7 +205,7 @@ public class RedSquareES2 implements GLEventListener {
class MyMouseAdapter extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
System.err.println(e);
- if(null != glWindow && e.getSource() == glWindow.getWindow()) {
+ if(null != glWindow && e.getSource() == glWindow.getDelegatedWindow()) {
if(e.getX() < glWindow.getWidth()/2) {
glWindow.setFullscreen(!glWindow.isFullscreen());
System.err.println("setFullscreen: "+glWindow.isFullscreen());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
index 8ab641267..83e3663dc 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
@@ -72,7 +72,7 @@ public class TestGearsAWT extends UITestCase {
frame.add(glCanvas);
frame.setSize(512, 512);
- glCanvas.addGLEventListener(new Gears());
+ glCanvas.addGLEventListener(new Gears(1));
Animator animator = new Animator(glCanvas);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -81,7 +81,7 @@ public class TestGearsAWT extends UITestCase {
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
frame.setVisible(true);
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
index 199b094f2..1d1ee1e0c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -103,7 +103,7 @@ public class WindowUtilNEWT {
while ( windowOffScreen.getTotalFPSFrames() < frames) {
windowOffScreen.display();
}
- windowOffScreen.removeAllSurfaceUpdatedListener();
+ windowOffScreen.removeSurfaceUpdatedListener(ul);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
index 3e153214b..b2a7e9a5e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
@@ -156,7 +156,7 @@ public class TestSWT02GLn extends UITestCase {
ProxySurface proxySurface = factory.createProxySurface(device, nativeWindowHandle, caps, null);
Assert.assertNotNull( proxySurface );
- proxySurface.setSize( 640, 480 );
+ proxySurface.surfaceSizeChanged( 640, 480 );
System.err.println("*** ProxySurface: " + proxySurface);
final GLDrawable drawable = factory.createGLDrawable(proxySurface);
Assert.assertNotNull( drawable );
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java
index adc885191..664cab03b 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java
@@ -39,10 +39,9 @@ import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.util.Point;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
+
import com.jogamp.newt.Window;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -53,6 +52,7 @@ public class TestCloseNewtAWT extends UITestCase {
NewtCanvasAWT newtCanvas = null;
JFrame frame = null;
+ @SuppressWarnings("serial")
class MyCanvas extends NewtCanvasAWT {
public MyCanvas(Window window) {
super(window);
@@ -78,7 +78,7 @@ public class TestCloseNewtAWT extends UITestCase {
NativeWindow nw = MyCanvas.this.getNativeWindow();
if(null != nw) {
Point p = nw.getLocationOnScreen(null);
- System.err.println("MyCanvas On NEWT-EDT: position: "+p);
+ System.err.println("MyCanvas On NEWT-EDT: position: "+p);
} else {
System.err.println("MyCanvas On NEWT-EDT: position n/a, null NativeWindow");
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
index 13653b907..fe7fef09f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
@@ -35,6 +35,7 @@ import org.junit.Assume;
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Button;
+import java.awt.Color;
import java.awt.Robot;
import java.lang.reflect.InvocationTargetException;
@@ -119,7 +120,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
AWTFocusAdapter frame1FA = new AWTFocusAdapter("frame1");
frame1.addFocusListener(frame1FA);
frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER);
- Button button = new Button("Click me ..");
+ final Button button = new Button("Click me ..");
AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button");
button.addFocusListener(buttonFA);
AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button");
@@ -127,7 +128,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
eventCountAdapters.add(buttonKA);
frame1.getContentPane().add(button, BorderLayout.NORTH);
frame1.setSize(width, height);
- frame1.setVisible(true);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame1.setVisible(true);
+ } } );
Assert.assertTrue(AWTRobotUtil.toFront(robot, frame1));
Thread.sleep(durationPerTest); // manual testing
@@ -162,7 +166,6 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
System.err.println("FOCUS NEWT Canvas/GLWindow request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA);
- Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA));
Assert.assertEquals(true, glWindow1FA.focusGained());
Assert.assertEquals(false, buttonFA.focusGained());
Assert.assertEquals(true, buttonFA.focusLost());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
index 56b08b52a..b9eb748b7 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
@@ -145,14 +145,17 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
jPanel1.add(new Button("west"), BorderLayout.WEST);
jPanel1.add(container1, BorderLayout.CENTER);
- JFrame jFrame1 = new JFrame("Swing Parent JFrame");
+ final JFrame jFrame1 = new JFrame("Swing Parent JFrame");
AWTFocusAdapter jFrame1FA = new AWTFocusAdapter("JFrame1");
jFrame1.addFocusListener(jFrame1FA);
// jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event!
jFrame1.setContentPane(jPanel1);
jFrame1.setSize(width, height);
- jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ jFrame1.setVisible(true);
+ } } );
Assert.assertTrue(AWTRobotUtil.toFront(robot, jFrame1));
int wait=0;
@@ -192,7 +195,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
System.err.println("FOCUS NEWT Canvas/GLWindow request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA);
- Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA));
Assert.assertEquals(true, glWindow1FA.focusGained());
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
Assert.assertEquals(true, buttonNorthOuterFA.focusLost());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
index 15151fa2c..429ef59cd 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
@@ -111,7 +111,7 @@ public class TestListenerCom01AWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
index 46748cb52..473f2f584 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -51,7 +51,11 @@ class NewtAWTReparentingKeyAdapter extends KeyAdapter {
if(e.getKeyChar()=='d') {
glWindow.setUndecorated(!glWindow.isUndecorated());
} else if(e.getKeyChar()=='f') {
- glWindow.setFullscreen(!glWindow.isFullscreen());
+ glWindow.setFullscreen(!glWindow.isFullscreen());
+ } else if(e.getKeyChar()=='l') {
+ javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null);
+ javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
+ System.err.println("NewtCanvasAWT position: "+p0+", "+p1);
} else if(e.getKeyChar()=='p') {
new Thread() {
public void run() {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
index 7f97be649..b49cf2670 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
@@ -654,7 +654,7 @@ public class TestParenting01NEWT extends UITestCase {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
}
- if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getWindow())) {
+ if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getDelegatedWindow())) {
MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
index 674cf4a06..2040fb9b6 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
@@ -467,7 +467,7 @@ public class TestParenting01aAWT extends UITestCase {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
}
- if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getWindow())) {
+ if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getDelegatedWindow())) {
MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
index 8571609a8..d98a540ec 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
@@ -173,7 +173,7 @@ public class TestParenting01bAWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
index 3b40554d2..dfd0787e7 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
@@ -228,7 +228,7 @@ public class TestParenting01cAWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
index f505547d4..22ed7c6fd 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
@@ -319,7 +319,7 @@ public class TestParenting01cSwingAWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
index f01468c2a..39759de9f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
@@ -233,7 +233,7 @@ public class TestParenting02AWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
index aded8f163..8f0da4000 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
@@ -35,10 +35,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import java.awt.BorderLayout;
+import java.awt.Button;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
-import java.awt.Label;
import javax.media.opengl.*;
@@ -53,28 +53,34 @@ import com.jogamp.opengl.test.junit.util.*;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
public class TestParenting03AWT extends UITestCase {
- static Dimension size;
+ static Dimension glSize, fSize;
static long durationPerTest = 800;
static long waitAdd2nd = 500;
static GLCapabilities glCaps;
@BeforeClass
public static void initClass() {
- size = new Dimension(400,200);
+ glSize = new Dimension(400,200);
+ fSize = new Dimension(3*400,2*200);
glCaps = new GLCapabilities(null);
}
@Test
- public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException {
- testWindowParenting1AWTTwoNewtChilds();
+ public void testWindowParenting1AWTOneNewtChilds01() throws InterruptedException, InvocationTargetException {
+ testWindowParenting1AWT(false);
}
- public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException {
+ @Test
+ public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException {
+ testWindowParenting1AWT(true);
+ }
+
+ public void testWindowParenting1AWT(boolean use2nd) throws InterruptedException, InvocationTargetException {
final Frame frame1 = new Frame("AWT Parent Frame");
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setUpdateFPSFrames(1, null);
final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
- newtCanvasAWT1.setPreferredSize(size);
+ newtCanvasAWT1.setPreferredSize(glSize);
GLEventListener demo1 = new GearsES2(1);
setDemoFields(demo1, glWindow1, false);
@@ -83,7 +89,6 @@ public class TestParenting03AWT extends UITestCase {
GLAnimatorControl animator1 = new Animator(glWindow1);
animator1.start();
- final boolean use2nd = true;
GLWindow glWindow2 = null;
NewtCanvasAWT newtCanvasAWT2 = null;
GLAnimatorControl animator2 = null;
@@ -91,7 +96,7 @@ public class TestParenting03AWT extends UITestCase {
glWindow2 = GLWindow.create(glCaps);
glWindow2.setUpdateFPSFrames(1, null);
newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
- newtCanvasAWT2.setPreferredSize(size);
+ newtCanvasAWT2.setPreferredSize(glSize);
GLEventListener demo2 = new GearsES2(1);
setDemoFields(demo2, glWindow2, false);
@@ -103,10 +108,10 @@ public class TestParenting03AWT extends UITestCase {
final Container cont1 = new Container();
cont1.setLayout(new BorderLayout());
- cont1.add(new Label("iNORTH"), BorderLayout.NORTH);
- cont1.add(new Label("iSOUTH"), BorderLayout.SOUTH);
- cont1.add(new Label("iEAST"), BorderLayout.EAST);
- cont1.add(new Label("iWEST"), BorderLayout.WEST);
+ cont1.add(new Button("NORTH"), BorderLayout.NORTH);
+ cont1.add(new Button("SOUTH"), BorderLayout.SOUTH);
+ cont1.add(new Button("EAST"), BorderLayout.EAST);
+ cont1.add(new Button("WEST"), BorderLayout.WEST);
cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
System.err.println("******* Cont1 setVisible");
cont1.setVisible(true);
@@ -114,34 +119,31 @@ public class TestParenting03AWT extends UITestCase {
final Container cont2 = new Container();
cont2.setLayout(new BorderLayout());
if(use2nd) {
- cont2.add(new Label("iNORTH"), BorderLayout.NORTH);
- cont2.add(new Label("iSOUTH"), BorderLayout.SOUTH);
- cont2.add(new Label("iEAST"), BorderLayout.EAST);
- cont2.add(new Label("iWEST"), BorderLayout.WEST);
+ cont2.add(new Button("north"), BorderLayout.NORTH);
+ cont2.add(new Button("sourth"), BorderLayout.SOUTH);
+ cont2.add(new Button("east"), BorderLayout.EAST);
+ cont2.add(new Button("west"), BorderLayout.WEST);
cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
}
System.err.println("******* Cont2 setVisible");
cont2.setVisible(true);
frame1.setLayout(new BorderLayout());
- frame1.add(new Label("NORTH"), BorderLayout.NORTH);
- frame1.add(new Label("CENTER"), BorderLayout.CENTER);
- frame1.add(new Label("SOUTH"), BorderLayout.SOUTH);
+ frame1.add(new Button("NORTH"), BorderLayout.NORTH);
+ frame1.add(new Button("CENTER"), BorderLayout.CENTER);
+ frame1.add(new Button("SOUTH"), BorderLayout.SOUTH);
frame1.add(cont1, BorderLayout.EAST);
frame1.setLocation(0, 0);
- frame1.setSize((int)size.getWidth()*3, (int)size.getHeight()*2);
+ frame1.setSize(fSize);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
System.err.println("******* Frame setVisible");
+ frame1.validate();
frame1.setVisible(true);
}});
Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
- if(use2nd) {
- Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent());
- }
-
Assert.assertEquals(true, animator1.isAnimating());
Assert.assertEquals(false, animator1.isPaused());
Assert.assertNotNull(animator1.getThread());
@@ -150,15 +152,17 @@ public class TestParenting03AWT extends UITestCase {
Assert.assertEquals(true, animator2.isAnimating());
Assert.assertEquals(false, animator2.isPaused());
Assert.assertNotNull(animator2.getThread());
- }
- Thread.sleep(waitAdd2nd);
+ Thread.sleep(waitAdd2nd);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame1.add(cont2, BorderLayout.WEST);
+ frame1.validate();
+ }});
+ Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent());
+ }
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- frame1.add(cont2, BorderLayout.WEST);
- frame1.validate();
- }});
Thread.sleep(durationPerTest);
@@ -187,7 +191,7 @@ public class TestParenting03AWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
new file mode 100644
index 000000000..b23c17022
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
@@ -0,0 +1,334 @@
+/**
+ * Copyright 2010 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.newt.parenting;
+
+import java.lang.reflect.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.awt.AWTException;
+import java.awt.AWTKeyStroke;
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.KeyboardFocusManager;
+import java.awt.Robot;
+
+import javax.media.opengl.*;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.newt.*;
+import com.jogamp.newt.opengl.*;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+
+import java.io.IOException;
+
+import jogamp.newt.driver.DriverClearFocus;
+
+import com.jogamp.opengl.test.junit.util.*;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+public class TestParentingFocusTraversal01AWT extends UITestCase {
+ static Dimension glSize, fSize;
+ static int numFocus = 8;
+ static long durationPerTest = numFocus * 100;
+ static GLCapabilities glCaps;
+ static boolean manual = false;
+
+ @BeforeClass
+ public static void initClass() {
+ glSize = new Dimension(200,200);
+ fSize = new Dimension(300,300);
+ glCaps = new GLCapabilities(null);
+ }
+
+ @Test
+ public void testWindowParentingAWTFocusTraversal01Onscreen() throws InterruptedException, InvocationTargetException, AWTException {
+ testWindowParentingAWTFocusTraversal(true);
+ }
+
+ @Test
+ public void testWindowParentingAWTFocusTraversal02Offscreen() throws InterruptedException, InvocationTargetException, AWTException {
+ testWindowParentingAWTFocusTraversal(false);
+ }
+
+ public void testWindowParentingAWTFocusTraversal(boolean onscreen) throws InterruptedException, InvocationTargetException, AWTException {
+ Robot robot = new Robot();
+
+ // Bug 4908075 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4908075
+ // Bug 6463168 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6463168
+ {
+ final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ final Set<AWTKeyStroke> bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ final AWTKeyStroke newBack = AWTKeyStroke.getAWTKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false);
+ Assert.assertNotNull(newBack);
+ final Set<AWTKeyStroke> bwdKeys2 = new HashSet<AWTKeyStroke>(bwdKeys);
+ bwdKeys2.add(newBack);
+ kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdKeys2);
+ }
+ {
+ final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ final Set<AWTKeyStroke> fwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ final Set<AWTKeyStroke> bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ Iterator<AWTKeyStroke> iter;
+ for(iter = fwdKeys.iterator(); iter.hasNext(); ) {
+ System.err.println("FTKL.fwd-keys: "+iter.next());
+ }
+ for(iter = bwdKeys.iterator(); iter.hasNext(); ) {
+ System.err.println("FTKL.bwd-keys: "+iter.next());
+ }
+ }
+
+ final Frame frame1 = new Frame("AWT Parent Frame");
+ final Button cWest = new Button("WEST");
+ final Button cEast = new Button("EAST");
+ final GLWindow glWindow1 = GLWindow.create(glCaps);
+ glWindow1.setUpdateFPSFrames(1, null);
+ final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+ newtCanvasAWT1.setPreferredSize(glSize);
+ newtCanvasAWT1.setShallUseOffscreenLayer(!onscreen);
+ newtCanvasAWT1.setFocusable(true);
+
+ // Test FocusAdapter
+ NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
+ glWindow1.addWindowListener(glWindow1FA);
+ AWTFocusAdapter bWestFA = new AWTFocusAdapter("WEST");
+ cWest.addFocusListener(bWestFA);
+ AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST");
+ cEast.addFocusListener(bEastFA);
+
+ // Test KeyAdapter
+ NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1");
+ glWindow1.addKeyListener(glWindow1KA);
+ AWTKeyAdapter bWestKA = new AWTKeyAdapter("West");
+ cWest.addKeyListener(bWestKA);
+ AWTKeyAdapter bEastKA = new AWTKeyAdapter("East");
+ cEast.addKeyListener(bEastKA);
+
+ // demo ..
+ GLEventListener demo1 = new GearsES2(1);
+ setDemoFields(demo1, glWindow1, false);
+ glWindow1.addGLEventListener(demo1);
+ glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+ glWindow1.addKeyListener(new KeyAdapter() {
+ public void keyTyped(KeyEvent e) {
+ if(e.getKeyChar()=='c') {
+ System.err.println("Focus Clear");
+ if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) {
+ ((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus();
+ }
+ } else if(e.getKeyChar()=='e') {
+ System.err.println("Focus East");
+ try {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ cEast.requestFocusInWindow();
+ }
+ });
+ } catch (Exception ex) { ex.printStackTrace(); }
+ } else if(e.getKeyChar()=='w') {
+ System.err.println("Focus West");
+ try {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ cWest.requestFocusInWindow();
+ }
+ });
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ });
+ GLAnimatorControl animator1 = new Animator(glWindow1);
+ animator1.start();
+
+ // make frame
+ frame1.setLayout(new BorderLayout());
+ frame1.setLayout(new BorderLayout());
+ frame1.add(cWest, BorderLayout.WEST);
+ frame1.add(newtCanvasAWT1, BorderLayout.CENTER);
+ frame1.add(cEast, BorderLayout.EAST);
+
+ frame1.setLocation(0, 0);
+ frame1.setSize(fSize);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame1.validate();
+ frame1.setVisible(true);
+ }});
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true));
+ Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
+
+ Assert.assertEquals(true, animator1.isAnimating());
+ Assert.assertEquals(false, animator1.isPaused());
+ Assert.assertNotNull(animator1.getThread());
+
+ if(manual) {
+ Thread.sleep(durationPerTest);
+ } else {
+ //
+ // initial focus on bWest
+ //
+ AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null);
+ Assert.assertEquals(true, bWestFA.focusGained());
+ Thread.sleep(durationPerTest/numFocus);
+
+ //
+ // forth
+ //
+
+ // bWest -> glWin
+ AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, cWest, null);
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA));
+ Assert.assertEquals(true, glWindow1FA.focusGained());
+ Assert.assertEquals(true, bWestFA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+
+ // glWin -> bEast
+ AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, glWindow1, null);
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cEast, bEastFA, glWindow1FA));
+ Assert.assertEquals(true, bEastFA.focusGained());
+ Assert.assertEquals(true, glWindow1FA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+
+ //
+ // back (using custom back traversal key 'backspace')
+ //
+ // bEast -> glWin
+ AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, cEast, null);
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bEastFA));
+ Assert.assertEquals(true, glWindow1FA.focusGained());
+ Assert.assertEquals(true, bEastFA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+
+ AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, glWindow1, null);
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA));
+ Assert.assertEquals(true, bWestFA.focusGained());
+ Assert.assertEquals(true, glWindow1FA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+
+ // direct AWT request focus
+ try {
+ java.awt.EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ newtCanvasAWT1.requestFocus();
+ }
+ });
+ } catch (Exception ex) { ex.printStackTrace(); }
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA));
+ Assert.assertEquals(true, glWindow1FA.focusGained());
+ Assert.assertEquals(true, bWestFA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+
+ // direct AWT request focus
+ try {
+ java.awt.EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ cWest.requestFocus();
+ }
+ });
+ } catch (Exception ex) { ex.printStackTrace(); }
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA));
+ Assert.assertEquals(true, bWestFA.focusGained());
+ Assert.assertEquals(true, glWindow1FA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+
+ // direct NEWT request focus
+ glWindow1.requestFocus();
+ Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA));
+ Assert.assertEquals(true, glWindow1FA.focusGained());
+ Assert.assertEquals(true, bWestFA.focusLost());
+ Thread.sleep(durationPerTest/numFocus);
+ }
+
+ animator1.stop();
+ Assert.assertEquals(false, animator1.isAnimating());
+ Assert.assertEquals(false, animator1.isPaused());
+ Assert.assertEquals(null, animator1.getThread());
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame1.dispose();
+ } } );
+ glWindow1.destroy();
+ }
+
+ public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
+ Assert.assertNotNull(demo);
+ Assert.assertNotNull(glWindow);
+ Window window = glWindow.getDelegatedWindow();
+ if(debug) {
+ MiscUtils.setFieldIfExists(demo, "glDebug", true);
+ MiscUtils.setFieldIfExists(demo, "glTrace", true);
+ }
+ if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
+ MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
+ }
+ }
+
+ 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[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ durationPerTest = atoi(args[++i]);
+ } else if(args[i].equals("-manual")) {
+ manual = true;
+ }
+ }
+ String tstname = TestParentingFocusTraversal01AWT.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" } ); */
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01AWT.java
new file mode 100644
index 000000000..fb2f7342e
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01AWT.java
@@ -0,0 +1,225 @@
+/**
+ * Copyright 2011 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.newt.parenting;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestParentingOffscreenLayer01AWT extends UITestCase {
+ static Dimension frameSize;
+ static Dimension preferredGLSize;
+ static Dimension minGLSize;
+ static long durationPerTest = 800;
+
+ @BeforeClass
+ public static void initClass() {
+ frameSize = new Dimension(500,300);
+ preferredGLSize = new Dimension(400,200);
+ minGLSize = new Dimension(200,100);
+ }
+
+ private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException {
+
+ Container c = new Container();
+ c.setLayout(new BorderLayout());
+ c.add(new Button("north"), BorderLayout.NORTH);
+ c.add(new Button("south"), BorderLayout.SOUTH);
+ c.add(new Button("east"), BorderLayout.EAST);
+ c.add(new Button("west"), BorderLayout.WEST);
+ c.add(comp, BorderLayout.CENTER);
+
+ f.setLayout(new BorderLayout());
+ f.add(new Button("NORTH"), BorderLayout.NORTH);
+ f.add(new Button("SOUTH"), BorderLayout.SOUTH);
+ f.add(new Button("EAST"), BorderLayout.EAST);
+ f.add(new Button("WEST"), BorderLayout.WEST);
+ f.add(c, BorderLayout.CENTER);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ // f.pack();
+ f.validate();
+ f.setVisible(true);
+ }});
+ }
+ private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException {
+ actrl.stop();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f.dispose();
+ } } );
+ if(null != w) {
+ w.destroy();
+ }
+ }
+
+ // @Test
+ public void testOffscreenLayerPath0_GLCanvas() throws InterruptedException, InvocationTargetException {
+ final Frame frame1 = new Frame("AWT Parent Frame");
+
+ GLCapabilities glCaps = new GLCapabilities(null);
+ final GLCanvas glc = new GLCanvas(glCaps);
+ glc.setPreferredSize(preferredGLSize);
+ glc.setMinimumSize(minGLSize);
+
+ GLEventListener demo1 = new GearsES2(1);
+ glc.addGLEventListener(demo1);
+
+ frame1.setSize(frameSize);
+ setupFrameAndShow(frame1, glc);
+
+ GLAnimatorControl animator1 = new Animator(glc);
+ animator1.start();
+
+ Thread.sleep(durationPerTest);
+ end(animator1, frame1, null);
+ }
+
+ @Test
+ public void testOnscreenLayer() throws InterruptedException, InvocationTargetException {
+ testOffscreenLayerPath1_Impl(false, false);
+ }
+
+ @Test
+ public void testOffscreenLayerPath1_NewtOffscreen() throws InterruptedException, InvocationTargetException {
+ testOffscreenLayerPath1_Impl(true, true);
+ }
+
+ @Test
+ public void testOffscreenLayerPath1_NewtOnscreen() throws InterruptedException, InvocationTargetException {
+ testOffscreenLayerPath1_Impl(true, false);
+ }
+
+ private void testOffscreenLayerPath1_Impl(boolean offscreenLayer, boolean newtOffscreenClass) throws InterruptedException, InvocationTargetException {
+ final Frame frame1 = new Frame("AWT Parent Frame");
+
+ GLCapabilities glCaps = new GLCapabilities(null);
+ if(newtOffscreenClass) {
+ glCaps.setOnscreen(false);
+ glCaps.setPBuffer(true);
+ }
+
+ GLWindow glWindow1 = GLWindow.create(glCaps);
+
+ final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+ newtCanvasAWT1.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported
+ newtCanvasAWT1.setPreferredSize(preferredGLSize);
+ newtCanvasAWT1.setMinimumSize(minGLSize);
+
+ GLEventListener demo1 = new GearsES2(1);
+ setDemoFields(demo1, glWindow1, false);
+ glWindow1.addGLEventListener(demo1);
+ glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+
+ frame1.setSize(frameSize);
+ setupFrameAndShow(frame1, newtCanvasAWT1);
+ Assert.assertTrue(glWindow1.isNativeValid());
+ Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
+
+ GLAnimatorControl animator1 = new Animator(glWindow1);
+ animator1.start();
+
+ Thread.sleep(durationPerTest);
+ end(animator1, frame1, glWindow1);
+ }
+
+ // @Test
+ public void testOffscreenLayerPath2_NewtOffscreen() throws InterruptedException, InvocationTargetException {
+ testOffscreenLayerPath2_Impl(true);
+ }
+
+ private void testOffscreenLayerPath2_Impl(boolean newtOffscreenClass) throws InterruptedException, InvocationTargetException {
+ }
+
+ public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
+ Assert.assertNotNull(demo);
+ Assert.assertNotNull(glWindow);
+ Window window = glWindow.getDelegatedWindow();
+ if(debug) {
+ MiscUtils.setFieldIfExists(demo, "glDebug", true);
+ MiscUtils.setFieldIfExists(demo, "glTrace", true);
+ }
+ if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
+ MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
+ }
+ }
+
+ 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[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ durationPerTest = atoi(args[++i]);
+ }
+ }
+ String tstname = TestParentingOffscreenLayer01AWT.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" } ); */
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java
index be812e6aa..86a76f9ff 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java
@@ -157,7 +157,7 @@ public class TestTranslucentParentingAWT extends UITestCase {
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
Assert.assertNotNull(glWindow);
- Window window = glWindow.getWindow();
+ Window window = glWindow.getDelegatedWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
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 7df8645de..a27bdd7a2 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -67,7 +67,7 @@ public class AWTRobotUtil {
int x0, y0;
if(null!=comp) {
- java.awt.Point p0 = comp.getLocationOnScreen();
+ java.awt.Point p0 = comp.getLocationOnScreen();
java.awt.Rectangle r0 = comp.getBounds();
if( onTitleBarIfWindow && comp instanceof java.awt.Window) {
java.awt.Window window = (java.awt.Window) comp;
@@ -78,7 +78,7 @@ public class AWTRobotUtil {
}
x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ;
} else {
- javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
+ javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
if( onTitleBarIfWindow ) {
javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets();
p0.translate(win.getWidth()/2, insets.getTopHeight()/2);
@@ -102,6 +102,9 @@ public class AWTRobotUtil {
public static boolean toFront(Robot robot, final java.awt.Window window)
throws AWTException, InterruptedException, InvocationTargetException {
+ AWTWindowFocusAdapter winFA = new AWTWindowFocusAdapter("window");
+ window.addWindowFocusListener(winFA);
+
if(null == robot) {
robot = new Robot();
robot.setAutoWaitForIdle(true);
@@ -119,11 +122,11 @@ public class AWTRobotUtil {
}});
robot.delay(ROBOT_DELAY);
- KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
int wait;
- for (wait=0; wait<POLL_DIVIDER && window != kfm.getFocusedWindow(); wait++) {
+ for (wait=0; wait<POLL_DIVIDER && !winFA.focusGained(); wait++) {
Thread.sleep(TIME_SLICE);
}
+ window.removeWindowFocusListener(winFA);
return wait<POLL_DIVIDER;
}
@@ -280,8 +283,8 @@ public class AWTRobotUtil {
Assert.assertTrue("Did not gain focus", hasFocus);
}
- static int keyType(int i, Robot robot, int keyCode,
- Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException
+ public static int keyType(int i, Robot robot, int keyCode,
+ Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException
{
int tc = 0;
int j;
@@ -293,13 +296,13 @@ public class AWTRobotUtil {
if(DEBUG) { System.err.println(i+":"+j+" KC1.0: "+counter+" - regain focus"); }
requestFocus(null, obj);
}
- final int c0 = counter.getCount();
+ final int c0 = null!=counter ? counter.getCount() : 0;
if(DEBUG) { System.err.println(i+":"+j+" KC1.1: "+counter); }
robot.waitForIdle();
robot.keyPress(keyCode);
robot.keyRelease(keyCode);
if(DEBUG) { System.err.println(i+":"+j+" KC1.2: "+counter); }
- tc = counter.getCount() - c0;
+ tc = ( null!=counter ? counter.getCount() : 1 ) - c0;
for (int wait=0; wait<POLL_DIVIDER && 1 > tc; wait++) {
robot.delay(TIME_SLICE);
tc = counter.getCount() - c0;
@@ -355,13 +358,13 @@ public class AWTRobotUtil {
if(DEBUG) { System.err.println(i+":"+j+" MC1.0: "+counter+" - regain focus"); }
requestFocus(null, obj);
}
- final int c0 = counter.getCount();
+ final int c0 = null != counter ? counter.getCount() : 0;
if(DEBUG) { System.err.println(i+":"+j+" MC1.1: "+counter); }
robot.waitForIdle();
robot.mousePress(mouseButton);
robot.mouseRelease(mouseButton);
if(DEBUG) { System.err.println(i+":"+j+" MC1.2: "+counter); }
- tc = counter.getCount() - c0;
+ tc = ( null != counter ? counter.getCount() : 1 ) - c0;
for (int wait=0; wait<POLL_DIVIDER && 1 > tc; wait++) {
robot.delay(TIME_SLICE);
tc = counter.getCount() - c0;
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java
new file mode 100644
index 000000000..16aacd2fd
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2010 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.util;
+
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+
+public class AWTWindowFocusAdapter implements FocusEventCountAdapter, WindowFocusListener {
+
+ String prefix;
+ int focusCount;
+
+ public AWTWindowFocusAdapter(String prefix) {
+ this.prefix = prefix;
+ reset();
+ }
+
+ public boolean focusLost() {
+ return focusCount<0;
+ }
+
+ public boolean focusGained() {
+ return focusCount>0;
+ }
+
+ public void reset() {
+ focusCount = 0;
+ }
+
+ /* @Override */
+ public void windowGainedFocus(WindowEvent e) {
+ if(focusCount<0) { focusCount=0; }
+ focusCount++;
+ System.err.println("FOCUS AWT GAINED (Window) [fc "+focusCount+"]: "+prefix+", "+e);
+ }
+
+ /* @Override */
+ public void windowLostFocus(WindowEvent e) {
+ if(focusCount>0) { focusCount=0; }
+ focusCount--;
+ System.err.println("FOCUS AWT LOST (Window) [fc "+focusCount+"]: "+prefix+", "+e);
+ }
+
+ public String toString() { return prefix+"[focusCount "+focusCount +"]"; }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
index 6a6cf390f..c74d2eaa7 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
@@ -78,6 +78,7 @@ public class NEWTGLContext {
Assert.assertNotNull(drawable);
drawable.setRealized(true);
+ Assert.assertTrue(drawable.isRealized());
GLContext context = drawable.createContext(null);
Assert.assertNotNull(context);