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

Improve test coverage

parent 78c37c9c
Pipeline #1930 failed with stages
in 66 minutes and 37 seconds
......@@ -3,11 +3,11 @@ import logging
import datetime
from PySide2 import QtWidgets
from PySide2.QtCore import QTimer
from sksurgeryvtk.widgets.vtk_overlay_window import VTKOverlayWindow
from sksurgeryutils.common_overlay_apps import OverlayOnVideoFeedCropRecord
from sksurgeryutils.common_overlay_apps import \
OverlayOnVideoFeedCropRecord, DuplicateOverlayWindow
from sksurgeryutils.utils.screen_utils import ScreenController
from sksurgerydavinci.ui.gui import UI
from sksurgerydavinci.widgets.auto_cropping import AutoCropBlackBorder
from sksurgerydavinci.davinci_xi_auto_cropping import AutoCropBlackBorder
LOGGER = logging.getLogger(__name__)
......@@ -15,59 +15,6 @@ LOGGER = logging.getLogger(__name__)
#pylint: disable= no-member, attribute-defined-outside-init
#pylint: disable=protected-access, no-self-use
class DuplicateOverlayWindow(OverlayOnVideoFeedCropRecord):
Set the background of vtk_overlay_window to duplicate
that of another vtk_overlay_window.
Example usage:
video_source = 0
source_window = OverlayOnVideoFeedCropRecord(video_source)
duplicate_window = DuplicateOverlayWindow()
def __init__(self):
#pylint: disable=super-init-not-called
self.vtk_overlay_window = VTKOverlayWindow()
self.update_rate = 30
self.img = None
self.timer = None
def set_source_window(self, source_window):
""" Set the source window.
:param source_window: The window that contains the image to copy. """
self.source_window = source_window
def update(self):
""" Update the frame with a new background image."""
if self.source_window.roi:
start_x, start_y = self.source_window.roi[0]
end_x, end_y = self.source_window.roi[1]
self.vtk_overlay_window. \
def on_record_start(self):
""" Don't want to call the base class version, so override."""
def on_record_stop(self):
""" Don't want to call the base class version, so override."""
def set_roi(self):
""" Don't want to call the base class version, so override."""
class FakeOverlayOnVideoFeed:
""" Implement empty methods to replicate OverlayOnVideoFeed. """
......@@ -323,6 +270,9 @@ class MonoViewer(StereoViewerBase):
Generates a VTK interactor UI with a single video stream as background.
:param video_source: OpenCV compatible video source (int or filename)
Only use the left_view of StereoViewerBase. Set the other views to
non-existent views.
def __init__(self, video_source):"Creating Mono Viewer")
import os
import sys
import pytest
import time
import numpy as np
from PySide2 import QtCore
from sksurgerydavinci.widgets import Viewers
from sksurgeryutils.common_overlay_apps import OverlayOnVideoFeed
def test_button_callbacks_executed(qtbot):
mono = Viewers.MonoViewer('tests/data/davinci_xi_generated_video.avi')
# Ensure we get a frame
# Screenshot button
qtbot.mouseClick(mono.UI.screenshot_button, QtCore.Qt.LeftButton)
# Record start/stop
qtbot.mouseClick(mono.UI.record_button, QtCore.Qt.LeftButton)
qtbot.mouseClick(mono.UI.record_button, QtCore.Qt.LeftButton)
# Autocropping
qtbot.mouseClick(mono.UI.autocrop_button, QtCore.Qt.LeftButton)
qtbot.mouseClick(mono.UI.autocrop_button, QtCore.Qt.LeftButton)
# # Manual cropping, click crop button then abort
# qtbot.mouseClick(mono.UI.crop_button, QtCore.Qt.LeftButton)
# qtbot.keyPress(mono, 'a')
def test_mock_stereo_cameras_are_synced(qtbot):
mock_stereo = Viewers.MockStereoViewer('tests/data/test_video.avi')
mock_stereo = Viewers.MockStereoViewer('tests/data/davinci_xi_generated_video.avi')
......@@ -17,4 +44,14 @@ def test_mock_stereo_cameras_are_synced(qtbot):
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
assert left_cam == ui_cam
def test_stereo_viewer_runs(qtbot):
left = 'tests/data/test_video.avi'
right = 'tests/data/test_video.avi'
stereo = Viewers.StereoViewer(left, right)
\ No newline at end of file
import cv2
import numpy as np
import pytest
from sksurgerydavinci.widgets.auto_cropping import AutoCropBlackBorder
from sksurgerydavinci.davinci_xi_auto_cropping import AutoCropBlackBorder
def set_central_screen(img, size):
Supports Markdown
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