LensStudio:UiTest
ModuleModule 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
| Enumeration | Description |
|---|---|
| EventType | Enumeration of synthetic event types that can be dispatched to widgets via sendEvent. |
Classes
| Class | Description |
|---|---|
| Cursor | - |
Functions
| Function | Description |
|---|---|
| compareImages | - |
| createDiffImage | - |
| findChildren | Returns descendant widgets of the given widget whose class matches the specified class name. |
| findTopLevelWidgets | - |
| invoke | Invokes the named method on the target widget (such as the preview panel) and returns whether the call succeeded. |
| itemActivate | - |
| itemClick | Clicks the item at the given index path within a tree or list widget. |
| itemCollapse | Collapses the tree item at the given index path within the widget. |
| itemCount | Returns the number of child items under the given index path within a tree or list widget. |
| itemExpand | Expands the tree item at the given index path within the widget. |
| itemText | Returns the displayed text of the item at the given index path within a tree or list widget. |
| KeyEvent | Constructs a synthetic keyboard event of the given type, key, modifiers, and text for delivery via sendEvent. |
| mainWindow | Returns the top-level main window widget of the Lens Studio GUI. |
| MouseEvent | Constructs a synthetic mouse event of the given type, button, modifiers, and position for delivery via sendEvent. |
| processEvents | Pumps the Qt event loop for the specified number of milliseconds so pending UI updates are processed. |
| sendEvent | Dispatches a synthetic event to the target widget as if the user had triggered it. |