public final class Test
extends Object
These functions mess with things pretty heavily; for one thing the mouse will be warped to a position somewhere within the Widget. Needless to say , the average user doesn't view it very kindly to have their pointer woosh off to another part of the screen. You therefore need to be using this where the display is actually some sort of virtual server, say Xvfb, and not with a live display.
Using sendKey()
and sendClick()
will inevitably
cause actions to occur that are not compatible with simultaneous human user
driven input. Obviously these are here to allow you to attempt to simulate
user actions, but if you need to click a button programmatically in a
normal application, call Button's emitClicked()
.
This is not a JUnit TestCase; using that, or any other test framework, is your problem.
Modifier and Type | Method and Description |
---|---|
static void |
sendClick(Widget widget,
MouseButton button,
ModifierType modifiers)
Send a mouse button click to a Widget.
|
static void |
sendKey(Widget widget,
Keyval keyval,
ModifierType modifiers)
Send a keystroke to a Widget.
|
public static void sendClick(Widget widget, MouseButton button, ModifierType modifiers)
IllegalStateException
- If sending the button click fails.public static void sendKey(Widget widget, Keyval keyval, ModifierType modifiers)
This should result in Widget.KeyPressEvent
and
Widget.KeyReleaseEvent
being emitted.
The Widget needs to be in a Window that is show()
n on
screen for the X server's event system to work and for the keystroke to
go anywhere. Which makes sense; you can't type in a minimized Window.
IllegalStateException
- If sending the keystroke fails.