From 30ec4fa63f89c37763a7f2b82a9c4afe272552fc Mon Sep 17 00:00:00 2001 From: codereader Date: Sat, 24 Oct 2020 07:02:04 +0200 Subject: [PATCH] #5361: Set up configure.ac to detect the gtest framework. Adjust automake files --- Makefile.am | 2 +- configure.ac | 15 +++++++++++++++ radiant/Makefile.am | 10 +++++----- test/Makefile.am | 14 ++++++++------ test/RadiantTest.h | 26 ++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/Makefile.am b/Makefile.am index 46fdbeaeac..63588a2ac2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = libs radiantcore radiant plugins install/i18n doc test +SUBDIRS = libs radiantcore radiant plugins install/i18n doc @test_subdir@ # Install data and stuff gamedir = $(pkgdatadir)/games diff --git a/configure.ac b/configure.ac index 98fe85d89b..6858496507 100644 --- a/configure.ac +++ b/configure.ac @@ -306,6 +306,14 @@ else AC_MSG_NOTICE([Using the fmtlib headers shipped with the sources (header-only mode)]) fi +# Check for google test framework +AC_CHECK_HEADER([gtest/gtest.h], [test_subdir=test], [test_subdir='']) +# We assume that if gtest_main is present, gtest is present too +AC_CHECK_LIB([gtest_main], [main], + [AC_MSG_NOTICE(Google test headers and libraries are present)], + [test_subdir='']) +AC_SUBST([test_subdir]) + # dynamic link library AC_CHECK_LIB([dl], [main], [DL_LIBS='-ldl'], @@ -453,4 +461,11 @@ fi # echo " Use system fmtlib: no" #fi +if test -n "$test_subdir" +then + echo " DarkRadiant Tests: yes" +else + echo " DarkRadiant Tests: no" +fi + echo " Use boost.filesystem: $use_boost_filesystem" diff --git a/radiant/Makefile.am b/radiant/Makefile.am index 04f15fb2c3..1e94642c83 100644 --- a/radiant/Makefile.am +++ b/radiant/Makefile.am @@ -202,12 +202,12 @@ darkradiant_SOURCES = main.cpp \ map/StartupMapLoader.cpp \ log/Console.cpp -check_PROGRAMS = facePlaneTest vfsTest shadersTest -TESTS = $(check_PROGRAMS) +#check_PROGRAMS = facePlaneTest vfsTest shadersTest +#TESTS = $(check_PROGRAMS) -facePlaneTest_SOURCES = test/facePlaneTest.cpp \ - brush/FacePlane.cpp -facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la +#facePlaneTest_SOURCES = test/facePlaneTest.cpp \ +# brush/FacePlane.cpp +#facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la #vfsTest_SOURCES = test/vfsTest.cpp $(VFS_SOURCES) #vfsTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS) diff --git a/test/Makefile.am b/test/Makefile.am index fb6a00d5fd..92f0faf31c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,10 +1,12 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs \ $(XML_CFLAGS) -bin_PROGRAMS = test -testdir = $(pkglibdir)/bin/ -test_CPPFLAGS = $(AM_CPPFLAGS) -test_LDFLAGS = -lgtest -lgtest_main -lX11 \ +check_PROGRAMS = drtest +TESTS = $(check_PROGRAMS) + +drtestdir = $(pkglibdir)/bin/ +drtest_CPPFLAGS = $(AM_CPPFLAGS) +drtest_LDFLAGS = -lgtest -lgtest_main -lX11 \ $(XML_LIBS) \ $(GLEW_LIBS) \ $(GL_LIBS) \ @@ -18,12 +20,12 @@ test_LDFLAGS = -lgtest -lgtest_main -lX11 \ $(INTL_LIBS) \ $(WX_LIBS) \ $(Z_LIBS) -test_LDADD = $(top_builddir)/libs/scene/libscenegraph.la \ +drtest_LDADD = $(top_builddir)/libs/scene/libscenegraph.la \ $(top_builddir)/libs/wxutil/libwxutil.la \ $(top_builddir)/libs/xmlutil/libxmlutil.la \ $(top_builddir)/libs/math/libmath.la \ $(top_builddir)/libs/module/libmodule.la -test_SOURCES = Camera.cpp \ +drtest_SOURCES = Camera.cpp \ CSG.cpp \ HeadlessOpenGLContext.cpp \ ModelScale.cpp \ diff --git a/test/RadiantTest.h b/test/RadiantTest.h index 726cdc4d57..832cb14e11 100644 --- a/test/RadiantTest.h +++ b/test/RadiantTest.h @@ -13,6 +13,7 @@ #include "HeadlessOpenGLContext.h" #include "module/CoreModule.h" #include "messages/GameConfigNeededMessage.h" +#include "messages/NotificationMessage.h" namespace test { @@ -32,6 +33,7 @@ class RadiantTest : std::unique_ptr _coreModule; std::size_t _gameSetupListener; + std::size_t _notificationListener; std::shared_ptr _glContextModule; @@ -72,6 +74,11 @@ class RadiantTest : radiant::TypeListener( sigc::mem_fun(this, &RadiantTest::handleGameConfigMessage))); + _notificationListener = _coreModule->get()->getMessageBus().addListener( + radiant::IMessage::Type::Notification, + radiant::TypeListener( + sigc::mem_fun(this, &RadiantTest::handleNotification))); + try { // Startup the application @@ -89,6 +96,7 @@ class RadiantTest : void TearDown() override { + _coreModule->get()->getMessageBus().removeListener(_notificationListener); _coreModule->get()->getMessageBus().removeListener(_gameSetupListener); // Issue a shutdown() call to all the modules @@ -126,6 +134,24 @@ class RadiantTest : message.setConfig(config); message.setHandled(true); } + + void handleNotification(radiant::NotificationMessage& msg) + { + switch (msg.getType()) + { + case radiant::NotificationMessage::Information: + rMessage() << msg.getMessage() << std::endl; + break; + + case radiant::NotificationMessage::Warning: + rWarning() << msg.getMessage() << std::endl; + break; + + case radiant::NotificationMessage::Error: + rError() << msg.getMessage() << std::endl; + break; + }; + } }; }