abbot.tester
Class JComponentTester

java.lang.Object
  extended by abbot.tester.Robot
      extended by abbot.tester.ComponentTester
          extended by abbot.tester.ContainerTester
              extended by abbot.tester.JComponentTester
All Implemented Interfaces:
AWTConstants
Direct Known Subclasses:
AbstractButtonTester, JComboBoxTester, JFileChooserTester, JGraphTester, JInternalFrameTester, JLabelTester, JListTester, JPopupMenuTester, JRootPaneTester, JScrollBarTester, JSliderTester, JSpinnerTester, JSplitPaneTester, JTabbedPaneTester, JTableHeaderTester, JTableTester, JTextComponentTester, JToolBarTester, JTreeTester

public class JComponentTester
extends ContainerTester

Provides auto-scrolling prior to events for JComponent-derived classes.


Field Summary
 
Fields inherited from class abbot.tester.ComponentTester
IGNORED_METHODS
 
Fields inherited from class abbot.tester.Robot
componentDelay, defaultDelay, EM_AWT, EM_ROBOT, IDLE_TIMEOUT, MOUSELESS_MODIFIER, MOUSELESS_MODIFIER_MASK, popupDelay
 
Fields inherited from interface abbot.tester.AWTConstants
BUTTON_MASK, COPY_MASK, DRAG_THRESHOLD, LINK_MASK, MENU_SHORTCUT_KEYCODE, MENU_SHORTCUT_MASK, MENU_SHORTCUT_MODIFIER, MENU_SHORTCUT_STRING, MOVE_MASK, MULTI_CLICK_INTERVAL, POPUP_MASK, POPUP_MODIFIER, POPUP_ON_PRESS, TERTIARY_MASK, TERTIARY_MODIFIER
 
Constructor Summary
JComponentTester()
           
 
Method Summary
 void actionActionMap(Component comp, String name)
          Invoke an action from the component's action map.
 void actionClick(Component c, ComponentLocation loc, int buttons, int count)
          Scrolls to ensure the substructure is in view before clicking.
 void actionClick(Component c, ComponentLocation loc, String buttons, int count)
          Deprecated. Use actionClick(Component, ComponentLocation, int, int) instead.
 void actionDrag(Component c, ComponentLocation loc, int modifiers)
          Scrolls to ensure the substructure is in view before starting the drag.
 void actionDrag(Component c, ComponentLocation loc, String mods)
          Deprecated. Use actionDrag(Component, ComponentLocation, int) instead.
 void actionDrop(Component c, ComponentLocation loc)
          Scrolls to ensure the drop target substructure is in view before dropping (normally handled by autoscroll).
 void actionScrollToVisible(Component comp, ComponentLocation loc)
          Make sure the given point is visible.
 void actionScrollToVisible(Component comp, int x, int y)
          Make sure the given point is visible.
 void actionScrollToVisible(Component comp, int x, int y, int width, int height)
          Make sure the given rectangle is visible.
static String convertRendererToString(Component cr)
           
 String deriveTag(Component comp)
          Derive a tag for identifying this component.
static JComponentTester getTester(JComponent c)
          Return a shared instance of JComponentTester.
protected  boolean isVisible(JComponent c, int x, int y)
           
protected  boolean isVisible(JComponent c, Rectangle rect)
           
 void mousePress(Component comp, int x, int y, int buttons)
          Click in the given part of the component, scrolling the component if necessary to make the point visible.
protected  void scrollRectToVisible(JComponent jc, Rectangle rect)
          Invoke JComponent.scrollRectToVisible(Rectangle) on the given JComponent on the event dispatch thread.
protected  void scrollToVisible(Component comp, int x, int y)
          Scrolls the component so that the coordinate x and y are visible.
protected  void scrollToVisible(Component comp, Rectangle rect)
          Scrolls the component so that the given rectangle is visible.
 
Methods inherited from class abbot.tester.ComponentTester
actionClick, actionClick, actionClick, actionClick, actionClick, actionClick, actionDelay, actionDrag, actionDrag, actionDrag, actionDrag, actionDragOver, actionDragOver, actionDrop, actionDrop, actionFocus, actionKeyPress, actionKeyPress, actionKeyRelease, actionKeyRelease, actionKeyString, actionKeyString, actionKeyStroke, actionKeyStroke, actionKeyStroke, actionKeyStroke, actionMouseMove, actionMousePress, actionMousePress, actionMouseRelease, actionSelectAWTMenuItem, actionSelectAWTMenuItemByLabel, actionSelectAWTPopupMenuItem, actionSelectAWTPopupMenuItemByLabel, actionSelectMenuItem, actionSelectMenuItem, actionSelectPopupMenuItem, actionSelectPopupMenuItem, actionSelectPopupMenuItem, actionSetModifiers, actionShowPopupMenu, actionShowPopupMenu, actionShowPopupMenu, actionWaitForIdle, assertComponentShowing, assertFrameShowing, assertFrameShowing, assertImage, deriveAccessibleTag, getActions, getAssertMethods, getComponentActions, getComponentAssertMethods, getLocation, getPropertyMethods, getTag, getTestedClass, getTester, getTester, isCustom, isExtension, parseLocation, setTester, stripHTML, waitAction, waitForComponentShowing, waitForFrameShowing, waitForFrameShowing
 
