EVENT_ADD_DATASOURCE,
EVENT_ADD_PRESENTATION,
EVENT_PLAY_TEST,
+ EVENT_QUIT_SALOME,
EVENT_UNKNOWN
};
}
void
-MEDModule::onPlayTest(const char * filename)
+MEDModule::requestSALOMETermination() const
{
-
+ SUIT_Session::session()->closeSession( SUIT_Session::DONT_SAVE, 1 ); // killServers = True
}
inline SALOME_AppStudyEditor* getStudyEditor() { return _studyEditor; }
+ void requestSALOMETermination() const;
+
public slots:
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 TestController::onPlayTestScenario()
{
- STDLOG("@@@@ About to play test " << _test_scenario.toStdString());
+ STDLOG("About to play test " << _test_scenario.toStdString());
_tester->playTests(_test_scenario);
- STDLOG("@@@@ Done playing test " << _test_scenario.toStdString());
+ STDLOG("Done playing test " << _test_scenario.toStdString());
}
void TestController::onLockViewSize()
pqSaveScreenshotReaction::saveScreenshot();
}
+void TestController::onRequestTermination()
+{
+ // Check if test playing
+ if (_tester->playingTest())
+ {
+ STDLOG("Termination requested, but test still playing ...");
+ QTimer::singleShot(200, this, SLOT(onRequestTermination()));
+ }
+ else
+ {
+ _salomeModule->requestSALOMETermination();
+ }
+}
+
+
void
TestController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
{
_test_scenario = QString(event->filename);
QTimer::singleShot(100, this, SLOT(onPlayTestScenario()));
}
+ else if ( event->type == MEDCALC::EVENT_QUIT_SALOME ) {
+ // [ABN] again: post as an event to give a chance to other events (piled up by test
+ // scenarios for example) to execute:
+ QTimer::singleShot(200, this, SLOT(onRequestTermination()));
+ }
}
void onPlayTestScenario();
void onLockViewSize();
void onTakeSnapshot();
+ void onRequestTermination();
protected:
MEDModule* _salomeModule;
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
+#include <QTimer>
+
/*!
* This class defines a DockWidget plugged in the SALOME application,
* and containing a tree view for rendering a hierarchical data
else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
emit workspaceSignal(event); // forward to TestController
}
-
+ else if ( event->type == MEDCALC::EVENT_QUIT_SALOME ) {
+ emit workspaceSignal(event); // forward to TestController
+ }
}
/*!
void OnSaveWorkspace();
void OnCleanWorkspace();
+ void onRequestTermination();
+
signals:
void workspaceSignal(const MEDCALC::MedEvent* event);
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})
def tearDown(self):
import shutil
unittest.TestCase.tearDown(self)
-# if self._removeDir:
-# shutil.rmtree(self._tmpDir, False)
+ if self._removeDir:
+ shutil.rmtree(self._tmpDir, False)
def getTestName(self):
""" Return name of the test being currently executed. """
baseline = "test_scalarmap.png"
self.launchSalomeWithScript("test_scalarmap.py", baseline)
self.compareSnapshot(baseline)
-
+
+
if __name__ == "__main__":
suite = unittest.TestSuite()
suite.addTest(MEDGUITest('testScalarMap'))
import medcalc # After module activation !!
medcalc.PlayQtTestingScenario(os.path.join(GetScenarioDir(), 'test_scalarmap.xml'))
-#medcalc.RequestTermination()
-#quit()
+medcalc.RequestSALOMETermination() # not equivalent to quit()!
# Playing test scenarii
from medtest import PlayQtTestingScenario
+from medtest import RequestSALOMETermination
#
def notifyGui_playQtTestingScenario(filename):
__notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
+#
+def notifyGui_termination():
+ __notifyGui(MEDCALC.EVENT_QUIT_SALOME)
+
def PlayQtTestingScenario(filename):
from medcalc.medevents import notifyGui_playQtTestingScenario
notifyGui_playQtTestingScenario(filename)
+
+def RequestSALOMETermination():
+ from medcalc.medevents import notifyGui_termination
+ notifyGui_termination()