Skip to content
Permalink
Browse files

Add cpp unit tests

  • Loading branch information
pblottiere committed Sep 2, 2020
1 parent 523c029 commit ffc65613ad3a7a558fd36ce9f82086d3ba4f631d
Showing with 73 additions and 0 deletions.
  1. +1 −0 tests/src/server/wms/CMakeLists.txt
  2. +72 −0 tests/src/server/wms/test_qgsserver_wms_parameters.cpp
@@ -79,6 +79,7 @@ SET(TESTS
test_qgsserver_wms_dxf.cpp
test_qgsserver_wms_restorer.cpp
test_qgsserver_wms_exceptions.cpp
test_qgsserver_wms_parameters.cpp
)

FOREACH(TESTSRC ${TESTS})
@@ -0,0 +1,72 @@
/***************************************************************************
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 "qgswmsparameters.h"

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

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

void external_layers();
};

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

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

void TestQgsServerWmsParameters::external_layers()
{
QUrlQuery query;
query.addQueryItem( "LAYERS", "EXTERNAL_WMS:external_layer_1,layer,EXTERNAL_WMS:external_layer_2" );
query.addQueryItem( "external_layer_1:url", "http://url_1" );
query.addQueryItem( "external_layer_1:layers", "layer_1_name" );
query.addQueryItem( "external_layer_2:url", "http://url_2" );
query.addQueryItem( "external_layer_2:layers", "layer_2_name" );

QgsWms::QgsWmsParameters parameters( query );

QList<QgsWms::QgsWmsParametersLayer> layers_params = parameters.layersParameters();
QCOMPARE( layers_params.size(), 3 );

QgsWms::QgsWmsParametersLayer layer_params = layers_params[0];
QCOMPARE( layer_params.mNickname, QString( "external_layer_1" ) );
QCOMPARE( layer_params.mExternalUri, QString( "layers=layer_1_name&url=http://url_1" ) );

layer_params = layers_params[1];
QCOMPARE( layer_params.mNickname, QString( "layer" ) );

layer_params = layers_params[2];
QCOMPARE( layer_params.mNickname, QString( "external_layer_2" ) );
QCOMPARE( layer_params.mExternalUri, QString( "layers=layer_2_name&url=http://url_2" ) );
}

QGSTEST_MAIN( TestQgsServerWmsParameters )
#include "test_qgsserver_wms_parameters.moc"

0 comments on commit ffc6561

Please sign in to comment.
You can’t perform that action at this time.