diff --git a/tests/src/server/wms/CMakeLists.txt b/tests/src/server/wms/CMakeLists.txt index b228f0e41c7..d450403ef77 100644 --- a/tests/src/server/wms/CMakeLists.txt +++ b/tests/src/server/wms/CMakeLists.txt @@ -37,13 +37,19 @@ SET(MODULE_WMS_SRCS ${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsrendercontext.cpp ) +SET(MODULE_WMS_HDRS + ${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsserviceexception.h +) + +QT5_WRAP_CPP(MODULE_WMS_MOC_SRCS ${MODULE_WMS_HDRS}) + MACRO (ADD_QGIS_TEST TESTSRC) SET (TESTNAME ${TESTSRC}) STRING(REPLACE "test" "" TESTNAME ${TESTNAME}) STRING(REPLACE "qgs" "" TESTNAME ${TESTNAME}) STRING(REPLACE ".cpp" "" TESTNAME ${TESTNAME}) SET (TESTNAME "qgis_${TESTNAME}test") - ADD_EXECUTABLE(${TESTNAME} ${TESTSRC} ${MODULE_WMS_SRCS}) + ADD_EXECUTABLE(${TESTNAME} ${TESTSRC} ${MODULE_WMS_SRCS} ${MODULE_WMS_MOC_SRCS}) SET_TARGET_PROPERTIES(${TESTNAME} PROPERTIES AUTOMOC TRUE) TARGET_LINK_LIBRARIES(${TESTNAME} ${Qt5Core_LIBRARIES} @@ -64,6 +70,7 @@ ENDMACRO (ADD_QGIS_TEST) SET(TESTS test_qgsserver_wms_dxf.cpp + test_qgsserver_wms_exceptions.cpp ) FOREACH(TESTSRC ${TESTS}) diff --git a/tests/src/server/wms/test_qgsserver_wms_exceptions.cpp b/tests/src/server/wms/test_qgsserver_wms_exceptions.cpp new file mode 100644 index 00000000000..045b62b7c18 --- /dev/null +++ b/tests/src/server/wms/test_qgsserver_wms_exceptions.cpp @@ -0,0 +1,57 @@ +/*************************************************************************** + test_qgsserver_wms_exceptions.cpp + --------------------------------- + Date : 27 Mar 2019 + Copyright : (C) 2019 by Paul Blottiere + Email : paul dot blottiere @ oslandia.com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgstest.h" +#include "qgswmsserviceexception.h" + +/** + * \ingroup UnitTests + * This is a unit test for the WMS Exceptions + */ +class TestQgsServerWmsExceptions : public QObject +{ + Q_OBJECT + + private slots: + void initTestCase(); + void cleanupTestCase(); + + void exception_code(); +}; + +void TestQgsServerWmsExceptions::initTestCase() +{ + QgsApplication::init(); + QgsApplication::initQgis(); +} + +void TestQgsServerWmsExceptions::cleanupTestCase() +{ + QgsApplication::exitQgis(); +} + +void TestQgsServerWmsExceptions::exception_code() +{ + QgsWms::QgsServiceException::ExceptionCode code = QgsWms::QgsServiceException::OGC_INVALID_FORMAT; + QgsWms::QgsServiceException exception0( code, QString(), 400 ); + QCOMPARE( exception0.code(), QString( "InvalidFormat" ) ); + + code = QgsWms::QgsServiceException::QGIS_ERROR; + QgsWms::QgsServiceException exception1( code, QString(), 400 ); + QCOMPARE( exception1.code(), QString( "Error" ) ); +} + +QGSTEST_MAIN( TestQgsServerWmsExceptions ) +#include "test_qgsserver_wms_exceptions.moc"