java-gnome version 4.0.19

org.gnome.gtk
Class Test

Object
  extended by org.gnome.gtk.Test

public final class Test
extends Object

Support for testing GTK programs.

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.

Since:
unstable
Author:
Andrew Cowie

Method Summary
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.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sendClick

public static void sendClick(Widget widget,
                             MouseButton button,
                             ModifierType modifiers)
Send a mouse button click to a Widget.

Throws:
IllegalStateException - If sending the button click fails.
Since:
unstable

sendKey

public static void sendKey(Widget widget,
                           Keyval keyval,
                           ModifierType modifiers)
Send a keystroke to a Widget.

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.

Throws:
IllegalStateException - If sending the keystroke fails.
Since:
unstable


java-gnome