# 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)
+
IF(SALOME_BUILD_GUI)
IF(SALOME_MED_WITH_QTTESTING)
ADD_SUBDIRECTORY(gui)
ENDIF()
SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc)
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_INSTALL_SCRIPT_SCRIPTS})
INSTALL(FILES CTestTestfileInstall.cmake
DESTINATION ${TEST_INSTALL_DIRECTORY}
RENAME CTestTestfile.cmake)
# 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_scalarmap.py
)
SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc/gui)
SALOME_INSTALL_SCRIPTS(test_qttesting.py ${TEST_INSTALL_DIRECTORY})
-SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${TEST_INSTALL_DIRECTORY})
SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests/gui)
+++ /dev/null
-# 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/gui"
- return os.path.join(__getRootDir(), relativeDir)
-
-def GetScenarioDir():
- relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/gui/scenarios"
- return os.path.join(__getRootDir(), relativeDir)
-
-def GetBaselineDir():
- relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/gui/baselines"
- return os.path.join(__getRootDir(), relativeDir)
-
-def GetMEDFileDir():
- relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/gui/medfiles"
- return os.path.join(__getRootDir(), relativeDir)
def launchSalomeWithScript(self, scriptname):
""" TODO: review this - what is the nicest way to launch SALOME GUI from a Python script? """
from salome_instance import SalomeInstance
- from medcalc_testutils import GetScriptDir
+ from medcalc_testutils import GetScriptDirGUI
args = "args:%s" % self._tmpDir
- pth = os.path.join(GetScriptDir(), scriptname)
+ pth = os.path.join(GetScriptDirGUI(), scriptname)
# Launch SALOME with the test script:
inst = SalomeInstance.start(with_gui=True, args=[pth, args])
# And make sure SALOME is stopped before running next one:
""" Compare the screenshot in the current temporary test directory with the reference baseline.
Assert if not matching. """
import filecmp
- from medcalc_testutils import GetBaselineDir
+ from medcalc_testutils import GetBaselineDirGUI
- base_pth = os.path.join(GetBaselineDir(), basename)
+ base_pth = os.path.join(GetBaselineDirGUI(), basename)
gen_path = os.path.join(self._tmpDir, basename)
print base_pth, gen_path
try:
def prepareScenario(self, scenario, baseline, med_file):
""" Copy scenario to current temporary test dir and substitute paths inside """
- from medcalc_testutils import GetScenarioDir, GetMEDFileDir
- scen_path = os.path.join(GetScenarioDir(), scenario)
+ from medcalc_testutils import GetScenarioDirGUI, GetMEDFileDirGUI
+ scen_path = os.path.join(GetScenarioDirGUI(), scenario)
scen_pth2 = os.path.join(self._tmpDir, scenario)
try:
shutil.copy(scen_path, scen_pth2)
with open(scen_pth2,'r') as f:
filedata = f.read()
filedata = filedata.replace("/tmp/%s" % baseline, "%s/%s" % (self._tmpDir, baseline))
- filedata = filedata.replace("/tmp/%s" % med_file, os.path.join(GetMEDFileDir(), med_file))
+ filedata = filedata.replace("/tmp/%s" % med_file, os.path.join(GetMEDFileDirGUI(), med_file))
with open(scen_pth2,'w') as f:
f.write(filedata)
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-""" Test of the scalarmap.
+""" 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, sys
import SalomePyQt
-from medcalc_testutils import GetScenarioDir
+
+from medcalc_testutils import GetScenarioDirGUI
sgPyQt = SalomePyQt.SalomePyQt()
sgPyQt.activateModule('MED')
localTestDir = sys.argv[1]
medcalc.PlayQtTestingScenario(os.path.join(localTestDir, 'test_scalarmap.xml'))
-medcalc.RequestSALOMETermination() # not equivalent to quit()!
+medcalc.RequestSALOMETermination() # not equivalent to quit()!
--- /dev/null
+# 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
+
+# === GUI ===
+
+def GetScriptDirGUI():
+ relativeDir = "@SALOME_INSTALL_PYTHON@/tests/gui"
+ return os.path.join(__getRootDir(), relativeDir)
+
+def GetScenarioDirGUI():
+ relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/gui/scenarios"
+ return os.path.join(__getRootDir(), relativeDir)
+
+def GetBaselineDirGUI():
+ relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/gui/baselines"
+ return os.path.join(__getRootDir(), relativeDir)
+
+def GetMEDFileDirGUI():
+ relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/gui/medfiles"
+ return os.path.join(__getRootDir(), relativeDir)
+
+# === TUI ===
+
+def GetMEDFileDirTUI():
+ relativeDir = "@SALOME_MED_INSTALL_RES_DATA@/tests/tui/medfiles"
+ return os.path.join(__getRootDir(), relativeDir)
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+INCLUDE(tests.set)
+
+SET(_test_files
+ medfiles/smooth_surface_and_field.med
+)
+
SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc/tui)
+
+FOREACH(tfile ${TEST_NAMES})
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py
+ DESTINATION ${TEST_INSTALL_DIRECTORY})
+ENDFOREACH()
+
INSTALL(FILES CTestTestfileInstall.cmake
DESTINATION ${TEST_INSTALL_DIRECTORY}
RENAME CTestTestfile.cmake)
+
+INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES ${_test_files} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/tui/medfiles)
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+
+INCLUDE(tests.set)
+
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDFOREACH()
--- /dev/null
+# Copyright (C) 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 medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+
+from medcalc.medconsole import saveWorkspace, cleanWorkspace
+from medcalc.medconsole import putInWorkspace, removeFromWorkspace
+from medcalc.medconsole import accessField
+from medcalc.medconsole import getEnvironment, ls, la
--- /dev/null
+# Copyright (C) 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 pvsimple as pvs
--- /dev/null
+# Copyright (C) 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 medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+
+from medcalc.medconsole import saveWorkspace, cleanWorkspace
+from medcalc.medconsole import putInWorkspace, removeFromWorkspace
+from medcalc.medconsole import accessField
+from medcalc.medconsole import getEnvironment, ls, la
+
+import os
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med")
+source_id = medcalc.LoadDataSource(datafile)
--- /dev/null
+# Copyright (C) 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 medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+
+from medcalc.medconsole import saveWorkspace, cleanWorkspace
+from medcalc.medconsole import putInWorkspace, removeFromWorkspace
+from medcalc.medconsole import accessField
+from medcalc.medconsole import getEnvironment, ls, la
+
+import os
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med")
+source_id = medcalc.LoadDataSource(datafile)
+
+presentation_id = medcalc.MakeScalarMap(accessField(source_id), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
+
+medcalc.RemovePresentation(presentation_id)
--- /dev/null
+# Copyright (C) 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
+#
+
+SET(TEST_NAMES
+ access_API
+ load_file
+ import_pvsimple
+# scalar_map
+)