Commit fa1c557f authored by Thomas Dowrick's avatar Thomas Dowrick
Browse files

Change UI tests to use pytest-qt

parent bde005aa
......@@ -13,4 +13,5 @@ sphinx
sphinx_rtd_theme
pyinstaller
pytest
pytest-qt
tox
""" Mono/Stereo viewing windows for Ardavinci"""
import logging
from PySide2 import QtWidgets
from sksurgeryvtk.widgets.vtk_overlay_window import VTKOverlayWindow
from sksurgeryvtk.widgets.common_overlay_apps import OverlayOnVideoFeed
from sksurgeryutils.utils.screen_utils import ScreenController
......@@ -42,11 +43,12 @@ class DuplicateOverlayWindow(OverlayOnVideoFeed):
self.vtk_overlay_window._RenderWindow.Render()
class MonoViewer():
class MonoViewer(QtWidgets.QWidget):
"""Generates a VTK interactor UI with a video stream as background"""
def __init__(self, video_source):
super().__init__()
LOGGER.info("Creating Mono Viewer")
self.overlay_window = OverlayOnVideoFeed(video_source)
......@@ -62,11 +64,13 @@ class MonoViewer():
self.overlay_window.start()
class StereoViewerBase():
class StereoViewerBase(QtWidgets.QWidget):
"""
Base class for StereoViewers.
"""
def __init__(self):
super().__init__()
def setup_widgets(self):
""" Sync the cameras between the widgets,
......@@ -192,6 +196,7 @@ class MockStereoViewer(StereoViewerBase):
"""
def __init__(self, video_source):
super().__init__()
LOGGER.info("Creating Mock Stereo Viewwer")
......
import pytest
import numpy as np
from sksurgeryardavinci.widgets import Viewers
from sksurgeryvtk.widgets.common_overlay_apps import OverlayOnVideoFeed
# pyint:disable=line-too-long
@pytest.fixture(scope="module")
def video_file_source():
""" Provide video file for subsequent tests"""
video_filename = 'tests/data/test_video.avi'
return video_filename
@pytest.fixture(scope="module")
def mock_stereo_widget(video_file_source):
""" Provide video file for subsequent tests"""
return mock_stereo
def test_mock_stereo_cameras_are_synced(qtbot):
mock_stereo = Viewers.MockStereoViewer('tests/data/test_video.avi')
qtbot.addWidget(mock_stereo)
mock_stereo.start()
left_cam = mock_stereo.left_overlay.get_foreground_camera()
right_cam = mock_stereo.right_overlay.get_foreground_camera()
ui_cam = mock_stereo.ui_overlay.get_foreground_camera()
assert left_cam == right_cam
assert left_cam == ui_cam
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment