Skip to content
Permalink
Browse files

Add test for map edit tool. Test the correctness of getting default z.

  • Loading branch information
alisovenko committed Feb 6, 2017
1 parent d780ba7 commit 332961f7484aec324f1db586dafac0c34127d409
Showing with 84 additions and 0 deletions.
  1. +1 −0 tests/src/gui/CMakeLists.txt
  2. +83 −0 tests/src/gui/testqgsmaptooledit.cpp
@@ -119,6 +119,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
ENDMACRO (ADD_QGIS_TEST)

ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)
ADD_QGIS_TEST(edittooltest testqgsmaptooledit.cpp)

# a simple app for testing GUI of renderers
# These tests are old and are never run so removed for now.
@@ -0,0 +1,83 @@
/***************************************************************************
testqgsmaptooledit.cpp
--------------------------------------
Date : 6.2.2017
Copyright : (C) 2017 Alexander Lisovenko
Email : alexander.lisovenko@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 <QCoreApplication>

#include "qgstest.h"
#include <qgisgui.h>
#include <qgsmaptooledit.h>
#include <qgsapplication.h>
#include <qgsmapcanvas.h>
#include <qgslogger.h>

class TestQgsMapToolEdit : public QObject
{
Q_OBJECT
public:
TestQgsMapToolEdit()
: mCanvas( 0 )
{}

private slots:
void initTestCase(); // will be called before the first testfunction is executed.
void cleanupTestCase(); // will be called after the last testfunction was executed.
void init(); // will be called before each testfunction is executed.
void cleanup(); // will be called after every testfunction.

void checkDefaultZValue();

private:
QgsMapCanvas* mCanvas;

};

void TestQgsMapToolEdit::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();
QgsApplication::showSettings();
}

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

void TestQgsMapToolEdit::init()
{
mCanvas = new QgsMapCanvas();
}

void TestQgsMapToolEdit::cleanup()
{
delete mCanvas;
}

void TestQgsMapToolEdit::checkDefaultZValue()
{
QSettings settings;
settings.remove( "/qgis/digitizing/default_z_value" );

QgsMapToolEdit* tool = new QgsMapToolEdit( mCanvas );
QCOMPARE( tool->defaultZValue(), Qgis::DEFAULT_Z_COORDINATE );

double z_value_for_test = Qgis::DEFAULT_Z_COORDINATE + 1;
settings.setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), z_value_for_test );


QCOMPARE( tool->defaultZValue(), z_value_for_test );
}

QGSTEST_MAIN( TestQgsMapToolEdit )
#include "testqgsmaptooledit.moc"

0 comments on commit 332961f

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