Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Mar 9, 2021
1 parent 5ba7cfb commit 35bac3e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/src/server/wms/CMakeLists.txt
Expand Up @@ -21,6 +21,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
#No relinking and full RPATH for the install tree
#See: http://www.cmake.org/Wiki/CMake_RPATH_handling#No_relinking_and_full_RPATH_for_the_install_tree
set(MODULE_WMS_SRCS
${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsrequest.cpp
${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsrenderer.cpp
${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsrestorer.cpp
${CMAKE_SOURCE_DIR}/src/server/services/wms/qgsmaprendererjobproxy.cpp
Expand Down Expand Up @@ -61,6 +62,7 @@ endmacro (ADD_QGIS_TEST)

set(TESTS
test_qgsserver_wms_dxf.cpp
test_qgsserver_wms_request.cpp
test_qgsserver_wms_restorer.cpp
test_qgsserver_wms_exceptions.cpp
test_qgsserver_wms_parameters.cpp
Expand Down
60 changes: 60 additions & 0 deletions tests/src/server/wms/test_qgsserver_wms_request.cpp
@@ -0,0 +1,60 @@
/***************************************************************************
test_qgsserver_wms_parameters.cpp
---------------------------------
Date : 02 Sept 2020
Copyright : (C) 2020 by Paul Blottiere
Email : paul dot blottiere @ gmail.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 "qgswmsrequest.h"

/**
* \ingroup UnitTests
* This is a unit test for the WMS parameters class
*/
class TestQgsServerWmsRequest : public QObject
{
Q_OBJECT

private slots:
void initTestCase();
void cleanupTestCase();

void cst();
};

void TestQgsServerWmsRequest::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();
}

void TestQgsServerWmsRequest::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsServerWmsRequest::cst()
{
QgsServerRequest request;
request.setParameter( "VERSION", "1.0.0" );

// the base class for parameters provides raw values...
QCOMPARE( request.serverParameters().version(), "1.0.0" );

// ...whereas the wms parameters class interprets values to be valid in the
// WMS context
QgsWms::QgsWmsRequest wmsRequest( request );
QCOMPARE( wmsRequest.wmsParameters().version(), "1.1.1" );
}

QGSTEST_MAIN( TestQgsServerWmsRequest )
#include "test_qgsserver_wms_request.moc"

0 comments on commit 35bac3e

Please sign in to comment.