| 1234567891011121314151617181920212223242526 |
- import os
- import sys
- import unittest
- from pathlib import Path
- os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
- sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
- from PyQt6.QtWidgets import QApplication
- from app import Attitude
- app = QApplication.instance() or QApplication([])
- class AttitudeLayoutTest(unittest.TestCase):
- def test_readout_fits_and_does_not_overlap_sphere(self):
- widget = Attitude()
- for width, height in [(250, 220), (280, 280), (450, 600), (800, 220)]:
- widget.resize(width, height)
- cx, cy, radius, label = widget.layout_geometry()
- self.assertGreaterEqual(label.top() + cy, cy + radius)
- self.assertLessEqual(label.bottom() + cy, height)
- self.assertGreaterEqual(cx - radius, 0)
- self.assertLessEqual(cx + radius, width)
- widget.roll, widget.pitch, widget.yaw = .1, -.2, .3
- widget.show(); app.processEvents(); widget.grab()
- widget.close()
- if __name__ == '__main__': unittest.main()
|