Salome HOME
[MEDCalc] Moved test directory up one level
authorabn <adrien.bruneton@cea.fr>
Tue, 12 Apr 2016 11:38:41 +0000 (13:38 +0200)
committerabn <adrien.bruneton@cea.fr>
Tue, 12 Apr 2016 11:38:41 +0000 (13:38 +0200)
18 files changed:
src/MEDCalc/CMakeLists.txt
src/MEDCalc/gui/CMakeLists.txt
src/MEDCalc/gui/test/CMakeLists.txt [deleted file]
src/MEDCalc/gui/test/README.txt [deleted file]
src/MEDCalc/gui/test/baselines/test_scalarmap.png [deleted file]
src/MEDCalc/gui/test/guiTester.pro [deleted file]
src/MEDCalc/gui/test/medcalc_testutils.py.in [deleted file]
src/MEDCalc/gui/test/scenarios/test_scalarmap.xml [deleted file]
src/MEDCalc/gui/test/test_qttesting.py [deleted file]
src/MEDCalc/gui/test/test_scalarmap.py [deleted file]
src/MEDCalc/test/CMakeLists.txt [new file with mode: 0644]
src/MEDCalc/test/README.txt [new file with mode: 0644]
src/MEDCalc/test/baselines/test_scalarmap.png [new file with mode: 0644]
src/MEDCalc/test/guiTester.pro [new file with mode: 0644]
src/MEDCalc/test/medcalc_testutils.py.in [new file with mode: 0644]
src/MEDCalc/test/scenarios/test_scalarmap.xml [new file with mode: 0644]
src/MEDCalc/test/test_qttesting.py [new file with mode: 0644]
src/MEDCalc/test/test_scalarmap.py [new file with mode: 0644]

index a0815a29fca2fabac4763f367882eab2a0ee255c..d6a1e4d3a8a25ec13c97dbbbe8ff04decc4a6687 100644 (file)
@@ -22,6 +22,11 @@ ADD_SUBDIRECTORY(res)
 
 IF(SALOME_BUILD_GUI)
   ADD_SUBDIRECTORY(gui)
+
+  IF(SALOME_MED_WITH_QTTESTING)  
+    ADD_SUBDIRECTORY(test)
+  ENDIF()
+  
 ENDIF()
 
 IF(SALOME_MED_ENABLE_PYTHON)
index f53d45075d18ce60a1239e750a98052252138607..b33ab4dfc4f1ec6b4472f79b10a1d852c9335e11 100644 (file)
@@ -17,8 +17,6 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-ADD_SUBDIRECTORY(test)
-
 IF(SALOME_MED_WITH_QTTESTING)
   ADD_DEFINITIONS(-DMED_HAS_QTTESTING)
 ENDIF()
