]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Exit procedure added in tests. Not killing all servers yet.
authorabn <adrien.bruneton@cea.fr>
Tue, 12 Apr 2016 11:32:46 +0000 (13:32 +0200)
committerabn <adrien.bruneton@cea.fr>
Tue, 12 Apr 2016 11:32:46 +0000 (13:32 +0200)
13 files changed:
idl/MEDEventListener.idl
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/TestController.cxx
src/MEDCalc/gui/TestController.hxx
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/gui/WorkspaceController.hxx
src/MEDCalc/gui/test/CMakeLists.txt
src/MEDCalc/gui/test/test_qttesting.py
src/MEDCalc/gui/test/test_scalarmap.py
src/MEDCalc/tui/__init__.py
src/MEDCalc/tui/medevents.py
src/MEDCalc/tui/medtest.py

index 425238772f78ff2dd08e1ca3a7193bb586adca36..77fcc8fa3e114c33e2e6e2dfc475f35a7bb8147e 100644 (file)
@@ -35,6 +35,7 @@ module MEDCALC
     EVENT_ADD_DATASOURCE,
     EVENT_ADD_PRESENTATION,
     EVENT_PLAY_TEST,
+    EVENT_QUIT_SALOME,
     EVENT_UNKNOWN
   };
 
index b16f71dd2d7fb0b9bccf27a65f4c2588e82394fb..b76c6ca879ea7c0782b459c5a9511a057244311f 100644 (file)
@@ -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
 }
index 819fd80b10ec1cbaae13b99fc891afcea4f63d93..12017f7bea4e67d77f7f253cc2a57b1a54626353 100644 (file)
@@ -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();
index 8023c6816a8e77fcfc8251082586cd29916c3626..9f2bc8dbd4e4e2d3ebfc79f4a45c1e1280f6cad3 100644 (file)
@@ -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()));
+  }
 }
 
index 5febf5275ce8fcc237f91bfe02cf58b73b65ffa8..7ce0b7bf30be824382b350f9e3964ba0f7421635 100644 (file)
@@ -48,6 +48,7 @@ public slots:
   void onPlayTestScenario();
   void onLockViewSize();
   void onTakeSnapshot();
+  void onRequestTermination();
 
 protected:
   MEDModule* _salomeModule;
index 8b2c6a2fd2456c7bcc464d5f0986663533525853..223eb7815cdd525aee6819d6888d244ce77fea4f 100644 (file)
@@ -35,6 +35,8 @@
 #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
@@ -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
+  }
 }
 
 /*!
index 5c69607673f702dcbb5a80bcbdbf7ddf97c57871..f85a068e4b4f68939f83f069a3b3dad677838d89 100644 (file)
@@ -65,6 +65,8 @@ public slots:
   void OnSaveWorkspace();
   void OnCleanWorkspace();
 
+  void onRequestTermination();
+
 signals:
   void workspaceSignal(const MEDCALC::MedEvent* event);
 
index 0df51419e2659fb79970f454256725a2d5f9a854..c17548bd241d5451bf69bcebbc3c49386c29a6fc 100644 (file)
@@ -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})
  
index 123812b8e7b8aa2d9ad77c968c6d9d77cf01ef12..390afe5fe270a439af7cce5bff37a461b4828480 100644 (file)
@@ -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'))
index a77762a27958bf36720f5ec7b76f06db37ee5149..ddf508ee32f763cbe3b7dc66e73dfabac32dd034 100644 (file)
@@ -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()! 
index c8e728a69c73a318c2b423eb08ce2b4cd8cbc5b4..01f092cce296301d8fa98d5f873441563d2a96ca 100644 (file)
@@ -51,4 +51,5 @@ import medconsole
 
 # Playing test scenarii
 from medtest import PlayQtTestingScenario
+from medtest import RequestSALOMETermination
 
index c30db75b71947611fc1cb4219447fe0e10a29a3f..6c3c28d711802337e8fae9466598fe60fab78736 100644 (file)
@@ -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)
+
index 929dd67e8f7b12e17ee61b45bd23dfbc7b9e3be6..cc389ae70ae2840b66f1489d57947f7018addfd9 100644 (file)
@@ -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()