[67:14] static extends: object
Provides GTK4 UI testing helpers for Aussom applications.
The gtktest module is the GTK counterpart to testfx. It targets one
GtkApplication or GtkWindow, walks the widget tree for selector-based
lookup, performs semantic user actions such as click, focus, and text entry,
pumps the GLib main loop, and exposes assertion helpers for common UI state.
The public API is intentionally small and test-oriented:
getGtkApi ()
Returns the generated
GtkApihelper.
A GtkApi object.getGLibApi ()
Returns the generated
GLibApihelper.
A GLibApi object.nowMillis ()
Returns the current system time in milliseconds.
An int with epoch milliseconds.setup (object AppObj)
Targets one GTK application or window for all subsequent test actions. When passed a
GtkApplication, setup waits briefly for the active window to become available and then uses it as the default lookup root.
AppObj is a GtkApplication, GtkWindow, GtkDialog, or GtkApplicationWindow.None.cleanup ()
Clears the current target application/window and recording state.
None.releaseRobotKeys ()
Releases any robot-held keys or buttons. Called from cleanup so a stray modifier from a failed test does not leak to the next test.
None.useRobot (bool Enabled)
Toggles the optional robot mode flag. The current implementation keeps semantic actions as the default path, even when robot mode is enabled.
Enabled is true to request robot mode.None.robotAvailable ()
Returns true when native robot input is available on the current backend. The probe caches its result. The v1 robot backend supports Linux with an X11 or XWayland display. Wayland-only and macOS / Windows backends report false so robot-only tests can gate cleanly.
A bool.probeRobot ()
Probes the environment to detect whether robot input is usable.
A map describing the probe result.x11KeycodeFromName (string Name)
Returns the X11 keycode for a keysym name such as "Return" or "a".
Name is the X11 keysym name.A keycode, or 0 when the lookup fails.lookup (string Query)
Returns the first widget matching the selector query, or null.
Query is a selector string using id, class, text, role, or type prefixes.A generated GTK wrapper object or null.lookupAll (string Query)
Returns all widgets matching the selector query.
Query is a selector string using id, class, text, role, or type prefixes.A list of generated GTK wrapper objects.exists (string Query)
Returns true when at least one widget matches the selector query.
Query is a selector string using id, class, text, role, or type prefixes.A bool.clickOn (string Query)
Clicks the matched widget using the semantic GTK path. For GtkButton the runtime emits the "clicked" signal through glib.signalEmitByName so any Aussom-side click handler fires exactly as it would for a real user click. Other widget types route through gtk_widget_activate, which covers GtkEntry activate-on-enter, GtkCheckButton toggle, and most action widgets.
Query is the selector string for the target widget.None.doubleClickOn (string Query)
Clicks the matched widget twice with a short pump between activations.
Query is the selector string for the target widget.None.rightClickOn (string Query)
Performs a secondary-button action on the matched widget. When robot mode is active this injects a real right-click through AWT Robot. Otherwise the semantic path looks for a GtkGestureClick controller on the widget with button 3 or 0 and emits its pressed and released signals. When no secondary gesture is attached and robot mode is unavailable the call throws.
Query is the selector string for the target widget.None.moveTo (string Query)
Moves the mouse cursor to the matched widget. In robot mode this injects a real AWT Robot mouse move. In semantic mode this is a no-op since GTK does not deliver synthetic motion without a real pointer.
Query is the selector string for the target widget.None.focus (string Query)
Grabs focus on the matched widget.
Query is the selector string for the target widget.None.write (string Text)
Writes text into the currently focused editable widget.
Text is the text to append.None.push (string KeyCombo)
Simulates one key combo on the focused widget. The v1 semantic implementation maps common test shortcuts directly to GTK editable operations and widget activation. Supported combos are:
ENTER,RETURN,ESCAPE,TAB,BACK_SPACE,DELETE,HOME,END,CONTROL+A,CONTROL+HOME,CONTROL+END. Unknown combos are no-ops.
KeyCombo is the combo string.None.requireEditableFocus (string MethodName)
Returns a fresh
Editablewrapper for the focused widget or throws when nothing editable has focus.
MethodName is used for error messages.An Editable wrapper.eraseText (int Count)
Removes characters from the end of the focused editable widget.
Count is the number of characters to remove.None.pump ()
Drains pending events from the default GLib main context.
None.pumpUntil (callback Predicate, int TimeoutMs = 5000)
Pumps the event loop until the predicate returns true or the timeout elapses.
Predicate is the callback checked after each pump cycle.TimeoutMs is the maximum wait in milliseconds.None.sleep (int Millis)
Waits for the provided duration while continuing to pump the GTK loop.
Millis is the duration in milliseconds.None.robotModeActive ()
Returns true when robot mode is currently active for an action. Robot mode is active when the caller has requested it through useRobot(true) and the current backend supports AWT Robot input.
A bool.widgetScreenCenter (object WidgetObj)
Computes the screen coordinates of the center of a widget. The math sums three parts: the widget center in widget coordinates, the widget origin relative to the native window obtained through gtk_widget_compute_point, and the native-window origin on screen obtained through XTranslateCoordinates. The native offset is scaled by the surface scale factor before the screen origin is added.
WidgetObj is the widget to locate.A map with x and y integer pixel coordinates.widgetToNativePoint (object Widget, object Target, double Cx, double Cy)
Wraps gtk_widget_compute_point to translate a widget-local point into coordinates relative to a target widget.
Widget is the source widget.Target is the reference widget.Cx is the widget-local x coordinate.Cy is the widget-local y coordinate.A map with x and y doubles in target coordinates.surfaceScreenPosition (object Surface)
Returns the screen origin of a GdkSurface. The v1 implementation uses X11 via gdk_x11_surface_get_xid and XTranslateCoordinates. Non-X11 backends throw because robotAvailable would have returned false for them already.
Surface is a GdkSurface wrapper.A map with x and y integer pixel coordinates.roundInt (double Value)
Rounds a double to a signed int using java.lang.Math.round.
Value is the value to round.An int.robotClick (object WidgetObj, int Button)
Injects a mouse click through the X11 XTest extension at the widget's screen center.
WidgetObj is the target widget.Button is the X11 button number (1=left, 2=middle, 3=right).None.robotMove (object WidgetObj)
Moves the robot cursor to the widget's screen center without pressing.
WidgetObj is the target widget.None.robotPushCombo (string KeyCombo)
Injects a key combo through the X11 XTest extension. Returns true when the combo is recognized and delivered.
KeyCombo is the combo string, upper-cased.A bool.x11KeyCodeForCombo (string Name)
Maps a combo key name to an X11 keycode via keysym lookup.
Name is the upper-cased key name.A keycode, or 0 when the name is unknown.x11ModifierKeyCode (string Name)
Maps a modifier name to an X11 keycode.
Name is the upper-cased modifier name.A keycode, or 0 when the name is unknown.findGestureClick (object WidgetObj, int Button)
Walks a widget's event controllers to find a GtkGestureClick whose button matches the target. Returns null when no matching gesture exists.
WidgetObj is the widget to inspect.Button is the button number (1=primary, 2=middle, 3=secondary, 0 matches any).A GtkGestureClick wrapper or null.emitGestureClick (object WidgetObj, object Gesture)
Emits pressed and released signals on a GtkGestureClick at the widget's local center.
WidgetObj is the widget owning the gesture.Gesture is the GtkGestureClick wrapper to drive.None.waitForDraw (object WidgetObj, int TimeoutMs = 2000)
Waits for the widget to complete a draw cycle. The v1 implementation used
gtk_test_widget_wait_for_draw, which blocks inside the GLib main loop until the widget's frame clock dispatches a draw. On Wayland and some XWayland compositor states that never happens for windows without focus, so the call hangs forever. This replacement iterates the main context with a bounded wall-clock deadline, exits as soon as the widget reports mapped with a non-zero allocation, and returns quietly when the deadline elapses. Callers that need a drawn widget (for examplecapture()) still checkget_allocated_width/heightthemselves and fail with a clear error, so a timeout does not silently produce a broken screenshot.
WidgetObj is the target widget.TimeoutMs is the maximum wall-clock wait in milliseconds.None.verifyExists (string Query)
Asserts that at least one widget matches the selector.
Query is the selector string.None.verifyNotExists (string Query)
Asserts that no widgets match the selector.
Query is the selector string.None.verifyVisible (string Query)
Asserts that the matched widget is visible and mapped.
Query is the selector string.None.verifyInvisible (string Query)
Asserts that the matched widget is not visible.
Query is the selector string.None.verifyEnabled (string Query)
Asserts that the matched widget is enabled.
Query is the selector string.None.verifyDisabled (string Query)
Asserts that the matched widget is disabled.
Query is the selector string.None.verifyHasText (string Query, string Text)
Asserts that the matched widget text equals the expected value.
Query is the selector string.Text is the expected text.None.verifyFocused (string Query)
Asserts that the matched widget currently has focus.
Query is the selector string.None.verifyAccessibleRole (string Query, Role)
Asserts that the matched widget reports the requested accessible role.
Query is the selector string.Role is the expected AccessibleRole enum value (a string like "button" or the equivalent AccessibleRole.button reference).None.verifyAccessibleProperty (string Query, Prop)
Asserts that the matched widget reports the requested accessible property.
Query is the selector string.Prop is the expected AccessibleProperty enum value (a string like "label" or the equivalent AccessibleProperty.label reference).None.capture (object WidgetObj, string Path)
Captures a PNG of the provided widget. The capture path wraps the widget in a
GtkWidgetPaintable, snapshots it at the widget's current allocated size, converts the resultingGskRenderNodeto aGdkTexturethrough the widget's native renderer, and writes the texture as a PNG.GtkWidgetPaintablecaches whatever the widget painted during its last frame-clock cycle. In test scenarios the compositor can take several frame intervals to deliver the first frame event, so the snapshot attempt is wrapped in a bounded retry loop that pumps the main loop between attempts until a populated render tree appears or a wall-clock deadline elapses.
WidgetObj is the widget to capture.Path is the output PNG path.The output path.captureWindow (object WindowObj, string Path)
Captures a PNG of the provided window.
WindowObj is the window or dialog to capture.Path is the output PNG path.The output path.captureScreen (string Path)
Captures the current target screen state. The v1 implementation captures the active target window, which covers the common single-window test case.
Path is the output PNG path.The output path.startRecording (string Dir, int Fps = 30)
Starts recording frame snapshots into the provided directory. Frames are captured opportunistically during
pump,sleep, and action calls, which keeps the implementation thread-safe and toolkit-aligned.
Dir is the output directory.Fps is the requested frame rate.None.stopRecording ()
Stops recording and optionally stitches the captured frames with ffmpeg.
The mp4 path when ffmpeg succeeds, otherwise the frame directory path.captureRecordingFrameIfDue ()
Captures one recording frame when the next frame deadline has been reached.
None.padFrame (int Number)
Returns one zero-padded frame number for recording output.
Number is the frame index.A string like 00001.targetAppHasWindow ()
Returns true when the targeted application has an active window.
A bool.ensureSetup (string MethodName)
Throws when the module has not been set up yet.
MethodName is the calling public method.None.requireWidget (string Query, string MethodName)
Returns the first matching widget, throwing a clear error when none exists.
Query is the selector string.MethodName is the calling public method.A Gtk.Widget wrapper.lookupWidget (string Query)
Returns the first raw
Gtk.Widgetmatch for the query.
Query is the selector string.A Gtk.Widget wrapper or null.lookupWidgetAll (string Query)
Returns all raw
Gtk.Widgetmatches for the query.
Query is the selector string.A list of Gtk.Widget wrappers.walk (object RootWidget)
Walks one widget subtree depth-first.
RootWidget is the subtree root.A list of Gtk.Widget wrappers.walkInto (object WidgetObj, list Out)
Recursively appends one widget subtree into the provided output list.
WidgetObj is the subtree root.Out is the result list.None.matchesToken (object WidgetObj, string Token)
Returns true when the widget matches the selector token.
WidgetObj is the widget to inspect.Token is the selector token.A bool.typeName (object Obj)
Returns the current native GObject type name for the wrapper.
Obj is a GTK wrapper object.A string like GtkButton.isEditableType (string TypeName)
Returns true when the native widget type is editable.
TypeName is the native GType name.A bool.getWidgetText (object WidgetObj)
Returns the user-facing text for a widget when a meaningful text accessor exists.
WidgetObj is the widget to inspect.A string or null.focusWidget (object WidgetObj)
Focuses one widget and throws clearly when the request fails.
WidgetObj is the widget to focus.None.getFocusedWindowWidget ()
Returns the widget GTK currently considers focused for the target window.
A Gtk.Widget wrapper or null.sameWidget (object Left, object Right)
Returns true when both wrapper objects refer to the same GTK widget.
Left is the first widget.Right is the second widget.A bool.findFocusedWidget ()
Returns the currently focused widget in the target subtree.
A Gtk.Widget wrapper or null.wrapWidget (object WidgetObj)
Wraps one raw widget handle in the most specific common generated wrapper used by the v1 tests.
WidgetObj is the widget to wrap.A generated GTK wrapper object.stripPrefix (string Text)
Removes the first selector prefix character.
Text is the selector token.A string without the first character.stripQuotes (string Text)
Removes the leading and trailing double quote from a text selector.
Text is the quoted selector token.An unquoted string.