Salome HOME
copyrights in HYDRO files are updated
[modules/hydro.git] / src / HYDROGUI / test_HYDROGUI_Main.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <cppunit/extensions/TestFactoryRegistry.h>
24 #include <cppunit/CompilerOutputter.h>
25 #include <cppunit/TestResult.h>
26 #include <cppunit/TestResultCollector.h>
27 #include <cppunit/TestRunner.h>
28 #include <cppunit/TextTestProgressListener.h>
29 #include <stdexcept>
30 #include <QApplication>
31
32 int main( int argc, char* argv[] )
33 {
34   QApplication anApp( argc, argv );
35
36   std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
37
38   // Create the event manager and test controller
39   CppUnit::TestResult controller;
40
41   // Add a listener that colllects test result
42   CppUnit::TestResultCollector result;
43   controller.addListener( &result );        
44
45   // Add a listener that print dots as test run.
46   CppUnit::TextTestProgressListener progress;
47   controller.addListener( &progress );      
48
49   CppUnit::TestFactoryRegistry& registry = 
50     CppUnit::TestFactoryRegistry::getRegistry();
51   // Add the top suite to the test runner
52   CppUnit::TestRunner runner;
53   runner.addTest( registry.makeTest() );   
54   try
55   {
56     std::cout << "Running "  <<  testPath;
57     runner.run( controller, testPath );
58
59     std::cerr << std::endl;
60
61     // Print test in a compiler compatible format.
62     CppUnit::CompilerOutputter outputter( &result, std::cerr );
63     outputter.write();                      
64   }
65   catch ( std::invalid_argument &e )  // Test path not resolved
66   {
67     std::cerr  <<  std::endl  
68       <<  "ERROR: "  <<  e.what()
69       << std::endl;
70     return 0;
71   }
72
73   return result.wasSuccessful() ? 0 : 1;
74 }