Class PGUIRobotSlave

java.lang.Object
  |
  +--java.awt.Component
        |
        +--PGUIRobotSlave
All Implemented Interfaces:
java.awt.event.AWTEventListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PGUIRobotSlave
extends java.awt.Component
implements java.awt.event.AWTEventListener

PhOSCo GUI Test Robot


PGUI - PhOSCo GUI Testing
Copyright (C) 2000 Mike Calder-Smith, mike@gmot.demon.co.uk
Guillemot Design Ltd - www.PhOSCo.com

This program 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 of the License, or
(at your option) any later version.

This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


The PhOSCo GUI Test Robot is a very easy to use tool for testing the Graphical User Interface (GUI) behaviour of Java applications. It consists of two programs and one helper class:

For documentation, see the PGUI user documentation .

This is a very initial release with minimal testing, but does work. Please let the author know of any problems. Improvements and adaptations welcomed.

PhOSCo Graphical User Interface Tester Capture Tool

This code requires Java 1.3 to compile, and the availability of the com.sun.image.codec.jpeg extensions from the Sun JDK 1.3 or JRE.

This is the helper class for inclusion in instrumented applications that are to be tested using PGUIRobot. This classs traps AWTEvents and sends Datagrams describing them and user test commands to the PGUICapture tool.

See Also:
Serialized Form

Inner Class Summary
private  class PGUIRobotSlave.ListenToRobbie
          Class to listen for messages from Robot
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
 boolean beTold
          Robot Commmand flag
(package private)  byte[] bufPGUI
          PGUI Capture/Robot Instrumentation Datagram Packet Buffer
(package private) static java.lang.String copyr
          Copyright
(package private)  java.net.DatagramPacket dpcktPGUI
          PGUI Capture/Robot Instrumentation Datagram Packet
(package private)  java.net.DatagramSocket dsPGUI
          PGUI Capture/Robot Instrumentation Datagram Socket
 boolean goforit
          Activity flag
(package private)  int height
          Test Application Screen Window height
(package private)  int lastKeyEvent
          Last Key flag
(package private)  boolean listeningPGUI
          AWTEvent listening flag
protected static java.io.PrintStream log
          Log file
(package private)  PGUIRobotSlave.ListenToRobbie ltr
          Robot Listener Thread
(package private) static int NOTRELEASED
          Key Event Type
(package private)  boolean readyPGUI
          PGUI Capture/Robot Datagram Ready Flag
(package private) static int RELEASED
          Key Event Type
(package private)  java.awt.Dimension screenSize
          Screen Dimension
(package private)  int sox
          Test Application Screen Window top left x
(package private)  int soy
          Test Application Screen Window top left y
(package private)  javax.swing.JFrame upThere
          Parent Frame
(package private) static java.lang.String version
          Version
(package private)  int width
          Test Application Screen Window width
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dbg, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PGUIRobotSlave(javax.swing.JFrame parent)
          Constructor
 
Method Summary
private  void captureDialog(java.awt.AWTEvent trigger)
          Provide a user dialog which can be used to save areas of the screen, save files, run setup processes, and so on.
 void eventDispatched(java.awt.AWTEvent e)
          Inspect AWTEvent and send appropriate Datagram
private  java.lang.String getFileName(java.lang.String dlgHdr)
          Get a file name
private  int getKeyCode(java.lang.String dmsg)
          Get Keycode from Datagram message
 java.lang.String getRobbie()
          Listen for datagram from Robot
 void screenChange(javax.swing.JFrame parent)
           
 void sendPGUI(java.lang.String msg)
          Send Datagram Packet to PGUICapture.
 void trilby(java.lang.String cmd)
          Perform Robot command
private  java.lang.String writeJPEG(java.awt.image.BufferedImage bi)
          Save an Image in a JPEG file.
 
Methods inherited from class java.awt.Component
, action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, coalesceEvents, constructComponentName, contains, contains, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAccessibleContext, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, numListening, paint, paintAll, paintHeavyweightComponents, paramString, postEvent, postsOldMouseEvents, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

version

static java.lang.String version
Version

copyr

static java.lang.String copyr
Copyright

screenSize

java.awt.Dimension screenSize
Screen Dimension

dsPGUI

java.net.DatagramSocket dsPGUI
PGUI Capture/Robot Instrumentation Datagram Socket

bufPGUI

byte[] bufPGUI
PGUI Capture/Robot Instrumentation Datagram Packet Buffer

dpcktPGUI

java.net.DatagramPacket dpcktPGUI
PGUI Capture/Robot Instrumentation Datagram Packet

readyPGUI

boolean readyPGUI
PGUI Capture/Robot Datagram Ready Flag

listeningPGUI

boolean listeningPGUI
AWTEvent listening flag

upThere

javax.swing.JFrame upThere
Parent Frame

goforit

public boolean goforit
Activity flag

beTold

public boolean beTold
Robot Commmand flag

lastKeyEvent

int lastKeyEvent
Last Key flag

RELEASED

static final int RELEASED
Key Event Type

NOTRELEASED

static final int NOTRELEASED
Key Event Type

ltr

PGUIRobotSlave.ListenToRobbie ltr
Robot Listener Thread

sox

int sox
Test Application Screen Window top left x

soy

int soy
Test Application Screen Window top left y

width

int width
Test Application Screen Window width

height

int height
Test Application Screen Window height

log

protected static java.io.PrintStream log
Log file
Constructor Detail

PGUIRobotSlave

public PGUIRobotSlave(javax.swing.JFrame parent)
Constructor
Parameters:
JFrame - Parent Frame
Method Detail

eventDispatched

public void eventDispatched(java.awt.AWTEvent e)
Inspect AWTEvent and send appropriate Datagram
Specified by:
eventDispatched in interface java.awt.event.AWTEventListener
Parameters:
AWTEvent -  

getKeyCode

private int getKeyCode(java.lang.String dmsg)
Get Keycode from Datagram message
Parameters:
String - Datagram message
Returns:
int Keycode

sendPGUI

public void sendPGUI(java.lang.String msg)
Send Datagram Packet to PGUICapture.
Parameters:
String - Message to send in packet

captureDialog

private void captureDialog(java.awt.AWTEvent trigger)
Provide a user dialog which can be used to save areas of the screen, save files, run setup processes, and so on.
Parameters:
AWTEvent - Triggering event

writeJPEG

private java.lang.String writeJPEG(java.awt.image.BufferedImage bi)
Save an Image in a JPEG file.
Parameters:
BufferedImage - Image to be saved to JPEG file

getFileName

private java.lang.String getFileName(java.lang.String dlgHdr)
Get a file name
Parameters:
String - Dialog Title

screenChange

public void screenChange(javax.swing.JFrame parent)

getRobbie

public java.lang.String getRobbie()
Listen for datagram from Robot
Returns:
String Dtaagram message

trilby

public void trilby(java.lang.String cmd)
Perform Robot command
Parameters:
String - command