fix Studio reset, 3D base colour and arrow-trigger defects
The tracker reset was decided by which panel was on screen rather than by the session, the automatic colour range moved the 3D surface's base colour on the first press, and the 2D canvas and the 3D overlay applied different flow thresholds (622 arrows against 432 on a real recording). ui_check 600/0; apps/studio 380 items and shared 390 items with no failures; real-GL 18 items, only the pre-existing colour-scale failure; AutoCal 358 passed; both views now select identical arrows on all 42 frames of a real video.
This commit is contained in:
@@ -2142,6 +2142,89 @@ def test_the_live_view_keeps_the_tracker_reset(make_window):
|
||||
window.close()
|
||||
|
||||
|
||||
def test_the_tracker_reset_follows_the_session_across_a_view_switch(make_window):
|
||||
"""Zeroing the tracker is a *device* action: which panel is on screen is not a fact
|
||||
about the session, so switching live → calibration → live must not take the reset
|
||||
away from a session that is still running.
|
||||
|
||||
The reported defect: with a session running, opening the 标定 view left the button
|
||||
unavailable, and coming back to 实时 did not restore it — the session was unchanged
|
||||
throughout. The state asserted at every step is the session's, so the test fails if
|
||||
the view switch is what drives the control rather than the session.
|
||||
"""
|
||||
from orisys_app_shared.i18n import t
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
window = _show(make_window(sensor_type="box", source_mode="camera"), (1440, 880))
|
||||
stuck = ui_check._StuckWorker()
|
||||
window._ensure_workers = lambda: None
|
||||
window._box_worker = stuck
|
||||
window._finger_worker = stuck
|
||||
window._start_run()
|
||||
window._run_timer.stop()
|
||||
try:
|
||||
# A first frame is what makes the session a *running* one: the phase, and with it
|
||||
# the device controls, key off it (see the rail's own rule).
|
||||
stuck.emit(ui_check._fake_packet(1))
|
||||
window._on_run_tick()
|
||||
assert window._session_phase == "running", window._session_phase
|
||||
assert window.toolbar.btn_reset.isEnabled() and window.act_reset.isEnabled(), (
|
||||
"a running session must offer the tracker reset before any view switch"
|
||||
)
|
||||
assert window.toolbar.btn_reset.text() == t("toolbar.reset")
|
||||
|
||||
window.brand_bar.btn_calibration.click()
|
||||
QApplication.processEvents()
|
||||
assert window.layout_ctl.view_preset == "calibration"
|
||||
assert window.toolbar.btn_reset.isEnabled() and window.act_reset.isEnabled(), (
|
||||
"the session still runs in the calibration view: the reset went unavailable"
|
||||
)
|
||||
|
||||
window.brand_bar.btn_live.click()
|
||||
QApplication.processEvents()
|
||||
assert window.layout_ctl.view_preset == "live"
|
||||
assert window.toolbar.btn_reset.isEnabled() and window.act_reset.isEnabled(), (
|
||||
"the return to the live view did not restore the session's reset"
|
||||
)
|
||||
finally:
|
||||
window._stop_run(reason="user_stop")
|
||||
stuck.release()
|
||||
|
||||
|
||||
def test_the_two_figures_are_drawn_from_one_arrow_policy(make_window, monkeypatch):
|
||||
"""The 2D canvas and the 3D surface must sample the same policy.
|
||||
|
||||
The pane owns the arrow thresholds (they are display settings and are persisted),
|
||||
so the 2D renderer is handed a policy built from that same object rather than
|
||||
inventing its own. A canvas that picks its own threshold is how the two figures
|
||||
ended up drawing a different number of arrows for one frame (measured: 432 against
|
||||
622 on a real recording, differing on 34 of 41 frames).
|
||||
"""
|
||||
import orisys_studio.app_window as app_window
|
||||
from orisys_app_shared.acquisition.image_backend import ImageFrame
|
||||
from orisys_app_shared.scene3d.visual_policy import policy_for_settings
|
||||
|
||||
seen: dict = {}
|
||||
|
||||
def spy(frame, plan=None, **kwargs):
|
||||
seen.update(kwargs)
|
||||
return None # the panel is not the subject here
|
||||
|
||||
monkeypatch.setattr(app_window, "render_image", spy)
|
||||
window = _show(make_window(sensor_type="finger"), (1440, 880))
|
||||
expected = policy_for_settings(window.mesh3d_panel.display_settings())
|
||||
assert window._arrow_policy() == expected
|
||||
|
||||
flow = np.zeros((12, 16, 2), dtype=np.float32)
|
||||
window._show_image_frame(
|
||||
ImageFrame(np.zeros((12, 16, 3), np.uint8), flow=flow, flow_valid=True)
|
||||
)
|
||||
assert seen.get("arrow_policy") == expected, (
|
||||
"the 2D canvas was not drawn with the pane's arrow policy"
|
||||
)
|
||||
window.close()
|
||||
|
||||
|
||||
def test_a_bare_video_plays_even_though_it_is_not_a_recording(make_window, record_root):
|
||||
"""A clip with no forces.csv beside it is still something to watch.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user