class Opal::Testing::Pilot

Overview

Python Textual-inspired Pilot test harness. Programmatically simulates user interactions (keystrokes, mouse gestures, resize events) against interactive TUI applications, screen hierarchies, and control engines.

Defined in:

opal/testing/pilot.cr

Constructors

Instance Method Summary

Constructor Detail

def self.for(engine : UI::Engine, driver : Terminal::MockDriver = Terminal::MockDriver.new(80, 24)) : self #

Factory method to create a Pilot for an Engine


[View source]
def self.for(screen : UI::Screen, driver : Terminal::MockDriver = Terminal::MockDriver.new(80, 24)) : self #

Factory method to create a Pilot for a Screen or ScreenStack


[View source]
def self.for(stack : UI::ScreenStack, driver : Terminal::MockDriver = Terminal::MockDriver.new(80, 24)) : self #

Factory method to create a Pilot for a ScreenStack


[View source]
def self.for(prog : TEA::Program, driver : Terminal::MockDriver) : self #

Factory method to create a Pilot for a TEA Program


[View source]
def self.new(driver : Terminal::MockDriver = Terminal::MockDriver.new(80, 24), engine : UI::Engine | Nil = nil, screen_stack : UI::ScreenStack | Nil = nil, program : TEA::Program | Nil = nil) #

[View source]

Instance Method Detail

def click(x : Int32, y : Int32, button : Terminal::MouseButton = Terminal::MouseButton::Left) : self #

Simulates a mouse click at the given terminal coordinates.


[View source]
def click(control : UI::Control) : self #

Simulates clicking on a managed UI control.


[View source]
def driver : Terminal::MockDriver #

[View source]
def engine : UI::Engine | Nil #

[View source]
def engine=(engine : UI::Engine | Nil) #

[View source]
def hover(x : Int32, y : Int32) : self #

Simulates mouse hover over the given terminal coordinates.


[View source]
def pause(duration : Time::Span = 5.milliseconds) : self #

Yields execution to let pending background fibers, timers, or animations settle.


[View source]
def press(*keys : String) : self #

Simulates pressing one or more keys in sequential order. Automatically resolves special key representations ("tab", "shift+tab", "enter", "esc", "ctrl+c", etc.).


[View source]
def program : TEA::Program | Nil #

[View source]
def program=(program : TEA::Program | Nil) #

[View source]
def resize_terminal(width : Int32, height : Int32) : self #

Resizes the mock terminal and dispatches resize events.


[View source]
def screen_stack : UI::ScreenStack | Nil #

[View source]
def screen_stack=(screen_stack : UI::ScreenStack | Nil) #

[View source]
def scroll_down(x : Int32 = 0, y : Int32 = 0) : self #

[View source]
def scroll_up(x : Int32 = 0, y : Int32 = 0) : self #

Simulates mouse scroll wheel movements.


[View source]
def type(text : String) : self #

Types a string character-by-character as synthetic key events.


[View source]
def wait_for(timeout : Time::Span = 1.second, interval : Time::Span = 5.milliseconds, message : String = "Condition timed out waiting for Pilot assertion", &block : -> Bool) : self #

Waits until the condition block evaluates to true, raising TimeoutError if duration exceeded.


[View source]
def wait_for_idle : self #

Drains any pending event queue in the mock driver.


[View source]