Skip to content

Commit

Permalink
refs #6601. Add to and refactor python tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Feb 22, 2013
1 parent ce6bb2c commit 522627f
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions Code/Mantid/MantidPlot/test/MantidPlotAlgorithmDialogTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,33 @@
from mantidplottests import *
import mantidqtpython
import sys
import tempfile

class MantidPlotAlgorithmDialogTest(unittest.TestCase):

__target_algorithm__ = "CreateMDWorkspace"
__clean_properties__ = True

def test_OpenDialog(self):
if not sys.platform == 'darwin':
interface_manager = mantidqtpython.MantidQt.API.InterfaceManager()
dialog = threadsafe_call( interface_manager.createDialogFromName, "CreateMDWorkspace", False)
is_instance_of_alg_dialog = isinstance(dialog, mantidqtpython.MantidQt.API.AlgorithmDialog)
self.assertEqual(is_instance_of_alg_dialog, True)
else:
pass

interface_manager = mantidqtpython.MantidQt.API.InterfaceManager()
dialog = threadsafe_call( interface_manager.createDialogFromName, self.__target_algorithm__, self.__clean_properties__)
is_instance_of_alg_dialog = isinstance(dialog, mantidqtpython.MantidQt.API.AlgorithmDialog)
self.assertEqual(is_instance_of_alg_dialog, True, "Did not get an AlgorithmDialog instance back.")
threadsafe_call( dialog.close )

def test_ScreenShotDialog(self):
interface_manager = mantidqtpython.MantidQt.API.InterfaceManager()
dialog = threadsafe_call( interface_manager.createDialogFromName, self.__target_algorithm__, self.__clean_properties__)
screenshotdir = tempfile.gettempdir();
file = "CreateMDWorkspace_screenshot"
screenshot(widget=dialog, filename=file, screenshot_dir=screenshotdir)
threadsafe_call(dialog.close)
file_abs = os.path.join(screenshotdir, file + ".png")
file_exists = os.path.isfile(file_abs)
self.assertEquals(file_exists, True, "Screenshot was not written out as expected.")
if file_exists:
os.remove(file_abs)

# Run the unit tests
mantidplottests.runTests(MantidPlotAlgorithmDialogTest)

Expand Down

0 comments on commit 522627f

Please sign in to comment.