org.fest.swing.fixture
Interface KeyboardInputSimulationFixture

All Known Subinterfaces:
CommonComponentFixture
All Known Implementing Classes:
DialogFixture, FrameFixture, GenericComponentFixture, JButtonFixture, JCheckBoxFixture, JComboBoxFixture, JFileChooserFixture, JInternalFrameFixture, JLabelFixture, JListFixture, JMenuItemFixture, JOptionPaneFixture, JPanelFixture, JPopupMenuFixture, JRadioButtonFixture, JScrollBarFixture, JScrollPaneFixture, JSliderFixture, JSpinnerFixture, JSplitPaneFixture, JTabbedPaneFixture, JTableFixture, JTextComponentFixture, JToggleButtonFixture, JToolBarFixture, JTreeFixture, WindowFixture

public interface KeyboardInputSimulationFixture

Understands simulation of keyboard input on a GUI component.

Author:
Alex Ruiz

Method Summary
 KeyboardInputSimulationFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's GUI component.
 KeyboardInputSimulationFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's GUI component.
 KeyboardInputSimulationFixture pressKey(int keyCode)
          Simulates a user pressing given key on this fixture's GUI component.
 KeyboardInputSimulationFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's GUI component.
 

Method Detail

pressAndReleaseKeys

KeyboardInputSimulationFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's GUI component.

Parameters:
keyCodes - one or more codes of the keys to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given array of codes is null.
IllegalArgumentException - if any of the given code is not a valid key code.
IllegalStateException - if the component is disabled.
IllegalStateException - if the component is not showing on the screen.
See Also:
KeyEvent

pressKey

KeyboardInputSimulationFixture pressKey(int keyCode)
Simulates a user pressing given key on this fixture's GUI component.

Parameters:
keyCode - the code of the key to press.
Returns:
this fixture.
Throws:
IllegalArgumentException - if the given code is not a valid key code.
IllegalStateException - if the component is disabled.
IllegalStateException - if the component is not showing on the screen.
See Also:
KeyEvent

pressAndReleaseKey

KeyboardInputSimulationFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's GUI component. Modifiers is a mask from the available InputEvent masks.

The following code listing shows how to press 'CTRL' + 'C' in a platform-safe way:

 JTextComponentFixture textBox = dialog.textBox("username");
 textBox.selectAll()
        .pressAndReleaseKey(key(VK_C).modifiers(controlOrCommandMask()));
 

Parameters:
keyPressInfo - specifies the key and modifiers to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given KeyPressInfo is null.
IllegalArgumentException - if the given code is not a valid key code.
IllegalStateException - if the component is disabled.
IllegalStateException - if the component is not showing on the screen.

releaseKey

KeyboardInputSimulationFixture releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's GUI component.

Parameters:
keyCode - the code of the key to release.
Returns:
this fixture.
Throws:
IllegalArgumentException - if the given code is not a valid key code.
IllegalStateException - if the component is disabled.
IllegalStateException - if the component is not showing on the screen.
See Also:
KeyEvent


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.