diff --git a/src/MEDCalc/gui/test/CMakeLists.txt b/src/MEDCalc/gui/test/CMakeLists.txt
deleted file mode 100644 (file)
index c17548b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) 2012-2016  CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-SALOME_CONFIGURE_FILE(medcalc_testutils.py.in ${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py)
-
-SET(_test_scripts
-    test_qttesting.py    # main entry point
-    test_scalarmap.py
-)
-
-SET(_test_scenarii
-   scenarios/test_scalarmap.xml
-)
-
-SET(_test_baselines
-    baselines/test_scalarmap.png
-)
-
-# Test rules - the test MEDCalcQtTesting must be run after install (since it starts SALOME) 
-ADD_TEST(MEDCalcQtTesting ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_qttesting.py)
-
-# Install rules
-SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests)
-SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_INSTALL_PYTHON})
-INSTALL(FILES ${_test_scenarii} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/scenarios)
-INSTALL(FILES ${_test_baselines} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/baselines)
diff --git a/src/MEDCalc/gui/test/README.txt b/src/MEDCalc/gui/test/README.txt
deleted file mode 100644 (file)
index ad68b0d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-test_qttesting.py
-=================
-
-Tests based on QtTesting framework from ParaView.
-Main entry point is test_qttesting.py.
-Each scenario is described in a XML file and can be recorded directly in the GUI via the "Record test" button. 
-
-A scneario must save a final screenshot of the ParaView view in a file located in the temp directory (TODO: review
-this). This file is compared against a baseline saved in the baselines subdirectory.
-
-
-guiTester.pro 
-=============
-
-This is a simple Qt framework to test the dialog widgets.
-
-To build the project:
-* specify the sources files in the .pro file
-* run qmake, then make
-* run guiTester
-
-To clean the project:
-* run "make clean"
-* remove binary and Makefile
-  $ rm guiTester Makefile
diff --git a/src/MEDCalc/gui/test/baselines/test_scalarmap.png b/src/MEDCalc/gui/test/baselines/test_scalarmap.png
deleted file mode 100644 (file)
index 3e827f4..0000000
Binary files a/src/MEDCalc/gui/test/baselines/test_scalarmap.png and /dev/null differ
diff --git a/src/MEDCalc/gui/test/guiTester.pro b/src/MEDCalc/gui/test/guiTester.pro
deleted file mode 100644 (file)
index 51f1f87..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-######################################################################
-# Automatically generated by qmake (2.01a) mer. oct. 6 14:46:48 2010
-######################################################################
-
-TEMPLATE = app
-TARGET = 
-DEPENDPATH += .
-INCLUDEPATH += . ../dialogs
-
-# Input
-HEADERS += ../dialogs/DlgAlias.h
-FORMS += ../dialogs/dlgAlias.ui
-SOURCES += ../dialogs/DlgAlias.cxx ../dialogs/dlgTester.cxx
diff --git a/src/MEDCalc/gui/test/medcalc_testutils.py.in b/src/MEDCalc/gui/test/medcalc_testutils.py.in
deleted file mode 100644 (file)
index 59880a5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-import os
-
-def __getRootDir():  
-  rootDir = os.environ.get("MED_ROOT_DIR", "")
-  return rootDir 
-
-def GetScriptDir():
-  relativeDir = "@SALOME_INSTALL_PYTHON@/tests"
-  return os.path.join(__getRootDir(), relativeDir)
-
-def GetScenarioDir():
-  relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/scenarios"
-  return os.path.join(__getRootDir(), relativeDir)
-
-def GetBaselineDir():
-  relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/baselines"
-  return os.path.join(__getRootDir(), relativeDir)
diff --git a/src/MEDCalc/gui/test/scenarios/test_scalarmap.xml b/src/MEDCalc/gui/test/scenarios/test_scalarmap.xml
deleted file mode 100644 (file)
index edbc38f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" ?>
-<pqevents>
-  <pqevent object="1STD_TabDesktop0/1QMenuBar0" command="activate" arguments="Fic&amp;hier" />
-  <pqevent object="1QMenu0" command="activate" arguments="LAB_LOCK_TEST" />
-  <pqevent object="1STD_TabDesktop0/DatasourceToolbar/1QToolButton0" command="activate" arguments="" />
-  <pqevent object="Qt-subapplication-app" command="FilesOpen" arguments="/home/ab205030/agi_BKP.med" />
-  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="expand" arguments="0.0" />
-  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="expand" arguments="0.0.0.0" />
-  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="expand" arguments="0.0.0.0.0.0" />
-  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseWheel" arguments="-120,0,0,88,5" />
-  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseWheel" arguments="-120,0,0,88,5" />
-  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="setCurrent" arguments="0.0.0.0.0.0.0.0" />
-  <pqevent object="1STD_TabDesktop0/PresentationToolbar/1QToolButton0" command="activate" arguments="" />
-  <pqevent object="1STD_TabDesktop0/1QMenuBar0" command="activate" arguments="Fic&amp;hier" />
-  <pqevent object="1QMenu0" command="activate" arguments="LAB_SNAP_TEST" />
-  <pqevent object="1STD_TabDesktop0/SaveSnapshotDialog/ok" command="activate" arguments="" />
-  <pqevent object="1STD_TabDesktop0/FileSaveScreenshotDialog" command="key" arguments="16777248" />
-  <pqevent object="1STD_TabDesktop0/FileSaveScreenshotDialog/mainSplitter/widget/FileName" command="set_string" arguments="/tmp/test_scalarmap.png" />
-  <pqevent object="1STD_TabDesktop0/FileSaveScreenshotDialog/mainSplitter/widget/OK" command="activate" arguments="" />
-</pqevents>
diff --git a/src/MEDCalc/gui/test/test_qttesting.py b/src/MEDCalc/gui/test/test_qttesting.py
deleted file mode 100644 (file)
index 390afe5..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# Author: A. Bruneton (CEA)
-
-import unittest, os
-from posixpath import basename
-
-class MEDGUITest(unittest.TestCase):
-  def __init__(self, methodName='runTest'):
-    unittest.TestCase.__init__(self, methodName=methodName)
-    self._tmpDir = ""
-    self._removeDir = True
-    
-  def setUp(self):
-    import tempfile
-    self._tmpDir = tempfile.mkdtemp(prefix="med_gui_tests_")
-    self._removeDir = True  # reset for each new test in the TestCase
-
-  def tearDown(self):
-    import shutil
-    unittest.TestCase.tearDown(self)
-    if self._removeDir:
-      shutil.rmtree(self._tmpDir, False)
-    
-  def getTestName(self):
-    """ Return name of the test being currently executed. """
-    return self.id().split(".")[-1]
-
-  def launchSalomeWithScript(self, scriptname, baseline):
-    """ TODO: review this - what is the nicest way to launch SALOME GUI from a Python script? """
-    import shutil, subprocess
-    from medcalc_testutils import GetScriptDir
-    # TODO: review this!
-    salomeCommand = os.path.join(os.environ.get("KERNEL_ROOT_DIR", ""), "bin", "salome", "runSalome.py")
-    pth = os.path.join(GetScriptDir(), scriptname)
-    # Remove a potentially already present image file from the tmp directory:
-    gen_image = os.path.join("/tmp", baseline)
-    try:
-      shutil.rmtree(gen_image)
-    except OSError:
-      pass
-    # Launch SALOME with the test script:
-    status = subprocess.call([salomeCommand, pth])
-    if status:
-      raise Exception("SALOME exited abnormally for this test!")
-    try:
-      # Move generated image to the temporary test directory - ideally test should produce image there directly ...
-      shutil.move(gen_image, self._tmpDir)
-    except IOError:
-      raise Exception("Test script didn't produce expected image '%s'!" % gen_image)
-
-  def compareSnapshot(self, basename):
-    import filecmp
-    from medcalc_testutils import GetBaselineDir
-    
-    base_pth = os.path.join(GetBaselineDir(), basename)
-    gen_path = os.path.join(self._tmpDir, basename)
-    print base_pth, gen_path
-    try:
-      ret = filecmp.cmp(base_pth, gen_path, shallow=False)
-    except OSError:
-      ret = False
-    if not ret:
-      # Keep file if comparison fails
-      self._removeDir = False
-      self.assertTrue(ret, "[%s] -- Failed screenshot equality, or unable to open baseline file - directory is kept alive: %s" % (self.getTestName(), self._tmpDir))
-    return ret
-
-  ##
-  ## Now the tests themselves
-  ##
-  
-  def testScalarMap(self):
-    baseline = "test_scalarmap.png"
-    self.launchSalomeWithScript("test_scalarmap.py", baseline)
-    self.compareSnapshot(baseline)
-
-
-if __name__ == "__main__":
-  suite = unittest.TestSuite()
-  suite.addTest(MEDGUITest('testScalarMap'))
-#  suite.addTest(MEDGUITest('testIsoContour'))
-  unittest.TextTestRunner().run(suite)
-
diff --git a/src/MEDCalc/gui/test/test_scalarmap.py b/src/MEDCalc/gui/test/test_scalarmap.py
deleted file mode 100644 (file)
index ddf508e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-""" Test of the scalarmap. 
-
-This script is to be passed as an argument of the ./salome command and will be executed within the SALOME
-Python console.
-"""
-
-import os
-import SalomePyQt
-from medcalc_testutils import GetScenarioDir
-
-sgPyQt = SalomePyQt.SalomePyQt()
-sgPyQt.activateModule('MED')
-
-import medcalc  # After module activation !!
-medcalc.PlayQtTestingScenario(os.path.join(GetScenarioDir(), 'test_scalarmap.xml'))
-
-medcalc.RequestSALOMETermination()  # not equivalent to quit()! 
diff --git a/src/MEDCalc/test/CMakeLists.txt b/src/MEDCalc/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c17548b
--- /dev/null
@@ -0,0 +1,43 @@
+# Copyright (C) 2012-2016  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SALOME_CONFIGURE_FILE(medcalc_testutils.py.in ${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py)
+
+SET(_test_scripts
+    test_qttesting.py    # main entry point
+    test_scalarmap.py
+)
+
+SET(_test_scenarii
+   scenarios/test_scalarmap.xml
+)
+
+SET(_test_baselines
+    baselines/test_scalarmap.png
+)
+
+# Test rules - the test MEDCalcQtTesting must be run after install (since it starts SALOME) 
+ADD_TEST(MEDCalcQtTesting ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_qttesting.py)
+
+# Install rules
+SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests)
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_INSTALL_PYTHON})
+INSTALL(FILES ${_test_scenarii} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/scenarios)
+INSTALL(FILES ${_test_baselines} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/baselines)
diff --git a/src/MEDCalc/test/README.txt b/src/MEDCalc/test/README.txt
new file mode 100644 (file)
index 0000000..ad68b0d
--- /dev/null
@@ -0,0 +1,25 @@
+test_qttesting.py
+=================
+
+Tests based on QtTesting framework from ParaView.
+Main entry point is test_qttesting.py.
+Each scenario is described in a XML file and can be recorded directly in the GUI via the "Record test" button. 
+
+A scneario must save a final screenshot of the ParaView view in a file located in the temp directory (TODO: review
+this). This file is compared against a baseline saved in the baselines subdirectory.
+
+
+guiTester.pro 
+=============
+
+This is a simple Qt framework to test the dialog widgets.
+
+To build the project:
+* specify the sources files in the .pro file
+* run qmake, then make
+* run guiTester
+
+To clean the project:
+* run "make clean"
+* remove binary and Makefile
+  $ rm guiTester Makefile
diff --git a/src/MEDCalc/test/baselines/test_scalarmap.png b/src/MEDCalc/test/baselines/test_scalarmap.png
new file mode 100644 (file)
index 0000000..3e827f4
Binary files /dev/null and b/src/MEDCalc/test/baselines/test_scalarmap.png differ
diff --git a/src/MEDCalc/test/guiTester.pro b/src/MEDCalc/test/guiTester.pro
new file mode 100644 (file)
index 0000000..51f1f87
--- /dev/null
@@ -0,0 +1,13 @@
+######################################################################
+# Automatically generated by qmake (2.01a) mer. oct. 6 14:46:48 2010
+######################################################################
+
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += . ../dialogs
+
+# Input
+HEADERS += ../dialogs/DlgAlias.h
+FORMS += ../dialogs/dlgAlias.ui
+SOURCES += ../dialogs/DlgAlias.cxx ../dialogs/dlgTester.cxx
diff --git a/src/MEDCalc/test/medcalc_testutils.py.in b/src/MEDCalc/test/medcalc_testutils.py.in
new file mode 100644 (file)
index 0000000..59880a5
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+
+def __getRootDir():  
+  rootDir = os.environ.get("MED_ROOT_DIR", "")
+  return rootDir 
+
+def GetScriptDir():
+  relativeDir = "@SALOME_INSTALL_PYTHON@/tests"
+  return os.path.join(__getRootDir(), relativeDir)
+
+def GetScenarioDir():
+  relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/scenarios"
+  return os.path.join(__getRootDir(), relativeDir)
+
+def GetBaselineDir():
+  relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/baselines"
+  return os.path.join(__getRootDir(), relativeDir)
diff --git a/src/MEDCalc/test/scenarios/test_scalarmap.xml b/src/MEDCalc/test/scenarios/test_scalarmap.xml
new file mode 100644 (file)
index 0000000..edbc38f
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+<pqevents>
+  <pqevent object="1STD_TabDesktop0/1QMenuBar0" command="activate" arguments="Fic&amp;hier" />
+  <pqevent object="1QMenu0" command="activate" arguments="LAB_LOCK_TEST" />
+  <pqevent object="1STD_TabDesktop0/DatasourceToolbar/1QToolButton0" command="activate" arguments="" />
+  <pqevent object="Qt-subapplication-app" command="FilesOpen" arguments="/home/ab205030/agi_BKP.med" />
+  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="expand" arguments="0.0" />
+  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="expand" arguments="0.0.0.0" />
+  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="expand" arguments="0.0.0.0.0.0" />
+  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseWheel" arguments="-120,0,0,88,5" />
+  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseWheel" arguments="-120,0,0,88,5" />
+  <pqevent object="1STD_TabDesktop0/objectBrowserDock/objectBrowser/1QtxTreeView0" command="setCurrent" arguments="0.0.0.0.0.0.0.0" />
+  <pqevent object="1STD_TabDesktop0/PresentationToolbar/1QToolButton0" command="activate" arguments="" />
+  <pqevent object="1STD_TabDesktop0/1QMenuBar0" command="activate" arguments="Fic&amp;hier" />
+  <pqevent object="1QMenu0" command="activate" arguments="LAB_SNAP_TEST" />
+  <pqevent object="1STD_TabDesktop0/SaveSnapshotDialog/ok" command="activate" arguments="" />
+  <pqevent object="1STD_TabDesktop0/FileSaveScreenshotDialog" command="key" arguments="16777248" />
+  <pqevent object="1STD_TabDesktop0/FileSaveScreenshotDialog/mainSplitter/widget/FileName" command="set_string" arguments="/tmp/test_scalarmap.png" />
+  <pqevent object="1STD_TabDesktop0/FileSaveScreenshotDialog/mainSplitter/widget/OK" command="activate" arguments="" />
+</pqevents>
diff --git a/src/MEDCalc/test/test_qttesting.py b/src/MEDCalc/test/test_qttesting.py
new file mode 100644 (file)
index 0000000..390afe5
--- /dev/null
@@ -0,0 +1,100 @@
+# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: A. Bruneton (CEA)
+
+import unittest, os
+from posixpath import basename
+
+class MEDGUITest(unittest.TestCase):
+  def __init__(self, methodName='runTest'):
+    unittest.TestCase.__init__(self, methodName=methodName)
+    self._tmpDir = ""
+    self._removeDir = True
+    
+  def setUp(self):
+    import tempfile
+    self._tmpDir = tempfile.mkdtemp(prefix="med_gui_tests_")
+    self._removeDir = True  # reset for each new test in the TestCase
+
+  def tearDown(self):
+    import shutil
+    unittest.TestCase.tearDown(self)
+    if self._removeDir:
+      shutil.rmtree(self._tmpDir, False)
+    
+  def getTestName(self):
+    """ Return name of the test being currently executed. """
+    return self.id().split(".")[-1]
+
+  def launchSalomeWithScript(self, scriptname, baseline):
+    """ TODO: review this - what is the nicest way to launch SALOME GUI from a Python script? """
+    import shutil, subprocess
+    from medcalc_testutils import GetScriptDir
+    # TODO: review this!
+    salomeCommand = os.path.join(os.environ.get("KERNEL_ROOT_DIR", ""), "bin", "salome", "runSalome.py")
+    pth = os.path.join(GetScriptDir(), scriptname)
+    # Remove a potentially already present image file from the tmp directory:
+    gen_image = os.path.join("/tmp", baseline)
+    try:
+      shutil.rmtree(gen_image)
+    except OSError:
+      pass
+    # Launch SALOME with the test script:
+    status = subprocess.call([salomeCommand, pth])
+    if status:
+      raise Exception("SALOME exited abnormally for this test!")
+    try:
+      # Move generated image to the temporary test directory - ideally test should produce image there directly ...
+      shutil.move(gen_image, self._tmpDir)
+    except IOError:
+      raise Exception("Test script didn't produce expected image '%s'!" % gen_image)
+
+  def compareSnapshot(self, basename):
+    import filecmp
+    from medcalc_testutils import GetBaselineDir
+    
+    base_pth = os.path.join(GetBaselineDir(), basename)
+    gen_path = os.path.join(self._tmpDir, basename)
+    print base_pth, gen_path
+    try:
+      ret = filecmp.cmp(base_pth, gen_path, shallow=False)
+    except OSError:
+      ret = False
+    if not ret:
+      # Keep file if comparison fails
+      self._removeDir = False
+      self.assertTrue(ret, "[%s] -- Failed screenshot equality, or unable to open baseline file - directory is kept alive: %s" % (self.getTestName(), self._tmpDir))
+    return ret
+
+  ##
+  ## Now the tests themselves
+  ##
+  
+  def testScalarMap(self):
+    baseline = "test_scalarmap.png"
+    self.launchSalomeWithScript("test_scalarmap.py", baseline)
+    self.compareSnapshot(baseline)
+
+
+if __name__ == "__main__":
+  suite = unittest.TestSuite()
+  suite.addTest(MEDGUITest('testScalarMap'))
+#  suite.addTest(MEDGUITest('testIsoContour'))
+  unittest.TextTestRunner().run(suite)
+
diff --git a/src/MEDCalc/test/test_scalarmap.py b/src/MEDCalc/test/test_scalarmap.py
new file mode 100644 (file)
index 0000000..ddf508e
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+""" Test of the scalarmap. 
+
+This script is to be passed as an argument of the ./salome command and will be executed within the SALOME
+Python console.
+"""
+
+import os
+import SalomePyQt
+from medcalc_testutils import GetScenarioDir
+
+sgPyQt = SalomePyQt.SalomePyQt()
+sgPyQt.activateModule('MED')
+
+import medcalc  # After module activation !!
+medcalc.PlayQtTestingScenario(os.path.join(GetScenarioDir(), 'test_scalarmap.xml'))
+
+medcalc.RequestSALOMETermination()  # not equivalent to quit()!