From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29907 invoked by alias); 30 Dec 2004 20:34:56 -0000 Mailing-List: contact mauve-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sources.redhat.com Received: (qmail 29836 invoked from network); 30 Dec 2004 20:34:44 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 30 Dec 2004 20:34:44 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iBUKYikt017943 for ; Thu, 30 Dec 2004 15:34:44 -0500 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iBUKYir06994 for ; Thu, 30 Dec 2004 15:34:44 -0500 Received: from localhost.localdomain (IDENT:U2FsdGVkX18udDKDTfAp+5NOcgpFROTDmi3qyse95Gc@tortoise.toronto.redhat.com [172.16.14.92]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id iBUKYfoS016644 for ; Thu, 30 Dec 2004 15:34:41 -0500 Subject: java.awt.Robot tests -- visual mauve tests revisited From: Thomas Fitzsimmons To: mauve-discuss@sources.redhat.com Content-Type: multipart/mixed; boundary="=-CDQzMOxKGFRbO5FdMwPo" Date: Thu, 30 Dec 2004 20:34:00 -0000 Message-Id: <1104438851.3365.29.camel@rh-ibm-t41> Mime-Version: 1.0 X-SW-Source: 2004-q4/txt/msg00069.txt.bz2 --=-CDQzMOxKGFRbO5FdMwPo Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 437 Hi, I've attached a series of tests for java.awt.Robot. I wrote a Robot implementation for GNU Classpath, so we can now start adding interactive GUI tests such as these to Mauve. I'm wondering how best to do this. There was a thread about this recently but I don't think we came to a decision. I know how I'd like GUI testing to work within libgcj's dejagnu harness, but I'm not sure how it should work in batch_run. Thoughts? Tom --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=constructors.java Content-Type: text/x-java; name=constructors.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1492 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.Robot; import java.awt.AWTException; /** * Checks that constructors in the {@link Robot} class work * correctly. */ public class constructors implements Testlet { /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { // default constructor try { Robot r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } // the test passed if we got here harness.check (true); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=createScreenCapture.java Content-Type: text/x-java; name=createScreenCapture.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2152 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.awt.AWTException; /** * Checks that createScreenCapture in the {@link Robot} class can * produce a screenshot. */ public class createScreenCapture implements Testlet { /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); Panel p = new Panel (); p.setBackground (new Color (255, 0, 0)); f.add (p); f.setSize (500, 500); f.setLocation (0, 0); f.show (); r.delay (1000); BufferedImage screenshot = r.createScreenCapture (new Rectangle (50, 50, 100, 100)); // check that captured image is completely red boolean passed = true; for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { Color c = new Color (screenshot.getRGB (i, j)); if (c.getRed () != 255 || c.getGreen () != 0 || c.getBlue () != 0) passed = false; } } harness.check (passed); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=getPixelColor.java Content-Type: text/x-java; name=getPixelColor.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1889 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that getPixelColor in the {@link Robot} class can read a * pixel's color value from the screen. */ public class getPixelColor implements Testlet { /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); Panel p = new Panel (); p.setBackground (new Color (255, 0, 0)); f.add (p); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.delay (100); Color c = r.getPixelColor (300, 300); r.delay (100); // check that pixel is red harness.check (c.getRed () == 255 && c.getGreen () == 0 && c.getBlue () == 0); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=keyPress.java Content-Type: text/x-java; name=keyPress.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2364 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that keyPress in the {@link Robot} class generates a * keyPressed event in a {@link TextField}. */ public class keyPress implements Testlet { char pressChar = '\0'; char releaseChar = '\0'; int pressCount = 0; int releaseCount = 0; /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); TextField tf = new TextField (); tf.addKeyListener (new KeyAdapter () { public void keyPressed (KeyEvent event) { pressChar = event.getKeyChar (); pressCount++; } public void keyReleased (KeyEvent event) { releaseChar = event.getKeyChar (); releaseCount++; } }); f.add (tf); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.setAutoDelay (100); // give focus to text field r.mouseMove (300, 300); r.mousePress (InputEvent.BUTTON1_MASK); r.mouseRelease (InputEvent.BUTTON1_MASK); // type 'a' r.keyPress (KeyEvent.VK_A); r.keyRelease (KeyEvent.VK_A); r.delay (2000); harness.check (pressChar == 'a'); harness.check (pressCount == 1); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=keyRelease.java Content-Type: text/x-java; name=keyRelease.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2224 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that keyRelease in the {@link Robot} class generates a * keyReleased event in a {@link TextField}. */ public class keyRelease implements Testlet { char releaseChar = '\0'; int releaseCount = 0; /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); TextField tf = new TextField (); tf.addKeyListener (new KeyAdapter () { public void keyReleased (KeyEvent event) { releaseChar = event.getKeyChar (); releaseCount++; } }); f.add (tf); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.setAutoDelay (100); // give focus to text field r.mouseMove (300, 300); r.mousePress (InputEvent.BUTTON1_MASK); r.mouseRelease (InputEvent.BUTTON1_MASK); // type 'a' r.keyPress (KeyEvent.VK_A); r.keyRelease (KeyEvent.VK_A); r.delay (2000); harness.check (releaseChar == 'a'); harness.check (releaseCount == 1); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=mouseMove.java Content-Type: text/x-java; name=mouseMove.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2107 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that mouseMove in the {@link Robot} class moves the mouse * pointer. */ public class mouseMove implements Testlet { int mouseX = 0; int mouseY = 0; /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); Button b = new Button ("test"); b.addMouseListener (new MouseAdapter () { public void mouseClicked (MouseEvent event) { mouseX = event.getX (); mouseY = event.getY (); } }); f.add (b); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.setAutoDelay (100); // click the button r.mouseMove (300, 300); r.mousePress (InputEvent.BUTTON1_MASK); r.mouseRelease (InputEvent.BUTTON1_MASK); r.delay (100); Insets i = f.getInsets (); harness.check (mouseX + i.left == 50 && mouseY + i.top == 50); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=mousePress.java Content-Type: text/x-java; name=mousePress.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2038 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that mousePress in the {@link Robot} class generates a * mousePressed event on a {@link Button}. */ public class mousePress implements Testlet { int mousePressCount = 0; /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); Button b = new Button ("test"); b.addMouseListener (new MouseAdapter () { public void mousePressed (MouseEvent event) { mousePressCount++; } }); f.add (b); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.setAutoDelay (100); // click the button r.mouseMove (300, 300); r.mousePress (InputEvent.BUTTON1_MASK); r.mouseRelease (InputEvent.BUTTON1_MASK); r.delay (100); harness.check (mousePressCount == 1); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=mouseRelease.java Content-Type: text/x-java; name=mouseRelease.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2050 // Tags: JDK1.3 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that mouseRelease in the {@link Robot} class generates a * mouseReleased event on a {@link Button}. */ public class mouseRelease implements Testlet { int mouseReleaseCount = 0; /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); Button b = new Button ("test"); b.addMouseListener (new MouseAdapter () { public void mouseReleased (MouseEvent event) { mouseReleaseCount++; } }); f.add (b); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.setAutoDelay (100); // click the button r.mouseMove (300, 300); r.mousePress (InputEvent.BUTTON1_MASK); r.mouseRelease (InputEvent.BUTTON1_MASK); r.delay (100); harness.check (mouseReleaseCount == 1); } } --=-CDQzMOxKGFRbO5FdMwPo Content-Disposition: attachment; filename=mouseWheel.java Content-Type: text/x-java; name=mouseWheel.java; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2354 // Tags: JDK1.4 // Copyright (C) 2004 Red Hat // This file is part of Mauve. // Mauve is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // Mauve is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Mauve; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. package gnu.testlet.java.awt.Robot; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import java.awt.*; import java.awt.event.*; import java.awt.AWTException; /** * Checks that mouseWheel in the {@link Robot} class generates a * {@link MouseWheelEvent} on a {@link Button}. */ public class mouseWheel implements Testlet { int mouseWheelUpCount = 0; int mouseWheelDownCount = 0; /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test (TestHarness harness) { Robot r = null; // construct robot try { r = new Robot (); } catch (AWTException e) { harness.fail ("caught AWT exception: " + e.getMessage ()); } Frame f = new Frame (); Button b = new Button ("test"); b.addMouseWheelListener (new MouseWheelListener () { public void mouseWheelMoved (MouseWheelEvent event) { int wheelRotation = event.getWheelRotation (); if (wheelRotation < 0) mouseWheelUpCount += wheelRotation; else mouseWheelDownCount += wheelRotation; } }); f.add (b); f.setSize (100, 100); f.setLocation (250, 250); f.show (); r.setAutoDelay (100); // scroll the mouse wheel up and down r.mouseMove (300, 300); r.mouseWheel (-4); r.mouseWheel (5); r.mouseWheel (-1); r.mouseWheel (3); r.mouseWheel (2); r.mouseWheel (-3); r.delay (100); harness.check (mouseWheelUpCount == -8); harness.check (mouseWheelDownCount == 10); } } --=-CDQzMOxKGFRbO5FdMwPo--