Salome HOME
Porting to Qt 5
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_Main.cxx
index 5b1367cbd1f5020e586b10b1f8014ea601d5e5d6..90a5559e02701917a02d36dee560a84d8a7e8562 100644 (file)
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/TestResult.h>
 #include <cppunit/TestResultCollector.h>
-#include <cppunit/TestRunner.h>
-#include <cppunit/TextTestProgressListener.h>
 #include <stdexcept>
 #include <TestViewer.h>
+#include <TestLib_Listener.h>
+#include <TestLib_Runner.h>
 #include <OCCViewer_ViewWindow.h>
 #include <SUIT_Session.h>
 #include <QApplication>
 #include <QColor>
-#include <time.h>
+#include <QTest>
 
 int main( int argc, char* argv[] )
 {
-  srand( time( 0 ) );
-
   QApplication anApp( argc, argv );
   SUIT_Session aSession;
 
   OCCViewer_ViewWindow* aWindow = TestViewer::viewWindow();
-  aWindow->setGeometry( 200, 200, 800, 600 );
+
+  int W = 800, H = 600;
+  aWindow->setGeometry( 200, 200, W, H );
   aWindow->show();
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+  QTest::qWaitForWindowShown( aWindow );
+#else
+  QTest::qWaitForWindowExposed( aWindow );
+#endif
+
+  int dy = 34;
+  //std::cout << dx << "," << dy << std::endl;
+  aWindow->resize( W, H+dy );
+  anApp.processEvents();
 
   std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
 
@@ -51,18 +61,20 @@ int main( int argc, char* argv[] )
   controller.addListener( &result );        
 
   // Add a listener that print dots as test run.
-  CppUnit::TextTestProgressListener progress;
+  TestLib_Listener progress;
   controller.addListener( &progress );      
 
   CppUnit::TestFactoryRegistry& registry = 
     CppUnit::TestFactoryRegistry::getRegistry();
   // Add the top suite to the test runner
-  CppUnit::TestRunner runner;
+  TestLib_Runner runner;
+  QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg";
+  runner.Load( aPath.toStdString() );
   runner.addTest( registry.makeTest() );   
   try
   {
-    std::cout << "Running "  <<  testPath;
-    runner.run( controller, testPath );
+    std::cout << "Running tests "  << testPath << "..." << std::endl;
+    runner.Run( controller );
 
     std::cerr << std::endl;