test_attitude_layout.py 1.0 KB

1234567891011121314151617181920212223242526
  1. import os
  2. import sys
  3. import unittest
  4. from pathlib import Path
  5. os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
  6. sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
  7. from PyQt6.QtWidgets import QApplication
  8. from app import Attitude
  9. app = QApplication.instance() or QApplication([])
  10. class AttitudeLayoutTest(unittest.TestCase):
  11. def test_readout_fits_and_does_not_overlap_sphere(self):
  12. widget = Attitude()
  13. for width, height in [(250, 220), (280, 280), (450, 600), (800, 220)]:
  14. widget.resize(width, height)
  15. cx, cy, radius, label = widget.layout_geometry()
  16. self.assertGreaterEqual(label.top() + cy, cy + radius)
  17. self.assertLessEqual(label.bottom() + cy, height)
  18. self.assertGreaterEqual(cx - radius, 0)
  19. self.assertLessEqual(cx + radius, width)
  20. widget.roll, widget.pitch, widget.yaw = .1, -.2, .3
  21. widget.show(); app.processEvents(); widget.grab()
  22. widget.close()
  23. if __name__ == '__main__': unittest.main()