Skip to content

Commit

Permalink
Basic tests of view paint functions
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed May 21, 2015
1 parent 206e1f4 commit 7db82ec
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
20 changes: 20 additions & 0 deletions inselect/tests/gui/gui_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,23 @@ def wait_for_input(self):
w.running_operation[-1].completed.connect(receiver.completed)
w.running_operation[-1].wait()
receiver.wait_for_input()

def run_event_loop(self, timeout_ms=100):
"""Runs the main window's event loop until timeout_ms have elapsed
"""
class TimeoutReceiver(QtCore.QObject):
def __init__(self):
super(self.__class__, self).__init__()
self.eventLoop = QtCore.QEventLoop(self)

def timerEvent(self, event):
self.eventLoop.exit()

def wait_for_timeout(self):
self.eventLoop.exec_()

w = self.window
receiver = TimeoutReceiver()
timer = receiver.startTimer(timeout_ms)
receiver.wait_for_timeout()
receiver.killTimer(timer)
42 changes: 42 additions & 0 deletions inselect/tests/gui/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import unittest

from pathlib import Path

from PySide import QtGui

from gui_test import MainWindowTest

TESTDATA = Path(__file__).parent.parent / 'test_data'


class TestViews(MainWindowTest):
"""Basic tests of the boxes and objects views. Functions test as much of the
view's paint methods as possible by loading a document, selecting the view
under test and showing the main window full screen.
"""

def test_boxes_view_paint(self):
"Boxes view is painted"
self.window.open_file(TESTDATA / 'test_segment.inselect')
self.window.showFullScreen()
self.run_event_loop()

def test_objects_view_grid_paint(self):
"Objects grid view is painted"
self.window.open_file(TESTDATA / 'test_segment.inselect')
self.window.show_tab(1)
self.window.show_grid()
self.window.showFullScreen()
self.run_event_loop()

def test_objects_view_expanded_paint(self):
"Objects expanded view is painted"
self.window.open_file(TESTDATA / 'test_segment.inselect')
self.window.show_tab(1)
self.window.show_expanded()
self.window.showFullScreen()
self.run_event_loop()


if __name__=='__main__':
unittest.main()
3 changes: 2 additions & 1 deletion inselect/tests/test_data/test_segment.inselect
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
0.4494,
0.1356,
0.08060000000000003
]
],
"rotation": 90
},
{
"fields": {},
Expand Down

0 comments on commit 7db82ec

Please sign in to comment.