INCLUDE(CMakeDependentOption)
OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
OPTION(SALOME_MED_WITH_FILE_EXAMPLES "Install examples of files containing meshes and fields of different formats." ON)
+OPTION(SALOME_MED_WITH_QTTESTING "Build MED with QtTesting support." OFF)
OPTION(SALOME_USE_MPI "(Use MPI containers) - For MED this triggers the build of ParaMEDMEM." ${_default_MPI})
OPTION(SALOME_BUILD_GUI "Build GUI of MED." ON)
OPTION(SALOME_BUILD_TESTS "Build MED tests." ON)
EVENT_CLEAN_WORKSPACE,
EVENT_ADD_DATASOURCE,
EVENT_ADD_PRESENTATION,
+ EVENT_PLAY_TEST,
EVENT_UNKNOWN
};
# 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()
+
ADD_DEFINITIONS(${MEDFILE_DEFINITIONS} ${XDR_DEFINITIONS} ${OMNIORB_DEFINITIONS})
SET(QT_LIBS "${QT_LIBRARIES}")
INCLUDE(UseQtExt)
ADD_SUBDIRECTORY(dialogs)
+SET(MEDCALCGUI_SOURCES
+ DatasourceController.cxx
+ factory.cxx
+ MEDEventListener_i.cxx
+ MEDModule.cxx
+ PresentationController.cxx
+ ProcessingController.cxx
+ WorkspaceController.cxx
+ XmedConsoleDriver.cxx
+ XmedDataModel.cxx
+)
-FILE(GLOB MEDCALCGUI_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx")
+IF(SALOME_MED_WITH_QTTESTING)
+ LIST(APPEND MEDCALCGUI_SOURCES TestController.cxx)
+ENDIF()
SET(MEDCALCGUI_HEADERS
MEDModule.hxx
PresentationController.hxx
ProcessingController.hxx
)
-QT_WRAP_MOC(MEDCALCGUI_HEADERS_MOC ${MEDCALCGUI_HEADERS})
+
+IF(SALOME_MED_WITH_QTTESTING)
+ LIST(APPEND MEDCALCGUI_HEADERS TestController.hxx)
+ENDIF()
+QT_WRAP_MOC(MEDCALCGUI_HEADERS_MOC ${MEDCALCGUI_HEADERS})
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR} ${OMNIORB_INCLUDE_DIRS}
MEDCALC_msg_ja.ts
)
-SET(COMMON_FLAGS
+SET(link_libraries
${QT_MT_LIBRARIES}
${OMNIORB_LIBRARIES}
${PLATFORM_LIBRARIES}
${MEDCoupling_medcouplingremapper}
)
+IF(SALOME_MED_WITH_QTTESTING)
+ LIST(APPEND link_libraries QtTesting) # from ParaView
+ENDIF()
+
ADD_LIBRARY(MEDCALCGUI SHARED ${MEDCALCGUI_SOURCES} ${MEDCALCGUI_HEADERS_MOC})
IF(WITH_MEDMEMGUI)
SET_TARGET_PROPERTIES(MEDCALCGUI PROPERTIES COMPILE_FLAGS "-D__WITH_MEDMEMGUI__")
ENDIF(WITH_MEDMEMGUI)
-TARGET_LINK_LIBRARIES(MEDCALCGUI ${COMMON_FLAGS})
+TARGET_LINK_LIBRARIES(MEDCALCGUI ${link_libraries})
INSTALL(TARGETS MEDCALCGUI DESTINATION ${SALOME_INSTALL_LIBS})
QT_INSTALL_TS_RESOURCES("${MEDCALCGUITS_SOURCES}" "${SALOME_MED_INSTALL_RES_DATA}")
#include <QStringList>
#include <QString>
#include <QMessageBox>
+#include <QFileDialog>
#include "DlgAlias.hxx"
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
anInitialPath = QDir::currentPath();
- QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(),
+// QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(),
+// anInitialPath,
+// filter,
+// tr("IMPORT_MED_FIELDS") );
+ // [ABN] the below to be compatible with QtTesting:
+ QStringList filenames = QFileDialog::getOpenFileNames( _salomeModule->getApp()->desktop(),
+ tr("IMPORT_MED_FIELDS"),
anInitialPath,
- filter,
- tr("IMPORT_MED_FIELDS") );
+ tr("FILE_FILTER_MED") );
if ( filenames.count() <= 0 ) return;
for ( QStringList::ConstIterator itFile = filenames.begin();
_workspaceController->setDataModel(_xmedDataModel);
_presentationController = new PresentationController(this);
_processingController = new ProcessingController(this);
+#ifdef MED_HAS_QTTESTING
+ _testController = new TestController(this);
+#endif
connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent*)),
_workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent*)));
connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
_presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
+
+#ifdef MED_HAS_QTTESTING
+ connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
+ _testController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
+#endif
}
void
_workspaceController->createActions();
_presentationController->createActions();
_processingController->createActions();
+#ifdef MED_HAS_QTTESTING
+ _testController->createActions();
+#endif
}
int
if ( effToolTip.isEmpty() )
effToolTip = label;
+ QIcon ico;
+ if (iconName.isEmpty())
+ ico = QIcon();
+ else
+ ico = QIcon(resMgr->loadPixmap("MED", iconName));
+
QAction* action = createAction(-1,
label,
- resMgr->loadPixmap("MED", iconName),
+ ico,
label,
effToolTip,
0,
STDLOG(" - Presentation name: " + name);
}
+
+void
+MEDModule::onPlayTest(const char * filename)
+{
+
+}
#include "DatasourceController.hxx"
#include "PresentationController.hxx"
#include "ProcessingController.hxx"
+#include "TestController.hxx"
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(MED_Gen)
virtual bool activateModule(SUIT_Study* theStudy);
virtual bool deactivateModule(SUIT_Study* theStudy);
virtual void onDblClick(const QModelIndex& index);
+ virtual void onPlayTest(const char * filename);
private:
void createModuleWidgets();
void createModuleActions();
+
static void init();
private:
XmedDataModel* _xmedDataModel;
PresentationController* _presentationController;
ProcessingController* _processingController;
+#ifdef MED_HAS_QTTESTING
+ TestController * _testController;
+#endif
static MED_ORB::MED_Gen_var myEngine;
};
</message>
<message>
<source>LAB_BLUE_TO_RED</source>
- <translation>Arc-en-ciel blue vers rouge</translation>
+ <translation>Arc-en-ciel bleu vers rouge</translation>
</message>
<message>
<source>LAB_COOL_TO_WARM</source>
--- /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
+//
+
+#include "TestController.hxx"
+#include "MEDModule.hxx"
+
+#include <Basics_Utils.hxx> // STDLOG() macro
+
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(MEDEventListener)
+
+#include <pqTestUtility.h>
+#include <pqXMLEventObserver.h>
+#include <pqXMLEventSource.h>
+
+#include <pqQVTKWidgetEventPlayer.h>
+#include <pqQVTKWidgetEventTranslator.h>
+
+#include <pqTabbedMultiViewWidget.h>
+#include <pqApplicationCore.h>
+#include <pqTestingReaction.h>
+#include <pqSaveScreenshotReaction.h>
+
+#include <QFileDialog>
+#include <QString>
+#include <QDir>
+#include <QIcon>
+#include <QTimer>
+
+TestController::TestController(MEDModule* mod):
+ _salomeModule(mod),
+ _desk(SUIT_Session::session()->activeApplication()->desktop()),
+ _tester(0), _lock_action(0)
+{
+ STDLOG("Creating a TestController");
+ _tester = new pqTestUtility(_desk);
+ _tester->addEventObserver("xml", new pqXMLEventObserver(_desk));
+ _tester->addEventSource("xml", new pqXMLEventSource(_desk));
+}
+
+TestController::~TestController()
+{
+ if (_tester)
+ delete _tester;
+ _tester = 0;
+}
+
+void
+TestController::createActions() {
+ //
+ // Main actions
+ //
+ QString label = tr("LAB_RECORD_TEST");
+ QString tooltip = tr("TIP_RECORD_TEST");
+ int actionId;
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(onRecordTest()),QString(),tooltip);
+
+ // This action has to be placed in the general file menu
+ int menuId = _salomeModule->createMenu( tr( "MEN_FILE" ), -1, 1 );
+ _salomeModule->action(actionId)->setIconVisibleInMenu(false);
+ _salomeModule->createMenu(actionId, menuId, 60);
+
+ label = tr("LAB_PLAY_TEST");
+ tooltip = tr("TIP_PLAY_TEST");
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(onPlayTest()),QString(),tooltip);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(false);
+ _salomeModule->createMenu(actionId, menuId, 70);
+
+ label = tr("LAB_LOCK_TEST");
+ tooltip = tr("TIP_LOCK_TEST");
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(onLockViewSize()),QString(),tooltip);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(false);
+ _salomeModule->action(actionId)->setCheckable(true);
+ _lock_action = _salomeModule->action(actionId);
+ _salomeModule->createMenu(actionId, menuId, 70);
+
+ label = tr("LAB_SNAP_TEST");
+ tooltip = tr("TIP_SNAP_TEST");
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(onTakeSnapshot()),QString(),tooltip);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(false);
+ _salomeModule->createMenu(actionId, menuId, 70);
+}
+
+void TestController::onRecordTest()
+{
+ QString fileName =
+ QFileDialog::getSaveFileName(_desk, "Save test", QString(), QString("XML file (*.xml)"));
+ if (!fileName.isEmpty())
+ {
+ QApplication::setActiveWindow(_desk); //mandatory otherwise record pop up doesn't show up
+ _tester->recordTests(fileName);
+ }
+}
+
+
+void TestController::onPlayTest()
+{
+ QString fileName =
+ QFileDialog::getOpenFileName(_desk, "Open test", QString(), QString("XML file (*.xml)"));
+ if (!fileName.isEmpty())
+ _tester->playTests(fileName);
+}
+
+void TestController::onPlayTestScenario()
+{
+ STDLOG("@@@@ About to play test " << _test_scenario.toStdString());
+ _tester->playTests(_test_scenario);
+ STDLOG("@@@@ Done playing test " << _test_scenario.toStdString());
+}
+
+void TestController::onLockViewSize()
+{
+ pqTestingReaction::lockViewSize(_lock_action->isChecked());
+}
+
+void TestController::onTakeSnapshot()
+{
+ pqSaveScreenshotReaction::saveScreenshot();
+}
+
+void
+TestController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
+{
+ if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
+ /* [ABN] Post an event. Indeed, calling the function directly would prevent the proper refresh of the
+ * GUI which also needs to go through the MED event loop (WorkspaceController::processWorkspaceEvent)
+ */
+ _test_scenario = QString(event->filename);
+ QTimer::singleShot(100, this, SLOT(onPlayTestScenario()));
+ }
+}
+
--- /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
+//
+
+#ifndef SRC_MEDCALC_GUI_TESTCONTROLLER_HXX_
+#define SRC_MEDCALC_GUI_TESTCONTROLLER_HXX_
+
+#include <QObject>
+#include <QString>
+
+class pqTestUtility;
+class MEDModule;
+class SUIT_Desktop;
+class QAction;
+namespace MEDCALC {
+ class MedEvent;
+};
+
+class TestController: public QObject {
+ Q_OBJECT
+
+public:
+ TestController(MEDModule* mod);
+ virtual ~TestController();
+
+ void createActions();
+
+public slots:
+ void processWorkspaceEvent(const MEDCALC::MedEvent* event);
+
+ void onRecordTest();
+ void onPlayTest();
+ void onPlayTestScenario();
+ void onLockViewSize();
+ void onTakeSnapshot();
+
+protected:
+ MEDModule* _salomeModule;
+ SUIT_Desktop * _desk;
+
+ pqTestUtility * _tester;
+ QAction * _lock_action;
+ QString _test_scenario;
+};
+
+#endif /* SRC_MEDCALC_GUI_TESTCONTROLLER_HXX_ */
else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
emit workspaceSignal(event); // forward to DatasourceController
}
+ else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
+ emit workspaceSignal(event); // forward to TestController
+ }
}
class WidgetPresentationParameters : public QWidget
{
Q_OBJECT
+
public:
WidgetPresentationParameters(QWidget* parent = 0);
virtual ~WidgetPresentationParameters() {}
--- /dev/null
+# 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
+)
+
+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)
+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.
--- /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"
+ 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)
--- /dev/null
+<?xml version="1.0" ?>
+<pqevents>
+ <pqevent object="1STD_TabDesktop0/1QMenuBar0" command="activate" arguments="Fic&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&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>
--- /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
+#
+# 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)
+
--- /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
+#
+
+""" 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.RequestTermination()
+#quit()
medimages.py
medio.py
medpresentation.py
+ medtest.py
)
SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON}/medcalc)
# Console commands
import medconsole
+
+# Playing test scenarii
+from medtest import PlayQtTestingScenario
+
def notifyGui_addPresentation(fieldId, presId):
__notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, dataId=fieldId, presentationId=presId)
#
+def notifyGui_playQtTestingScenario(filename):
+ __notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
--- /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
+#
+
+def PlayQtTestingScenario(filename):
+ from medcalc.medevents import notifyGui_playQtTestingScenario
+ notifyGui_playQtTestingScenario(filename)