Skip to main content

LensStudio:UiTest

Module

Module providing synthetic input and widget inspection utilities for driving the Lens Studio UI in integration tests.

Example

// LensStudio:UiTest creates synthetic key/mouse events and dispatches them
// to widgets — used to drive automated UI smoke tests.
const UiTest = await import('LensStudio:UiTest');
const { Key, KeyboardModifier, IGui } = await import('LensStudio:Ui');

const gui = this.pluginSystem.findInterface(IGui) as IGui;
if (Editor.isNull(gui)) {
console.log('IGui unavailable; UiTest needs a running UI');
return;
}
const window = UiTest.mainWindow(gui);
const event = UiTest.KeyEvent(UiTest.EventType.KeyPress, Key.Key_A, KeyboardModifier.NoModifier, 'a');
UiTest.sendEvent(window, event);
UiTest.processEvents(100);
console.log(`Sent KeyPress 'a' to main window (${UiTest.findChildren(window, 'Label').length} labels)`);

Enumerations

EnumerationDescription
EventTypeEnumeration of synthetic event types that can be dispatched to widgets via sendEvent.

Classes

ClassDescription
Cursor-

Functions

FunctionDescription
compareImages-
createDiffImage-
findChildrenReturns descendant widgets of the given widget whose class matches the specified class name.
findTopLevelWidgets-
invokeInvokes the named method on the target widget (such as the preview panel) and returns whether the call succeeded.
itemActivate-
itemClickClicks the item at the given index path within a tree or list widget.
itemCollapseCollapses the tree item at the given index path within the widget.
itemCountReturns the number of child items under the given index path within a tree or list widget.
itemExpandExpands the tree item at the given index path within the widget.
itemTextReturns the displayed text of the item at the given index path within a tree or list widget.
KeyEventConstructs a synthetic keyboard event of the given type, key, modifiers, and text for delivery via sendEvent.
mainWindowReturns the top-level main window widget of the Lens Studio GUI.
MouseEventConstructs a synthetic mouse event of the given type, button, modifiers, and position for delivery via sendEvent.
processEventsPumps the Qt event loop for the specified number of milliseconds so pending UI updates are processed.
sendEventDispatches a synthetic event to the target widget as if the user had triggered it.