This adds the ability for Python to send events into the event queue (using RNA).
This is intended for writing interaction tests, which I've started doing for the undo system.
Basics:
- --enable-event-simulate enables events to be added via Window.event_simulate
- When G_DEBUG_EVENTS_SIMULATE is enabled, user keyboard and mouse events are ignored.
Useful so tests can be run without stray mouse events interfering.
This also keeps the feature *testing-only*, not something for developers to use for nasty hacks. - bpy.app.debug_events_simulate can only be disabled, never enabled.
Useful for checking the result of running a test.
- This patch includes some test scripts, they're not for review, just examples of how it can be used.
They need to be updated to validate the output is correct. Currently I'm just using them for bugs that crash Blender.
Open Topics:
- We could add events at different levels, eg: generate ghost events instead.
It would have some advantages since lower level events could be generated but it would be a bigger patch to interface Python w/ ghost, don't think it's worth the extra hassle. - Using keyboard/mouse events to test things isn't perfect because they break when shortcuts change. We could consider alternatives. OTOH, the tests end up being short making them quicker to update. There is also an advantage in being able to translate user steps into something that can be automated, w/o having to lookup API docs.
- We may eventually want to access other UI elements too, but would only consider this later on.