mirror of
https://github.com/barkeser2002/VMD-Motion-Optimizer.git
synced 2026-09-25 06:30:09 +03:00
.gitignore *.vmd dosyalarını engellediği için fixture'lar depoya konamıyor; tests/conftest.py spesifikasyona uygun VMD baytlarını çalışma anında üretiyor. Kapsam: kayıpsız gidiş-dönüş, interpolasyon eğrilerinin kare bazında korunması, kamera/gölge bloklarının hayatta kalması, VMD 1.0 başlığı, bozuk dosyanın hızlı reddi, çıktı==girdi reddi, atomik yazma, cp932 çevriyazısı, _moving_average uzunluğu, depth eğilim çıkarma, ground IK dışlama ve geri alma, morph sabit aralık sonu, normalize edilmemiş quaternionlar, RDP özyineleme derinliği, iptal ve GUI duman testleri.
82 lines
2.3 KiB
Python
82 lines
2.3 KiB
Python
# VMD Motion Optimizer by Barış Keser (barkeser2002)
|
||
# License: GNU General Public License v3.0 (GPL-3.0)
|
||
|
||
"""GUI duman testleri. Ekransız (offscreen) Qt platformu ile çalışır."""
|
||
|
||
import os
|
||
|
||
import pytest
|
||
|
||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||
|
||
pytest.importorskip("PyQt6")
|
||
|
||
from PyQt6 import QtWidgets # noqa: E402
|
||
|
||
import app as gui # noqa: E402
|
||
|
||
|
||
@pytest.fixture(scope="module")
|
||
def qapp():
|
||
inst = QtWidgets.QApplication.instance() or QtWidgets.QApplication([])
|
||
yield inst
|
||
|
||
|
||
def test_window_constructs(qapp):
|
||
w = gui.MainWindow()
|
||
assert w.windowTitle().startswith("VMD Motion Optimizer")
|
||
assert not w.cancel_btn.isEnabled()
|
||
assert w.start_btn.isEnabled()
|
||
w.close()
|
||
|
||
|
||
def test_running_state_toggles_buttons(qapp):
|
||
w = gui.MainWindow()
|
||
w._set_running(True)
|
||
assert not w.start_btn.isEnabled()
|
||
assert w.cancel_btn.isEnabled()
|
||
assert not w.in_btn.isEnabled()
|
||
w._set_running(False)
|
||
assert w.start_btn.isEnabled()
|
||
assert not w.cancel_btn.isEnabled()
|
||
w.close()
|
||
|
||
|
||
def test_profile_roundtrip_covers_all_fields(qapp):
|
||
w = gui.MainWindow()
|
||
settings = w._current_settings()
|
||
assert set(settings) == set(gui.PROFILE_FIELDS)
|
||
w.ground_check.setChecked(True)
|
||
w.depth_smooth.setValue(42)
|
||
saved = w._current_settings()
|
||
w._profiles["T"] = saved
|
||
w.ground_check.setChecked(False)
|
||
w.depth_smooth.setValue(1)
|
||
w.apply_profile("T")
|
||
assert w.ground_check.isChecked() is True
|
||
assert w.depth_smooth.value() == 42
|
||
w.close()
|
||
|
||
|
||
@pytest.mark.parametrize("bad", [
|
||
{"P": "aggressive"}, # dict yerine str -> v1.0.4'te abort()
|
||
{"P": {"pos_eps": "x"}}, # sayısal olmayan -> float() ValueError
|
||
["not", "a", "dict"], # dizi
|
||
{}, # boş
|
||
])
|
||
def test_sanitize_rejects_malformed_profiles(bad):
|
||
with pytest.raises(ValueError):
|
||
gui._sanitize_profiles(bad)
|
||
|
||
|
||
def test_sanitize_keeps_known_fields_only():
|
||
clean = gui._sanitize_profiles({"P": {"pos_eps": 0.1, "bilinmeyen": 5, "ground_check": True}})
|
||
assert clean == {"P": {"pos_eps": 0.1, "ground_check": True}}
|
||
|
||
|
||
def test_applying_malformed_profile_does_not_raise(qapp):
|
||
w = gui.MainWindow()
|
||
w._profiles["Bozuk"] = "aggressive" # tip hatası
|
||
w.apply_profile("Bozuk") # sessizce yok sayılmalı
|
||
w.close()
|