Skip to content

Commit

Permalink
Add test for map edit tool. Test the correctness of getting default z.
Browse files Browse the repository at this point in the history
  • Loading branch information
alisovenko committed Feb 6, 2017
1 parent d780ba7 commit 332961f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/src/gui/CMakeLists.txt
Expand Up @@ -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.
Expand Down
83 changes: 83 additions & 0 deletions tests/src/gui/testqgsmaptooledit.cpp
@@ -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.