Fix: Multi-window UI tests can produce inconsistent results

After creating a new scene in a separate window when performing UI
tests, the respective view layer for the window may not be updated
immediately in the event loop.

Previously, this was mitigated with a single `yield` statement that
would delay processing by a single tick. To fix this issue, this commit
adds the capability to yield for a specific `timedelta` and waits this
amount of time for the two affected tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/136012
This commit is contained in:
Sean Kim
2025-04-02 21:38:05 +02:00
committed by Sean Kim
parent 5546fe9848
commit f1c87d1bd2
2 changed files with 12 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
"""
This file does not run anything, it's methods are accessed for tests by: ``run.py``.
"""
import datetime
# FIXME: Since 2.8 or so, there is a problem with simulated events
# where a popup needs the main-loop to cycle once before new events
@@ -653,7 +654,10 @@ def view3d_multi_mode_multi_window():
yield from _call_menu(e_b, "New Scene")
yield e_b.ret()
if _MENU_CONFIRM_HACK:
yield
# We wait for a brief period of time after confirming to ensure that each main window has a different view layer
yield datetime.timedelta(seconds=1 / 60)
t.assertNotEqual(window_a.view_layer, window_b.view_layer, "Windows should have different view layers")
for e in (e_a, e_b):
pos_v3d = _cursor_position_from_spacetype(e.window, 'VIEW_3D')
@@ -809,7 +813,10 @@ def view3d_edit_mode_multi_window():
yield from _call_menu(e_b, "New Scene")
yield e_b.ret()
if _MENU_CONFIRM_HACK:
yield
# We wait for a brief period of time after confirming to ensure that each main window has a different view layer
yield datetime.timedelta(seconds=1 / 60)
t.assertNotEqual(window_a.view_layer, window_b.view_layer, "Windows should have different view layers")
for e in (e_a, e_b):
pos_v3d = _cursor_position_from_spacetype(e.window, 'VIEW_3D')