mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add test for map edit tool. Test the correctness of getting default z.
This commit is contained in:
parent
d780ba7593
commit
332961f748
@ -119,6 +119,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
|
|||||||
ENDMACRO (ADD_QGIS_TEST)
|
ENDMACRO (ADD_QGIS_TEST)
|
||||||
|
|
||||||
ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)
|
ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)
|
||||||
|
ADD_QGIS_TEST(edittooltest testqgsmaptooledit.cpp)
|
||||||
|
|
||||||
# a simple app for testing GUI of renderers
|
# a simple app for testing GUI of renderers
|
||||||
# These tests are old and are never run so removed for now.
|
# These tests are old and are never run so removed for now.
|
||||||
|
83
tests/src/gui/testqgsmaptooledit.cpp
Normal file
83
tests/src/gui/testqgsmaptooledit.cpp
Normal file
@ -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"
|
Loading…
x
Reference in New Issue
Block a user