Skip to content
Snippets Groups Projects
Commit b046c006 authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #4316 added SliceViewer test to ctest

Created a GUITests target to hold this and future GUI tests.
Test python script runs from python stand alone. Rudimentary test for now, can use QtTest in the future for more sophisticated tests.
parent 8de49404
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,10 @@ include_directories ( Framework/API/inc ) ...@@ -51,6 +51,10 @@ include_directories ( Framework/API/inc )
include_directories ( Framework/NexusCPP/inc ) include_directories ( Framework/NexusCPP/inc )
set ( CORE_MANTIDLIBS Kernel Geometry API ) set ( CORE_MANTIDLIBS Kernel Geometry API )
# Add a target for all GUI tests
add_custom_target ( GUITests )
add_dependencies ( check GUITests )
add_subdirectory ( MantidQt ) add_subdirectory ( MantidQt )
include_directories ( QtPropertyBrowser/src ) include_directories ( QtPropertyBrowser/src )
......
...@@ -49,6 +49,11 @@ set ( UI_FILES ...@@ -49,6 +49,11 @@ set ( UI_FILES
inc/MantidQtSliceViewer/XYLimitsDialog.ui inc/MantidQtSliceViewer/XYLimitsDialog.ui
) )
# Python unit tests
set ( TEST_PY_FILES
test/SliceViewerPythonInterfaceTest.py
)
include_directories ( inc ) include_directories ( inc )
include_directories ( ../../QtPropertyBrowser/src ) include_directories ( ../../QtPropertyBrowser/src )
...@@ -119,6 +124,19 @@ target_link_libraries ( LineViewerDemo ...@@ -119,6 +124,19 @@ target_link_libraries ( LineViewerDemo
endif () endif ()
###########################################################################
# Unit tests setup
###########################################################################
# python unit tests
if (PYUNITTEST_FOUND)
pyunittest_add_test ( SliceViewerTest.py ${TEST_PY_FILES} "" )
add_dependencies ( SliceViewerTest.py MantidQt Algorithms )
add_dependencies ( GUITests SliceViewerTest.py )
# Add to the 'UnitTests' group in VS
set_property ( TARGET SliceViewerTest.py PROPERTY FOLDER "UnitTests" )
endif ()
########################################################################### ###########################################################################
# Installation settings # Installation settings
########################################################################### ###########################################################################
......
...@@ -6,8 +6,16 @@ import time ...@@ -6,8 +6,16 @@ import time
from PyQt4 import Qt from PyQt4 import Qt
from PyQt4 import QtTest from PyQt4 import QtTest
from PyQt4.QtTest import QTest from PyQt4.QtTest import QTest
# Import the Mantid framework
import MantidFramework
from MantidFramework import mtd
from mantidsimple import *
import libmantidqtpython import libmantidqtpython
app = Qt.QApplication(sys.argv)
# Create a test data set # Create a test data set
CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z', CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',
Units='m,m,m',SplitInto='5',SplitThreshold=100, MaxRecursionDepth='20',OutputWorkspace='mdw') Units='m,m,m',SplitInto='5',SplitThreshold=100, MaxRecursionDepth='20',OutputWorkspace='mdw')
...@@ -20,9 +28,13 @@ class SliceViewerPythonInterfaceTest(unittest.TestCase): ...@@ -20,9 +28,13 @@ class SliceViewerPythonInterfaceTest(unittest.TestCase):
"""Test for accessing SliceViewer widgets from MantidPlot """Test for accessing SliceViewer widgets from MantidPlot
python interpreter""" python interpreter"""
def __init__(self, *args):
""" Constructor: builda QApplication """
unittest.TestCase.__init__(self, *args)
def setUp(self): def setUp(self):
""" Set up and create a SliceViewer widget """ """ Set up and create a SliceViewer widget """
global libmantidqtpython
self.sv = libmantidqtpython.MantidQt.SliceViewer.SliceViewer() self.sv = libmantidqtpython.MantidQt.SliceViewer.SliceViewer()
pass pass
...@@ -31,26 +43,14 @@ class SliceViewerPythonInterfaceTest(unittest.TestCase): ...@@ -31,26 +43,14 @@ class SliceViewerPythonInterfaceTest(unittest.TestCase):
self.sv.close() self.sv.close()
def test_setWorkspace(self): def test_setWorkspace(self):
print "test_setWorkspace"
sv = self.sv sv = self.sv
sv.setWorkspace('uniform') sv.setWorkspace('uniform')
sv.show() sv.show()
global QTest
#QTest.mouseClick(sv)
def test_other(self): def test_set_MDEventWorkspace(self):
print "test_other"
sv = self.sv sv = self.sv
sv.setWorkspace('mdw') sv.setWorkspace('mdw')
sv.show() sv.show()
# ----- Create and run the unit test ---------------------- \ No newline at end of file
sys.path.append("/home/8oz/Code/Mantid/Code/Mantid/TestingTools/unittest-xml-reporting/src")
import xmlrunner
suite = unittest.makeSuite(SliceViewerPythonInterfaceTest)
runner = xmlrunner.XMLTestRunner(output='Testing')
runner.run(suite)
print "Done!"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment