fixed label under 3d view
This commit is contained in:
@@ -9,20 +9,16 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
import ui_check
|
||||
from tests.conftest import visible_descendants
|
||||
from tests.conftest import (
|
||||
finish_run as _finish,
|
||||
running_window as _running_window,
|
||||
show_window as _show,
|
||||
visible_descendants,
|
||||
)
|
||||
|
||||
RESOLUTIONS = ((1280, 720), (1600, 900), (1920, 1080))
|
||||
|
||||
|
||||
def _show(window, size):
|
||||
window.resize(*size)
|
||||
window.show()
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
QApplication.processEvents()
|
||||
return window
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("theme", "sensor_type"), [
|
||||
("dark", "box"),
|
||||
("light", "box"),
|
||||
@@ -211,8 +207,9 @@ def test_toolbar_run_button_is_labelled(make_window):
|
||||
assert window.toolbar.btn_run.text() != label
|
||||
|
||||
|
||||
def test_stop_cancels_a_hung_connect(make_window):
|
||||
"""Stop must stay live and take effect instantly while connecting."""
|
||||
@pytest.mark.parametrize("cancel_via", ("toolbar", "escape"))
|
||||
def test_a_hung_connect_can_be_cancelled_immediately(make_window, cancel_via):
|
||||
"""Both cancellation paths stay responsive while a device is connecting."""
|
||||
import time
|
||||
|
||||
import ui_check
|
||||
@@ -226,35 +223,24 @@ def test_stop_cancels_a_hung_connect(make_window):
|
||||
|
||||
window.toolbar.btn_run.setChecked(True)
|
||||
assert window._session_phase == "connecting"
|
||||
assert window.toolbar.btn_run.isEnabled(), "Stop is disabled while connecting"
|
||||
assert window.toolbar.btn_run.text() == t("toolbar.cancel_label")
|
||||
assert window.act_stop.isEnabled()
|
||||
try:
|
||||
if cancel_via == "toolbar":
|
||||
assert window.toolbar.btn_run.isEnabled(), "Stop is disabled while connecting"
|
||||
assert window.toolbar.btn_run.text() == t("toolbar.cancel_label")
|
||||
assert window.act_stop.isEnabled()
|
||||
cancel = lambda: window.toolbar.btn_run.setChecked(False)
|
||||
else:
|
||||
assert window.act_stop.shortcut().toString() == "Esc"
|
||||
cancel = window._on_stop_shortcut
|
||||
|
||||
started = time.perf_counter()
|
||||
window.toolbar.btn_run.setChecked(False)
|
||||
elapsed = time.perf_counter() - started
|
||||
assert elapsed < 0.5, f"Stop blocked the GUI for {elapsed:.2f}s"
|
||||
assert not window._running
|
||||
assert stuck.thread_still_owned, "Stop abandoned the still-running worker thread"
|
||||
|
||||
|
||||
def test_escape_cancels_a_hung_connect(make_window):
|
||||
import time
|
||||
|
||||
import ui_check
|
||||
|
||||
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.toolbar.btn_run.setChecked(True)
|
||||
assert window.act_stop.shortcut().toString() == "Esc"
|
||||
started = time.perf_counter()
|
||||
window._on_stop_shortcut()
|
||||
assert time.perf_counter() - started < 0.5
|
||||
assert not window._running
|
||||
started = time.perf_counter()
|
||||
cancel()
|
||||
elapsed = time.perf_counter() - started
|
||||
assert elapsed < 0.5, f"{cancel_via} cancellation blocked for {elapsed:.2f}s"
|
||||
assert not window._running
|
||||
assert stuck.thread_still_owned, "Stop abandoned the still-running worker thread"
|
||||
finally:
|
||||
stuck.release()
|
||||
|
||||
|
||||
def test_theme_switch_updates_panels(make_window):
|
||||
@@ -581,31 +567,6 @@ def test_force_plots_render_demo_data(make_window):
|
||||
|
||||
|
||||
# --------------------------------------------------------------- record channel
|
||||
|
||||
|
||||
def _running_window(make_window):
|
||||
"""A window in the ``running`` phase whose worker never opens a device.
|
||||
|
||||
The Qt timer is stopped deliberately: these tests drive the display path by
|
||||
calling ``_on_run_tick`` themselves, and a concurrent 16 ms timer would race
|
||||
the assertions (and outlive the window on teardown).
|
||||
"""
|
||||
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()
|
||||
window._set_phase("running")
|
||||
return window, stuck
|
||||
|
||||
|
||||
def _finish(window, stuck):
|
||||
window._stop_run(reason="user_stop")
|
||||
stuck.release()
|
||||
|
||||
|
||||
def test_record_channel_does_not_depend_on_the_ui_timer(make_window):
|
||||
window, stuck = _running_window(make_window)
|
||||
for index in range(90):
|
||||
@@ -965,48 +926,6 @@ def test_depth_view_reports_missing_data_and_fixes_its_scale(make_window):
|
||||
|
||||
|
||||
# ------------------------------------------------------------- experiment record
|
||||
|
||||
#: Recording scratch goes under the app's gitignored ``outputs`` tree rather than
|
||||
#: the system temp directory, so the tests also run under a file sandbox that
|
||||
#: only permits writes inside the workspace.
|
||||
RECORD_SCRATCH = Path(__file__).resolve().parents[1] / "outputs" / "_test_record"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def record_root():
|
||||
import shutil
|
||||
|
||||
shutil.rmtree(RECORD_SCRATCH, ignore_errors=True)
|
||||
RECORD_SCRATCH.mkdir(parents=True, exist_ok=True)
|
||||
yield RECORD_SCRATCH
|
||||
shutil.rmtree(RECORD_SCRATCH, ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def replay_recording(record_root):
|
||||
"""One short finished recording (video + forces + frames + session.json)."""
|
||||
from orisys_app_shared.record import ExperimentRecorder, RecordConfig
|
||||
|
||||
recorder = ExperimentRecorder(RecordConfig(video=True, fps=30.0, segment_seconds=30.0))
|
||||
recording = recorder.start(
|
||||
root=record_root,
|
||||
session_id=1,
|
||||
metadata={
|
||||
"device": {
|
||||
"sensor_type": "box",
|
||||
"config_ref": str(record_root / "sensor.json"),
|
||||
"config_sha256": "recorded",
|
||||
},
|
||||
"versions": {"sdk": "0.5.1"},
|
||||
"depth": {"stored": False, "replay": "recompute"},
|
||||
},
|
||||
)
|
||||
for index in range(60):
|
||||
recorder.on_packet(ui_check._fake_packet(index))
|
||||
recorder.stop()
|
||||
yield Path(recording)
|
||||
|
||||
|
||||
def test_recording_writes_the_documented_experiment_layout(make_window, record_root):
|
||||
import csv
|
||||
import json
|
||||
|
||||
Reference in New Issue
Block a user