Methods inherited from class abbot.tester.Robot
activate, canMoveWindows, canResizeWindows, capture, capture, capture, click, click, click, click, click, close, deiconify, delay, descriptiveClassName, drag, drag, dragOver, drop, findFocusOwner, fireAccessibleAction, focus, focus, getAutoDelay, getBorderTitle, getCanonicalClass, getCloseLocation, getDescriptiveName, getEventID, getEventID, getEventMode, getEventModeDescription, getEventPostDelay, getEventQueue, getIconifyLocation, getIconName, getIndex, getLabel, getMaximizeLocation, getMoveLocation, getName, getPreferredRobotAutoDelay, getResizeLocation, getRobot, getState, getText, getTitle, iconify, invokeAction, invokeAction, invokeAndWait, invokeAndWait, invokeLater, invokeLater, isReadyForInput, jitter, jitter, key, key, keyPress, keyRelease, keyString, keyStroke, maximize, mouseMove, mouseMove, mousePress, mousePress, mousePress, mousePress, mouseRelease, mouseRelease, move, moveBy, normalize, postEvent, postInvocationEvent, queueBlocked, reset, resize, resizeBy, sample, sample, sample, selectAWTMenuItem, selectAWTMenuItem, selectAWTMenuItemByLabel, selectAWTPopupMenuItem, selectAWTPopupMenuItem, selectAWTPopupMenuItemByLabel, selectMenuItem, selectMenuItem, selectPopupMenuItem, sendEvent, setAutoDelay, setEventMode, setEventPostDelay, setModifiers, showPopupMenu, showPopupMenu, simpleClassName, sleep, toHierarchyPath, toString, toString, toString, userMovable, userResizable, useScreenMenuBar, wait, wait, wait, waitForIdle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JComponentTester

public JComponentTester()
Method Detail

deriveTag

public String deriveTag(Component comp)
Derive a tag for identifying this component.

Overrides:
deriveTag in class ComponentTester

actionClick

public void actionClick(Component c,
                        ComponentLocation loc,
                        String buttons,
                        int count)
Deprecated. Use actionClick(Component, ComponentLocation, int, int) instead.

Scrolls to ensure the substructure is in view before clicking.


actionClick

public void actionClick(Component c,
                        ComponentLocation loc,
                        int buttons,
                        int count)
Scrolls to ensure the substructure is in view before clicking.

Overrides:
actionClick in class ComponentTester

actionDrag

public void actionDrag(Component c,
                       ComponentLocation loc,
                       String mods)
Deprecated. Use actionDrag(Component, ComponentLocation, int) instead.

Description copied from class: ComponentTester
Perform a drag action with the given modifiers.

Overrides:
actionDrag in class ComponentTester
Parameters:
c - source of the drag
loc - identifies where on the given Component to begin the drag.
mods - a String representation of key modifiers, e.g. "ALT|SHIFT", based on the InputEvent _MASK fields.

actionDrag

public void actionDrag(Component c,
                       ComponentLocation loc,
                       int modifiers)
Scrolls to ensure the substructure is in view before starting the drag.

Overrides:
actionDrag in class ComponentTester
Parameters:
c - source of the drag
loc - identifies where on the given Component to begin the drag.
modifiers - one or more of the InputEvent BUTTONN_MASK fields.

actionDrop

public void actionDrop(Component c,
                       ComponentLocation loc)
Scrolls to ensure the drop target substructure is in view before dropping (normally handled by autoscroll).

Overrides:
actionDrop in class ComponentTester

mousePress

public void mousePress(Component comp,
                       int x,
                       int y,
                       int buttons)
Click in the given part of the component, scrolling the component if necessary to make the point visible. Performing the scroll here obviates the need for all derived classes to remember to do it for actions involving clicks.

Overrides:
mousePress in class Robot

scrollToVisible

protected void scrollToVisible(Component comp,
                               int x,
                               int y)
Scrolls the component so that the coordinate x and y are visible. Has no effect if the component has no JViewport ancestor.

Parameters:
comp - the Component to scroll
x - the x coordinate to be visible
y - the y coordinate to be visible

scrollRectToVisible

protected void scrollRectToVisible(JComponent jc,
                                   Rectangle rect)
Invoke JComponent.scrollRectToVisible(Rectangle) on the given JComponent on the event dispatch thread.


isVisible

protected boolean isVisible(JComponent c,
                            Rectangle rect)

isVisible

protected boolean isVisible(JComponent c,
                            int x,
                            int y)

scrollToVisible

protected void scrollToVisible(Component comp,
                               Rectangle rect)
Scrolls the component so that the given rectangle is visible. Has no effect if the component has no JViewport ancestor. When this method returns, the requested rectangle's upper left corner will be visible (i.e. no Robot.waitForIdle() is required.

Parameters:
comp - the Component to scroll
rect - the Rectangle to make visible.

actionScrollToVisible

public void actionScrollToVisible(Component comp,
                                  ComponentLocation loc)
Make sure the given point is visible. Note that this may have no effect if the component is not actually in a scroll pane.


actionScrollToVisible

public void actionScrollToVisible(Component comp,
                                  int x,
                                  int y)
Make sure the given point is visible. Note that this may have no effect if the component is not actually in a scroll pane.


actionScrollToVisible

public void actionScrollToVisible(Component comp,
                                  int x,
                                  int y,
                                  int width,
                                  int height)
Make sure the given rectangle is visible. Note that this may have no effect if the component is not actually in a scroll pane.


actionActionMap

public void actionActionMap(Component comp,
                            String name)
Invoke an action from the component's action map.


getTester

public static JComponentTester getTester(JComponent c)
Return a shared instance of JComponentTester.


convertRendererToString

public static String convertRendererToString(Component cr)
Parameters:
cr - A custom cell renderer
Returns:
Either the name in the case or a label, or uses reflection to call "getText" which covers a range of other components and custom renderers


Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge