From: abn Date: Tue, 12 Apr 2016 11:32:46 +0000 (+0200) Subject: Exit procedure added in tests. Not killing all servers yet. X-Git-Tag: V8_1_0b1~25^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cfc8c7584db03dc2a31d5df9aa87d2fa411b790a;p=modules%2Fmed.git Exit procedure added in tests. Not killing all servers yet. --- diff --git a/idl/MEDEventListener.idl b/idl/MEDEventListener.idl index 425238772..77fcc8fa3 100644 --- a/idl/MEDEventListener.idl +++ b/idl/MEDEventListener.idl @@ -35,6 +35,7 @@ module MEDCALC EVENT_ADD_DATASOURCE, EVENT_ADD_PRESENTATION, EVENT_PLAY_TEST, + EVENT_QUIT_SALOME, EVENT_UNKNOWN }; diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index b16f71dd2..b76c6ca87 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -368,7 +368,7 @@ MEDModule::onDblClick(const QModelIndex& index) } void -MEDModule::onPlayTest(const char * filename) +MEDModule::requestSALOMETermination() const { - + SUIT_Session::session()->closeSession( SUIT_Session::DONT_SAVE, 1 ); // killServers = True } diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index 819fd80b1..12017f7be 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -83,11 +83,12 @@ public: 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(); diff --git a/src/MEDCalc/gui/TestController.cxx b/src/MEDCalc/gui/TestController.cxx index 8023c6816..9f2bc8dbd 100644 --- a/src/MEDCalc/gui/TestController.cxx +++ b/src/MEDCalc/gui/TestController.cxx @@ -122,9 +122,9 @@ void TestController::onPlayTest() 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() @@ -137,6 +137,21 @@ void TestController::onTakeSnapshot() 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) { @@ -147,5 +162,10 @@ 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())); + } } diff --git a/src/MEDCalc/gui/TestController.hxx b/src/MEDCalc/gui/TestController.hxx index 5febf5275..7ce0b7bf3 100644 --- a/src/MEDCalc/gui/TestController.hxx +++ b/src/MEDCalc/gui/TestController.hxx @@ -48,6 +48,7 @@ public slots: void onPlayTestScenario(); void onLockViewSize(); void onTakeSnapshot(); + void onRequestTermination(); protected: MEDModule* _salomeModule; diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index 8b2c6a2fd..223eb7815 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -35,6 +35,8 @@ #include #include +#include + /*! * This class defines a DockWidget plugged in the SALOME application, * and containing a tree view for rendering a hierarchical data @@ -311,7 +313,9 @@ void WorkspaceController::processMedEvent(const MEDCALC::MedEvent* event) { 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 + } } /*! diff --git a/src/MEDCalc/gui/WorkspaceController.hxx b/src/MEDCalc/gui/WorkspaceController.hxx index 5c6960767..f85a068e4 100644 --- a/src/MEDCalc/gui/WorkspaceController.hxx +++ b/src/MEDCalc/gui/WorkspaceController.hxx @@ -65,6 +65,8 @@ public slots: void OnSaveWorkspace(); void OnCleanWorkspace(); + void onRequestTermination(); + signals: void workspaceSignal(const MEDCALC::MedEvent* event); diff --git a/src/MEDCalc/gui/test/CMakeLists.txt b/src/MEDCalc/gui/test/CMakeLists.txt index 0df51419e..c17548bd2 100644 --- a/src/MEDCalc/gui/test/CMakeLists.txt +++ b/src/MEDCalc/gui/test/CMakeLists.txt @@ -32,6 +32,10 @@ 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}) diff --git a/src/MEDCalc/gui/test/test_qttesting.py b/src/MEDCalc/gui/test/test_qttesting.py index 123812b8e..390afe5fe 100644 --- a/src/MEDCalc/gui/test/test_qttesting.py +++ b/src/MEDCalc/gui/test/test_qttesting.py @@ -35,8 +35,8 @@ class MEDGUITest(unittest.TestCase): 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. """ @@ -90,7 +90,8 @@ class MEDGUITest(unittest.TestCase): baseline = "test_scalarmap.png" self.launchSalomeWithScript("test_scalarmap.py", baseline) self.compareSnapshot(baseline) - + + if __name__ == "__main__": suite = unittest.TestSuite() suite.addTest(MEDGUITest('testScalarMap')) diff --git a/src/MEDCalc/gui/test/test_scalarmap.py b/src/MEDCalc/gui/test/test_scalarmap.py index a77762a27..ddf508ee3 100644 --- a/src/MEDCalc/gui/test/test_scalarmap.py +++ b/src/MEDCalc/gui/test/test_scalarmap.py @@ -33,5 +33,4 @@ sgPyQt.activateModule('MED') import medcalc # After module activation !! medcalc.PlayQtTestingScenario(os.path.join(GetScenarioDir(), 'test_scalarmap.xml')) -#medcalc.RequestTermination() -#quit() +medcalc.RequestSALOMETermination() # not equivalent to quit()! diff --git a/src/MEDCalc/tui/__init__.py b/src/MEDCalc/tui/__init__.py index c8e728a69..01f092cce 100644 --- a/src/MEDCalc/tui/__init__.py +++ b/src/MEDCalc/tui/__init__.py @@ -51,4 +51,5 @@ import medconsole # Playing test scenarii from medtest import PlayQtTestingScenario +from medtest import RequestSALOMETermination diff --git a/src/MEDCalc/tui/medevents.py b/src/MEDCalc/tui/medevents.py index c30db75b7..6c3c28d71 100644 --- a/src/MEDCalc/tui/medevents.py +++ b/src/MEDCalc/tui/medevents.py @@ -117,3 +117,7 @@ def notifyGui_addPresentation(fieldId, presId): # def notifyGui_playQtTestingScenario(filename): __notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename) +# +def notifyGui_termination(): + __notifyGui(MEDCALC.EVENT_QUIT_SALOME) + diff --git a/src/MEDCalc/tui/medtest.py b/src/MEDCalc/tui/medtest.py index 929dd67e8..cc389ae70 100644 --- a/src/MEDCalc/tui/medtest.py +++ b/src/MEDCalc/tui/medtest.py @@ -20,3 +20,7 @@ def PlayQtTestingScenario(filename): from medcalc.medevents import notifyGui_playQtTestingScenario notifyGui_playQtTestingScenario(filename) + +def RequestSALOMETermination(): + from medcalc.medevents import notifyGui_termination + notifyGui_termination()