From e5f0ee1e8969b9259f31b88f9ddd7165ab8ca5ae Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 26 Feb 2011 22:43:10 +0100 Subject: Attempt to analyze failed AWT UI tests, where no paint is being issued to GLCanvas. --- .../classes/javax/media/opengl/awt/GLCanvas.java | 17 ++++++++++++--- .../jogamp/nativewindow/jawt/JAWTWindow.java | 3 ++- .../junit/jogl/acore/TestSharedContextListAWT.java | 6 ++---- .../opengl/test/junit/util/AWTRobotUtil.java | 24 +++++++++++++++------- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 78038500e..086a17362 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -380,6 +380,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void display() { if( !validateGLDrawable() ) { + if(DEBUG) { + System.err.println("Info: GLCanvas display - skipped GL render, drawable not valid yet"); + } return; // not yet available .. } maybeDoSingleThreadedWorkaround(displayOnEventDispatchThreadAction, @@ -740,11 +743,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - @Override + @Override public String toString() { - return "AWT-GLCanvas[ "+awtConfig+", "+((null!=drawable)?drawable.getClass().getName():"null-drawable")+"]"; + return "AWT-GLCanvas[Realized "+isRealized()+ + ",\n\t"+((null!=drawable)?drawable.getClass().getName():"null-drawable")+ + ",\n\tRealized "+isRealized()+ + ",\n\tFactory "+getFactory()+ + ",\n\thandle 0x"+Long.toHexString(getHandle())+ + ",\n\tDrawable size "+drawable.getWidth()+"x"+drawable.getHeight()+ + ",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + ",\n\tvisible "+isVisible()+ + ",\n\t"+awtConfig+"]"; } - + //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java index 61be51b8a..67f6fe4b8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java @@ -257,8 +257,9 @@ public abstract class JAWTWindow implements NativeWindow { } protected abstract Point getLocationOnScreenImpl(int x, int y); + @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("JAWT-Window["+ "windowHandle 0x"+Long.toHexString(getWindowHandle())+ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java index 9e0bebc9c..63f54e267 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java @@ -98,12 +98,10 @@ public class TestSharedContextListAWT extends UITestCase { SwingUtilities.invokeLater(new Runnable() { public void run() { frame.add(glCanvas); - frame.pack(); - frame.setSize(width, height); frame.setLocation(x, y); - frame.invalidate(); + frame.setSize(width, height); + frame.pack(); frame.setVisible(true); - frame.validate(); } }); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, 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 40c1e0528..bbd53db9b 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -45,7 +45,7 @@ import javax.swing.JFrame; public class AWTRobotUtil { - public static int TIME_OUT = 2000; // 2s + public static int TIME_OUT = 1000; // 1s public static int ROBOT_DELAY = 50; // ms public static int POLL_DIVIDER = 20; // TO/20 @@ -354,16 +354,26 @@ public class AWTRobotUtil { */ public static boolean waitForRealized(Object obj, boolean realized) throws InterruptedException { int wait; - if(obj instanceof GLCanvas) { - GLCanvas comp = (GLCanvas) obj; - for (wait=0; wait drawable.setRealized(true); + if(wait=POLL_DIVIDER) { + // for some reason GLCanvas hasn't been painted yet, force it! + System.err.println("XXX: FORCE REPAINT - canvas: "+glcanvas); + glcanvas.repaint(); + for (wait=0; wait