From 121e4ddec8ca5bea8aa45741774cb4bf5c8b5910 Mon Sep 17 00:00:00 2001 From: mkr Date: Thu, 18 Sep 2008 13:08:52 +0000 Subject: [PATCH] TestRecorder support. --- adm_local/unix/config_files/Makefile.am | 3 +- .../unix/config_files/check_TestRecorder.m4 | 101 ++++++++++++++++++ configure.ac | 2 +- src/SUIT/Makefile.am | 12 +++ src/SUIT/SUIT_ExceptionHandler.cxx | 9 ++ src/SUITApp/Makefile.am | 21 ++++ src/SUITApp/SUITApp_Application.cxx | 16 ++- src/SUITApp/SUITApp_Application.h | 12 ++- src/Session/Makefile.am | 14 +++ src/Session/SALOME_Session_Server.cxx | 19 +++- 10 files changed, 202 insertions(+), 7 deletions(-) create mode 100644 adm_local/unix/config_files/check_TestRecorder.m4 diff --git a/adm_local/unix/config_files/Makefile.am b/adm_local/unix/config_files/Makefile.am index 3b4c5acd9..e0847b3c1 100644 --- a/adm_local/unix/config_files/Makefile.am +++ b/adm_local/unix/config_files/Makefile.am @@ -36,4 +36,5 @@ check_SupervGraphViewer.m4 \ check_vtk.m4 \ check_VTKViewer.m4 \ check_corba_in_GUI.m4 \ -check_QxGraphViewer.m4 +check_QxGraphViewer.m4 \ +check_TestRecorder.m4 diff --git a/adm_local/unix/config_files/check_TestRecorder.m4 b/adm_local/unix/config_files/check_TestRecorder.m4 new file mode 100644 index 000000000..c98bf6488 --- /dev/null +++ b/adm_local/unix/config_files/check_TestRecorder.m4 @@ -0,0 +1,101 @@ +# +# Check existence of Test recorder sources and libraries. +# Set DISABLE_TESTRECORDER to yes|no +# +# Author : Margarita KARPUNINA (OCN, 2008) +# + +AC_DEFUN([CHECK_TESTRECORDER],[ + +AC_ARG_WITH(testrecorder, + [ --with-testrecorder=DIR root directory path of TestRecorder installation], + [], + [with_testrecorder=no]) + +AS_IF([test "x$with_testrecorder" != xno || test "$with_testrecorder" != "no"],[ + + echo + echo --------------------------------------------- + echo Testing TestRecorder + echo --------------------------------------------- + echo + + AC_REQUIRE([CHECK_QT])dnl + AC_REQUIRE([AC_PROG_CXX])dnl + AC_REQUIRE([AC_PROG_CXXCPP])dnl + + AC_CHECKING(for TestRecorder product) + + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + + TESTRECORDER_INCLUDES="" + TESTRECORDER_LIBS="" + DISABLE_TESTRECORDER="yes" + + TestRecorder_ok=no + + if test "$with_testrecorder" == "yes" || test "$with_testrecorder" == "auto"; then + TESTRECORDER_HOME="" + else + TESTRECORDER_HOME="$with_testrecorder" + fi + + if test "$TESTRECORDER_HOME" == "" ; then + if test "x$TESTRECORDERHOME" != "x" ; then + TESTRECORDER_HOME=$TESTRECORDERHOME + fi + fi + + if test "x$TESTRECORDER_HOME" != "x"; then + TESTRECORDER_INCLUDES="-I$TESTRECORDER_HOME" + TESTRECORDER_LIBS="-L$TESTRECORDER_HOME/lib -lTestRecorder" + + CPPFLAGS_old="$CPPFLAGS" + CXXFLAGS_old="$CXXFLAGS" + CPPFLAGS="$TESTRECORDER_INCLUDES $QT_INLCUDES $CPPFLAGS" + CXXFLAGS="$TESTRECORDER_INCLUDES $QT_INCLUDES $CXXFLAGS" + + AC_MSG_CHECKING(for TestRecorder header file) + + AC_CHECK_HEADER(TestApplication.h,TestRecorder_ok=yes,TestRecorder_ok=no) + + if test "x$TestRecorder_ok" == "xyes"; then + + AC_MSG_CHECKING(for TestRecorder library) + + LDFLAGS_old="$LDFLAGS" + LDFLAGS="-L. -$TESTRECORDER_LIBS $QT_LIBS $LDFLAGS" + + AC_TRY_LINK( + #include "TestApplication.h", + TESTRECORDER_init();, + TestRecorder_ok=yes,TestRecorder_ok=no + ) + + LDFLAGS="$LDFLAGS_old" + + AC_MSG_RESULT($TestRecorder_ok) + fi + + CPPFLAGS="$CPPFLAGS_old" + CXXFLAGS="$CXXFLAGS_old" + + fi + + if test "x$TestRecorder_ok" == xno ; then + AC_MSG_RESULT(for TestRecorder: no) + AC_MSG_WARN(TestRecorder is not found or not properly installed) + else + AC_MSG_RESULT(for TestRecorder: yes) + DISABLE_TESTRECORDER="no" + fi + + AC_SUBST(TESTRECORDER_INCLUDES) + AC_SUBST(TESTRECORDER_LIBS) + + AC_LANG_RESTORE + + ]) + +])dnl diff --git a/configure.ac b/configure.ac index 73ae8e165..4d86c95fa 100644 --- a/configure.ac +++ b/configure.ac @@ -524,7 +524,7 @@ do done echo "---Optional:" -variables="cppunit_ok TESTRECORDER_ok" +variables="cppunit_ok TestRecorder_ok" for var in $variables do diff --git a/src/SUIT/Makefile.am b/src/SUIT/Makefile.am index 4c5ce056d..0e3d53627 100755 --- a/src/SUIT/Makefile.am +++ b/src/SUIT/Makefile.am @@ -117,5 +117,17 @@ nodist_salomeres_DATA = \ SUIT_msg_en.qm libsuit_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../Qtx -I$(srcdir)/../ObjBrowser + +if ENABLE_TESTRECORDER + libsuit_la_CPPFLAGS+= $(TESTRECORDER_INCLUDES) +else !ENABLE_TESTRECORDER + libsuit_la_CPPFLAGS+= -DDISABLE_TESTRECORDER +endif + libsuit_la_LDFLAGS = $(QT_MT_LIBS) + +if ENABLE_TESTRECORDER + libsuit_la_LDFLAGS+= $(TESTRECORDER_LIBS) +endif + libsuit_la_LIBADD = ../Qtx/libqtx.la ../ObjBrowser/libObjBrowser.la diff --git a/src/SUIT/SUIT_ExceptionHandler.cxx b/src/SUIT/SUIT_ExceptionHandler.cxx index 861fdcf2c..babe67e69 100755 --- a/src/SUIT/SUIT_ExceptionHandler.cxx +++ b/src/SUIT/SUIT_ExceptionHandler.cxx @@ -20,6 +20,10 @@ #include "SUIT_MessageBox.h" +#ifndef DISABLE_TESTRECORDER + #include +#endif + #include /*!\class SUIT_ExceptionHandler @@ -39,7 +43,12 @@ bool SUIT_ExceptionHandler::handle( QObject* o, QEvent* e ) */ bool SUIT_ExceptionHandler::internalHandle( QObject* o, QEvent* e ) { +#ifndef DISABLE_TESTRECORDER + TestApplication* aTApp = qobject_cast(qApp); + return aTApp ? aTApp->TestApplication::notify( o, e ) : false; +#else return qApp ? qApp->QApplication::notify( o, e ) : false; +#endif } /*! diff --git a/src/SUITApp/Makefile.am b/src/SUITApp/Makefile.am index 2f8448a8e..1e1b85582 100644 --- a/src/SUITApp/Makefile.am +++ b/src/SUITApp/Makefile.am @@ -42,7 +42,18 @@ nodist_salomeres_DATA = SUITApp_msg_en.qm libSUITApp_la_CPPFLAGS = $(QT_INCLUDES) $(PYTHON_INCLUDES) \ -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../Style +if ENABLE_TESTRECORDER + libSUITApp_la_CPPFLAGS+= $(TESTRECORDER_INCLUDES) +else !ENABLE_TESTRECORDER + libSUITApp_la_CPPFLAGS+= -DDISABLE_TESTRECORDER +endif + libSUITApp_la_LDFLAGS = $(QT_MT_LIBS) + +if ENABLE_TESTRECORDER + libSUITApp_la_LDFLAGS+= $(TESTRECORDER_LIBS) +endif + libSUITApp_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../Style/libSalomeStyle.la if ENABLE_PYCONSOLE @@ -57,4 +68,14 @@ dist_SUITApp_SOURCES = SUITApp.cxx SUITApp_CPPFLAGS = $(QT_INCLUDES) $(PYTHON_INCLUDES) \ -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../Style +if ENABLE_TESTRECORDER + SUITApp_CPPFLAGS+= $(TESTRECORDER_INCLUDES) +else !ENABLE_TESTRECORDER + SUITApp_CPPFLAGS+= -DDISABLE_TESTRECORDER +endif + SUITApp_LDADD = libSUITApp.la ../Qtx/libqtx.la ../SUIT/libsuit.la ../Style/libSalomeStyle.la + +if ENABLE_TESTRECORDER + SUITApp_LDADD+= $(TESTRECORDER_LIBS) +endif diff --git a/src/SUITApp/SUITApp_Application.cxx b/src/SUITApp/SUITApp_Application.cxx index 7027184df..df551d580 100644 --- a/src/SUITApp/SUITApp_Application.cxx +++ b/src/SUITApp/SUITApp_Application.cxx @@ -35,7 +35,11 @@ Constructor */ SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand ) -: QApplication( argc, argv ), +#ifndef DISABLE_TESTRECORDER + : TestApplication( argc, argv ), +#else + : QApplication( argc, argv ), +#endif myExceptHandler( hand ) { QString path = SUIT_Tools::dir( argv[0] ) + QDir::separator() + "../../resources"; @@ -52,7 +56,11 @@ myExceptHandler( hand ) Constructor */ SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand ) -: QApplication( argc, argv, type ), +#ifndef DISABLE_TESTRECORDER + : TestApplication( argc, argv ), +#else + : QApplication( argc, argv, type ), +#endif myExceptHandler( hand ) { QTranslator* strTbl = new QTranslator( 0 ); @@ -69,7 +77,11 @@ myExceptHandler( hand ) bool SUITApp_Application::notify( QObject* receiver, QEvent* e ) { return myExceptHandler ? myExceptHandler->handle( receiver, e ) : +#ifndef DISABLE_TESTRECORDER + TestApplication::notify( receiver, e ); +#else QApplication::notify( receiver, e ); +#endif } /*! diff --git a/src/SUITApp/SUITApp_Application.h b/src/SUITApp/SUITApp_Application.h index 808e464cc..bb27322b5 100644 --- a/src/SUITApp/SUITApp_Application.h +++ b/src/SUITApp/SUITApp_Application.h @@ -19,11 +19,19 @@ #ifndef SUITAPP_APPLICATION_H #define SUITAPP_APPLICATION_H -#include +#ifndef DISABLE_TESTRECORDER + #include +#else + #include +#endif class SUIT_ExceptionHandler; -class SUITApp_Application : public QApplication +#ifndef DISABLE_TESTRECORDER + class SUITApp_Application : public TestApplication +#else + class SUITApp_Application : public QApplication +#endif { Q_OBJECT diff --git a/src/Session/Makefile.am b/src/Session/Makefile.am index b6b196500..781aedd20 100755 --- a/src/Session/Makefile.am +++ b/src/Session/Makefile.am @@ -54,12 +54,22 @@ libSalomeSession_la_CPPFLAGS = $(QT_MT_INCLUDES) $(PYTHON_INCLUDES) \ -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT -I$(srcdir)/../Event \ -I$(srcdir)/../Style @LIBXML_INCLUDES@ +if ENABLE_TESTRECORDER + libSalomeSession_la_CPPFLAGS+= $(TESTRECORDER_INCLUDES) +else !ENABLE_TESTRECORDER + libSalomeSession_la_CPPFLAGS+= -DDISABLE_TESTRECORDER +endif + libSalomeSession_la_LDFLAGS = $(QT_MT_LIBS) $(KERNEL_LDFLAGS) -lSalomeNS \ -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace -lSalomeCatalog \ -lSalomeDSClient $(CAS_KERNEL) -lwith_loggerTraceCollector \ ../SUIT/libsuit.la ../Event/libEvent.la ../../idl/libSalomeIDLGUI.la \ ../Style/libSalomeStyle.la +if ENABLE_TESTRECORDER + libSalomeSession_la_LDFLAGS+= $(TESTRECORDER_LIBS) +endif + # Executable bin_PROGRAMS = SALOME_Session_Server @@ -72,3 +82,7 @@ SALOME_Session_Server_LDADD = $(libSalomeSession_la_LDFLAGS) $(OMNIORB_LIBS) -lSalomeNotification -lSALOMEBasics -lSalomeLauncher ../Qtx/libqtx.la \ $(top_builddir)/idl/libSalomeIDLGUI.la \ libSalomeSession.la + +if ENABLE_TESTRECORDER + SALOME_Session_Server_LDADD+= $(TESTRECORDER_LIBS) +endif diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 9ddfbd8f8..18365ce9f 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -35,6 +35,10 @@ #include #include +#ifndef DISABLE_TESTRECORDER + #include +#endif + #include #include #include @@ -245,10 +249,18 @@ protected: } }; -class SALOME_QApplication : public QApplication +#ifndef DISABLE_TESTRECORDER + class SALOME_QApplication : public TestApplication +#else + class SALOME_QApplication : public QApplication +#endif { public: +#ifndef DISABLE_TESTRECORDER + SALOME_QApplication( int& argc, char** argv ) : TestApplication( argc, argv ), myHandler ( 0 ) {} +#else SALOME_QApplication( int& argc, char** argv ) : QApplication( argc, argv ), myHandler ( 0 ) {} +#endif virtual bool notify( QObject* receiver, QEvent* e ) { @@ -266,8 +278,13 @@ public: } #endif +#ifndef DISABLE_TESTRECORDER + return myHandler ? myHandler->handle( receiver, e ) : + TestApplication::notify( receiver, e ); +#else return myHandler ? myHandler->handle( receiver, e ) : QApplication::notify( receiver, e ); +#endif } SUIT_ExceptionHandler* handler() const { return myHandler; } void setHandler( SUIT_ExceptionHandler* h ) { myHandler = h; } -- 2.39.2