summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-10 10:03:30 +0100
committerSven Gothel <[email protected]>2013-11-10 10:03:30 +0100
commit4d79797fecfb7bfc725dfea26573b15b9b365181 (patch)
treed6e92ff91d60f1fd45a061683705b7b3457ce844 /src/test/com/jogamp
parentf3ef5de2b2d183f44c0e8e2001aaf7b88dfa27a1 (diff)
Tests: Align NEWT parenting focus tests (package and class names) using NewtCanvasAWT
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java)46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java)68
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java)104
3 files changed, 112 insertions, 106 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java
index 5f3702340..29c3279aa 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,13 +20,13 @@
* 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;
+
+package com.jogamp.opengl.test.junit.newt.parenting;
import org.junit.Assert;
import org.junit.AfterClass;
@@ -55,20 +55,20 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
-
+import com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT;
import com.jogamp.opengl.test.junit.util.*;
/**
- * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
- * <p>
- * {@link JFrame} . {@link Container}+ . {@link NewtCanvasAWT} . {@link GLWindow}
+ * Testing focus <i>mouse-click</i> and <i>programmatic</i> traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
+ * <p>
+ * {@link JFrame} . {@link Container}+ [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ]
* </p>
* <p>
- * <i>+ Container is the JFrame's implicit root content pane</i><br/>
+ * <i>+ Container is the JFrame's implicit root content pane</i><br/>
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFocus01SwingAWTRobot extends UITestCase {
+public class TestParentingFocus01SwingAWTRobot extends UITestCase {
static int width, height;
static long durationPerTest = 10;
static long awtWaitTimeout = 1000;
@@ -119,7 +119,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
// Wrap the window in a canvas.
final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
// newtCanvasAWT.setShallUseOffscreenLayer(true);
-
+
// Monitor AWT focus and keyboard events.
AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT");
newtCanvasAWT.addKeyListener(newtCanvasAWTKA);
@@ -140,7 +140,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button");
button.addMouseListener(buttonMA);
eventCountAdapters.add(buttonMA);
-
+
frame1.getContentPane().add(button, BorderLayout.NORTH);
frame1.setSize(width, height);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -148,12 +148,12 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
frame1.setVisible(true);
} } );
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true));
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true));
AWTRobotUtil.clearAWTFocus(robot);
Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1));
Thread.sleep(durationPerTest); // manual testing
-
+
int wait=0;
while(wait<awtWaitTimeout/100 && glWindow1.getTotalFPSFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFPSFrames());
@@ -166,7 +166,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
// Button Focus
Thread.sleep(200); // allow event sync
-
+
System.err.println("FOCUS AWT Button request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, null); // OSX sporadically button did not gain - major UI failure
@@ -174,9 +174,9 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
System.err.println("FOCUS AWT Button sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, button, buttonKA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
button, buttonMA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
button, buttonMA);
// Request the AWT focus, which should automatically provide the NEWT window with focus.
@@ -186,7 +186,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA); // OSX sporadically button did not loose - minor UI failure
// Manually tested on Java7/[Linux,Windows] (where this assertion failed),
// Should be OK to have the AWT component assume it also has the focus.
- // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
+ // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
// AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA));
if( !AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA) ) {
System.err.println("Info: Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA);
@@ -212,7 +212,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
glWindow1.destroy();
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, false));
}
@@ -234,10 +234,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
/**
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
- System.err.println(stdin.readLine());
+ System.err.println(stdin.readLine());
*/
System.out.println("durationPerTest: "+durationPerTest);
- String tstname = TestFocus01SwingAWTRobot.class.getName();
+ String tstname = TestParentingFocus01SwingAWTRobot.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java
index 1c1ba9080..aa02e096b 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,13 +20,13 @@
* 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;
+
+package com.jogamp.opengl.test.junit.newt.parenting;
import java.lang.reflect.*;
@@ -59,16 +59,16 @@ import com.jogamp.opengl.test.junit.util.*;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
/**
- * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
- * <p>
- * {@link JFrame} . {@link JPanel}+ . {@link Container} . {@link NewtCanvasAWT} . {@link GLWindow}
+ * Testing focus <i>mouse-click</i> and <i>programmatic</i> traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
+ * <p>
+ * {@link JFrame} . {@link JPanel}+ . {@link Container} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ]
* </p>
* <p>
- * <i>+ JPanel is set as JFrame's root content pane</i><br/>
+ * <i>+ JPanel is set as JFrame's root content pane</i><br/>
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFocus02SwingAWTRobot extends UITestCase {
+public class TestParentingFocus02SwingAWTRobot extends UITestCase {
static int width, height;
static long durationPerTest = 10;
static long awtWaitTimeout = 1000;
@@ -96,8 +96,8 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
@AfterClass
public static void release() {
}
-
- private void testFocus01ProgrFocusImpl(Robot robot)
+
+ private void testFocus01ProgrFocusImpl(Robot robot)
throws AWTException, InterruptedException, InvocationTargetException {
ArrayList<EventCountAdapter> eventCountAdapters = new ArrayList<EventCountAdapter>();
@@ -169,7 +169,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
jFrame1.setVisible(true);
} } );
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(jFrame1, true));
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true));
AWTRobotUtil.clearAWTFocus(robot);
Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, jFrame1));
@@ -184,7 +184,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
animator1.start();
Thread.sleep(durationPerTest); // manual testing
-
+
// Button Outer Focus
Thread.sleep(100); // allow event sync
System.err.println("FOCUS AWT Button Outer request");
@@ -195,10 +195,10 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
System.err.println("FOCUS AWT Button Outer sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthOuter, buttonNorthOuterKA); // OSX sporadically won't receive the keyboard input - major UI failure
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ buttonNorthOuter, buttonNorthOuterMA);
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
buttonNorthOuter, buttonNorthOuterMA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
- buttonNorthOuter, buttonNorthOuterMA);
// NEWT Focus
Thread.sleep(100); // allow event sync
@@ -207,7 +207,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA);
// Manually tested on Java7/[Linux,Windows] (where this assertion failed),
// Should be OK to have the AWT component assume it also has the focus.
- // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
+ // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
// AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA));
if( !AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA) ) {
System.err.println("Info: Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA);
@@ -216,9 +216,9 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
System.err.println("FOCUS NEWT Canvas/GLWindow sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
glWindow1, glWindow1MA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
glWindow1, glWindow1MA);
Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
@@ -232,9 +232,9 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
System.err.println("FOCUS AWT Button sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthInner, buttonNorthInnerKA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
buttonNorthInner, buttonNorthInnerMA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
buttonNorthInner, buttonNorthInnerMA);
// NEWT Focus
@@ -244,19 +244,19 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA);
// Manually tested on Java7/[Linux,Windows] (where this assertion failed),
// Should be OK to have the AWT component assume it also has the focus.
- // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
+ // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
// AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA));
if( !AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA) ) {
System.err.println("Info: Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA);
}
-
+
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
System.err.println("FOCUS NEWT Canvas/GLWindow sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
glWindow1, glWindow1MA);
- AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
glWindow1, glWindow1MA);
Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
@@ -295,8 +295,8 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
}
@SuppressWarnings("unused")
- public static void main(String args[])
- throws IOException, AWTException, InterruptedException, InvocationTargetException
+ public static void main(String args[])
+ throws IOException, AWTException, InterruptedException, InvocationTargetException
{
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -304,14 +304,14 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
}
}
if(true) {
- String tstname = TestFocus02SwingAWTRobot.class.getName();
+ String tstname = TestParentingFocus02SwingAWTRobot.class.getName();
org.junit.runner.JUnitCore.main(tstname);
- } else {
- TestFocus02SwingAWTRobot.initClass();
- TestFocus02SwingAWTRobot test = new TestFocus02SwingAWTRobot();
+ } else {
+ TestParentingFocus02SwingAWTRobot.initClass();
+ TestParentingFocus02SwingAWTRobot test = new TestParentingFocus02SwingAWTRobot();
test.testFocus01ProgrFocus();
test.testFocus02RobotFocus();
- TestFocus02SwingAWTRobot.release();
+ TestParentingFocus02SwingAWTRobot.release();
}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java
index ff540408a..1e6cf4a1d 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,12 +20,12 @@
* 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.*;
@@ -64,8 +64,14 @@ import jogamp.newt.driver.DriverClearFocus;
import com.jogamp.opengl.test.junit.util.*;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+/**
+ * Testing focus <i>key</i> traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
+ * <p>
+ * {@link Frame} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ]
+ * </p>
+ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestParentingFocusTraversal01AWT extends UITestCase {
+public class TestParentingFocus03KeyTraversalAWT extends UITestCase {
static Dimension glSize, fSize;
static int numFocus = 8;
static long durationPerTest = numFocus * 200;
@@ -92,22 +98,22 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
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 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);
+ 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);
+ 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());
@@ -116,7 +122,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
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");
@@ -134,7 +140,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
cWest.addFocusListener(bWestFA);
AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST");
cEast.addFocusListener(bEastFA);
-
+
// Test KeyAdapter
NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1");
glWindow1.addKeyListener(glWindow1KA);
@@ -142,7 +148,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
cWest.addKeyListener(bWestKA);
AWTKeyAdapter bEastKA = new AWTKeyAdapter("East");
cEast.addKeyListener(bEastKA);
-
+
// demo ..
GLEventListener demo1 = new GearsES2(1);
setDemoFields(demo1, glWindow1, false);
@@ -152,32 +158,32 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
public void keyReleased(KeyEvent e) {
if( !e.isPrintableKey() || e.isAutoRepeat() ) {
return;
- }
- if(e.getKeyChar()=='c') {
+ }
+ if(e.getKeyChar()=='c') {
System.err.println("Focus Clear");
if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) {
((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus();
}
- } else if(e.getKeyChar()=='e') {
+ } 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') {
+ } 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();
@@ -193,7 +199,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
public void run() {
frame1.setLocation(0, 0);
frame1.setSize(fSize);
- frame1.validate();
+ frame1.validate();
frame1.setVisible(true);
}});
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true));
@@ -201,88 +207,88 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
AWTRobotUtil.clearAWTFocus(robot);
Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1));
-
+
Assert.assertEquals(true, animator1.isAnimating());
// Assert.assertEquals(false, animator1.isPaused());
Assert.assertNotNull(animator1.getThread());
-
+
if(manual) {
- Thread.sleep(durationPerTest);
+ Thread.sleep(durationPerTest);
} else {
//
// initial focus on bWest
- //
+ //
AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null);
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.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.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.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.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA));
Assert.assertEquals(true, bWestFA.focusGained());
Assert.assertEquals(true, glWindow1FA.focusLost());
- Thread.sleep(durationPerTest/numFocus);
-
+ Thread.sleep(durationPerTest/numFocus);
+
System.err.println("Test: Direct NewtCanvasAWT 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));
+ } 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);
-
+
System.err.println("Test: Direct AWT Button-West 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));
+ } 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);
-
+
System.err.println("Test: Direct NEWT-Child request focus");
glWindow1.requestFocus();
- Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA));
+ 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);
+ Thread.sleep(durationPerTest/numFocus);
}
-
+
animator1.stop();
Assert.assertEquals(false, animator1.isAnimating());
Assert.assertEquals(false, animator1.isPaused());
@@ -326,7 +332,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase {
forceGL3 = true;
}
}
- String tstname = TestParentingFocusTraversal01AWT.class.getName();
+ String tstname = TestParentingFocus03KeyTraversalAWT.class.getName();
/*
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
tstname,