Skip to content

Commit

Permalink
Refs #4316 added SliceViewer test to ctest
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Janik Zikovsky committed Dec 13, 2011
1 parent 8de4940 commit b046c00
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ include_directories ( Framework/API/inc )
include_directories ( Framework/NexusCPP/inc )
set ( CORE_MANTIDLIBS Kernel Geometry API )

# Add a target for all GUI tests
add_custom_target ( GUITests )
add_dependencies ( check GUITests )

add_subdirectory ( MantidQt )

include_directories ( QtPropertyBrowser/src )
Expand Down
18 changes: 18 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ set ( UI_FILES
inc/MantidQtSliceViewer/XYLimitsDialog.ui
)

# Python unit tests
set ( TEST_PY_FILES
test/SliceViewerPythonInterfaceTest.py
)


include_directories ( inc )
include_directories ( ../../QtPropertyBrowser/src )
Expand Down Expand Up @@ -119,6 +124,19 @@ target_link_libraries ( LineViewerDemo

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
###########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
from PyQt4 import Qt
from PyQt4 import QtTest
from PyQt4.QtTest import QTest

# Import the Mantid framework
import MantidFramework
from MantidFramework import mtd
from mantidsimple import *
import libmantidqtpython


app = Qt.QApplication(sys.argv)

# Create a test data set
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')
Expand All @@ -20,9 +28,13 @@ class SliceViewerPythonInterfaceTest(unittest.TestCase):
"""Test for accessing SliceViewer widgets from MantidPlot
python interpreter"""

def __init__(self, *args):
""" Constructor: builda QApplication """
unittest.TestCase.__init__(self, *args)


def setUp(self):
""" Set up and create a SliceViewer widget """
global libmantidqtpython
self.sv = libmantidqtpython.MantidQt.SliceViewer.SliceViewer()
pass

Expand All @@ -31,26 +43,14 @@ def tearDown(self):
self.sv.close()

def test_setWorkspace(self):
print "test_setWorkspace"
sv = self.sv
sv.setWorkspace('uniform')
sv.show()
global QTest
#QTest.mouseClick(sv)

def test_other(self):
print "test_other"
def test_set_MDEventWorkspace(self):
sv = self.sv
sv.setWorkspace('mdw')
sv.show()



# ----- Create and run the unit test ----------------------
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 comments on commit b046c00

Please sign in to comment.