Recording Events
Writing complex debug or unit-test scenarios might be a tedious task. However, it can be automated with the record events feature from AppCUI.
The first step is to enable this feature in Cargo.toml: add the EVENT_RECORDER feature to your default features, as in the following snippet.
[features]
default = ["EVENT_RECORDER"]
DEBUG_SHOW_WINDOW_TITLE_BOUNDERIES = []
EVENT_RECORDER = []
Once you do this, any program that uses AppCUI will enable a special hotkey Ctrl+Alt+Space that will allow you to open a special configuration window similar to the one from the next image:
You can use this window to perform the following actions:
- Add a new state (by typing its name and pressing
Enter)—this will effectively add newPaintandCheckHashcommands. - Enable automated mode (via the shortcut
F9). Enabling auto-record mode will effectively detect whenever the screen changes because of an action performed and automatically addPaintandCheckHashcommands. It will also filter out all other raw events (related to keystrokes and the mouse). - Clear all events recorded up to this moment (via the hotkey
F8).
The typical way of using this feature is as follows:
- Enable the feature from
Cargo.toml. - Run your application.
- If you prefer to do this manually, perform actions that change the state of the application, then press
Ctrl+Alt+Spaceand, in the configuration menu, type the name of the new state and pressEnter. - If you prefer automated mode, press
Ctrl+Alt+Spaceand enable automatic mode via theF9shortcut. - Once you finish your scenario, exit the application. At that point a file named
events.txtwill be written next to your application. You can use its content as part of a unit test or for debugging.